hiyouga/LlamaFactory
A unified Python framework for LLM and VLM fine-tuning with pluggable inference
Automated SPDX check for reference only — not legal advice. Disclaimer
GitHub Star History
Full-history star trajectory from GitHub official history. Switch ranges or hover any point for exact counts.
Evidence-Backed Technical Brief
AI Deep ReviewArchitecture & 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.
deepseek3, deepseekr1, gemma3, and glm4_moe.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.
You already have a checkpoint and only need inference serving, or you need a managed service rather than maintaining GPU and backend dependencies.
Quick Start & Installation
git clone --depth 1 https://github.com/hiyouga/LlamaFactory.git cd LlamaFactory pip install -e . pip install -r requirements/metrics.txt
Comparison vs. Top LLMs & Inference Alternatives
Full comparison →| Repository | Stars | 7d Trend | Stack | License | Core Positioning |
|---|---|---|---|---|---|
| LlamaFactory ★ | 76.4k | +86 | Python | Apache-2.0 | A unified Python framework for LLM and VLM fine-tuning with pluggable inference |
| peft | 21.9k | +32 | Python | Apache-2.0 | Python/PyTorch adapters for fine-tuning large models without updating base weigh |
| axolotl | 12.8k | +15 | Python | Apache-2.0 | YAML-driven GPU trainer for LLM and multimodal post-training |
| minimind | 75.4k | +3.1k | Python | Apache-2.0 | Native PyTorch dense and MoE models for end-to-end LLM training on local GPUs |
AI Context Briefing (for Claude / Cursor / Windsurf)
Standardized architecture summary & quickstart commands ready to paste into coding agents.
curl -sL https://repoforai.com/repo/hiyouga/LlamaFactory.md
Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).
Frequently Asked Questions about LlamaFactory
How do I connect a fine-tuning run to an existing application?
How should I size GPU memory for training and serving?
Can I self-host it commercially and distribute the resulting model?
When should I use LlamaFactory instead of vLLM or SGLang directly?
Upstream README & Documentation
This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.
Top 10 Breakout Open-Source AI Repos, Every Thursday
Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.
Zero spam · 1-click unsubscribe · Privacy Policy