# Repository Briefing: hiyouga/LlamaFactory
> Source: https://repoforai.com/repo/hiyouga/LlamaFactory (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/hiyouga/LlamaFactory
- **Official Docs / Website**: https://llamafactory.readthedocs.io
- **Category**: LLMs & Inference (大模型与推理微调)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A+ (92/100 · Maintenance 35/35 · Adoption 23/25 · Releases 14/20 · License 20/20)
- **Latest Release**: v0.9.5 (2026-05-30) — https://github.com/hiyouga/LlamaFactory/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Docker, CLI, GPU
- **Momentum**: 76,384 ★ total (+28 24h / +86 7d) · 9,430 forks
- **Topics**: `agent`, `ai`, `deepseek`, `fine-tuning`, `gemma`, `gpt`, `instruction-tuning`, `large-language-models`, `llama`, `llama3`, `llm`, `lora`
- **When to Use**: Best for: Teams comparing LLM or VLM fine-tuning recipes across model families and validating the resulting checkpoints through a local UI, CLI, or self-hosted API. Skip if: You already have a checkpoint and only need inference serving, or you need a managed service rather than maintaining GPU and backend dependencies.

## Overview
```text
### Architecture & Core Mechanics
LlamaFactory is a Python/PyTorch training framework with an inference layer, not a standalone inference engine. A typical run starts by matching a model family to its input template, then choosing a training objective such as supervised fine-tuning (SFT) or DPO and a parameter-update method such as full tuning or LoRA. These are separate decisions: switching to LoRA changes which parameters are updated, not what the training objective optimizes.

The package uses Hatchling, with source under `src/` and separate `data/`, `examples/`, and `docker/` directories. The CLI and LlamaBoard provide scripted and browser-based workflows respectively. Inference has its own OpenAI-style API, Gradio UI, and CLI, with vLLM and SGLang available as worker integrations. The API is the application integration point; the worker is the execution backend.

### Key Capabilities & Differentiators
The model catalog spans text and multimodal families, including Llama, Qwen3-VL, DeepSeek, and Gemma. Model selection includes the template: DeepSeek 3 and DeepSeek R1, for example, use `deepseek3` and `deepseekr1` respectively. Training covers continued pretraining, multimodal SFT, reward modeling, PPO, DPO, KTO, and ORPO. Supported task types include tool use and image, video, and audio understanding, depending on the chosen model.

The tuning matrix covers 16-bit full tuning, freeze tuning, LoRA, QLoRA, OFT, and QOFT. Quantized LoRA options span 2–8 bits through integrations such as AQLM, AWQ, GPTQ, HQQ, and EETQ. FlashAttention-2 and Liger Kernel are optional acceleration integrations; TensorBoard, W&B, MLflow, and SwanLab cover experiment monitoring. Treat these as choices to validate, not features that can necessarily be combined in one run.

### Trade-offs & Limitations
Choose LlamaFactory when the work spans training and inference validation across model families. Compared with maintaining separate training scripts, its shared workflows reduce repeated setup for common experiments. The cost is a larger compatibility surface: a model, template, tuning method, quantizer, and acceleration kernel may each be supported without working together in the combination you want. Validate the exact combination on a small run first.

For serving an existing checkpoint, deploying vLLM or SGLang directly avoids the training framework layer. For training, LoRA reduces trainable state and QLoRA also shrinks the base-weight footprint, but neither eliminates activation memory or makes long contexts cheap. Size training and serving independently. Apache-2.0 applies to the framework; model weights and training data retain their own terms.

### Hardware & Deployment Guide
Use Python 3.11 or later; v0.9.4 moved the minimum version past Python 3.9 and 3.10. For a source install, clone the repository and run `pip install -e .` from its root. The quickstart separately installs metrics dependencies with `pip install -r requirements/metrics.txt`. The repository includes a `docker/` directory, but the available details do not establish a specific image tag or launch command.

For self-hosting, stage the model weights and datasets and check that the GPU runtime matches the quantization, kernel, or serving backend you intend to use. Start with a small training and inference smoke test before adding optional components. For upgrades, v0.9.5 adds support for Qwen3.5, Qwen3.6, and Gemma 4 as well as Transformers v5 compatibility. Pin and test the model, template, and dependency versions together, especially when introducing a new model or worker.
```

## Key Capabilities
```text
- Model adaptation: Family-specific templates include `deepseek3`, `deepseekr1`, `gemma3`, and `glm4_moe`.
- Training objectives: Continued pretraining and multimodal SFT sit alongside reward modeling, PPO, DPO, KTO, and ORPO.
- Parameter updates: The training matrix separates full and freeze tuning from LoRA, QLoRA, OFT, and QOFT.
- Quantized tuning: QLoRA options span 2–8 bits across integrations including AQLM, AWQ, GPTQ, HQQ, and EETQ; supported combinations vary.
- Inference interfaces: OpenAI-style API, Gradio UI, and CLI, with vLLM or SGLang worker integrations.
- Release compatibility: v0.9.5 adds Qwen3.5, Qwen3.6, and Gemma 4 support, plus Transformers v5 compatibility.
```

## Quick Start / Clone
```bash
git clone --depth 1 https://github.com/hiyouga/LlamaFactory.git
cd LlamaFactory
pip install -e .
pip install -r requirements/metrics.txt
```
