LlamaFactory
by hiyouga
Toolkit for fine-tuning many open language and vision-language models with one unified interface.
- Stars
- 76,269 stars
- Forks
- 9.4k forks
- Last push
- today
- Activity
- Active
# Install from source$ git clone --depth 1 https://github.com/hiyouga/LlamaFactory.git
cd LlamaFactory
pip install -e .
pip install -r requirements/metrics.txt# Open the web UI$ llamafactory-cli webuiCommands from the project's README. Run them after installing (see below).
Overview
Understand LlamaFactory in 60 seconds
- What it does
- LlamaFactory is a toolkit for fine-tuning more than 100 large language models with a command line or a web UI and little or no code. It supports LoRA, QLoRA, full fine-tuning, DPO, PPO and more for models like Qwen, LLaMA, Mistral, DeepSeek and Gemma.
- The problem it solves
- Fine-tuning usually means writing training scripts and wiring libraries together for each model. LlamaFactory puts many models and methods behind YAML configs, a three-command workflow and a Gradio web interface called LLaMA Board.
- Why choose it
- Choose it for broad model and method coverage with a zero-code UI. You still need a suitable GPU; the README's table estimates 6 GB for 4-bit QLoRA on a 7B model.
- Who should use it
- Developers fine-tuning open models on their data
- Researchers comparing training methods
- Teams without deep ML engineering resources
- Users of NVIDIA, AMD or Ascend NPU hardware
- Setup difficulty
You'll need:
- Python 3.11+
- PyTorch 2.0+ (2.6 recommended)
- A GPU with enough memory (CUDA 11.6+, or AMD ROCm, or Ascend NPU)
- Optional: Docker
How LlamaFactory works
LlamaFactory supports many model families, including LLaMA, LLaVA, Mistral, Mixtral, Qwen3, Qwen3-VL, DeepSeek, Gemma, GLM and Phi. Methods include continued pre-training, supervised fine-tuning (including multimodal), reward modelling, PPO, DPO, KTO and ORPO.
Training can be 16-bit full or freeze tuning, LoRA, or QLoRA at 2 to 8 bits through several quantization backends, with advanced optimisers like GaLore, BAdam and APOLLO and speed-ups such as FlashAttention-2, Unsloth and Liger Kernel. A hardware table estimates memory needs, from 6 GB for 4-bit QLoRA on a 7B model.
You can train from the CLI with YAML configs, use the LLaMA Board web UI, or run in free cloud notebooks such as Colab. Fine-tuned models can be served with an OpenAI-style API backed by vLLM. Model weights keep their own licenses.
Features
Key features
100+ models
Qwen, LLaMA, Mistral, DeepSeek, Gemma, GLM and more.
Many methods
SFT, reward modelling, PPO, DPO, KTO and ORPO.
LoRA and QLoRA
2 to 8-bit QLoRA to fit smaller GPUs.
LLaMA Board web UI
Fine-tune without writing code.
OpenAI-style API
Serve models with vLLM.
Multiple backends
NVIDIA, AMD ROCm and Ascend NPU.
Strengths
- Huge model and method coverage
- Zero-code CLI and web UI
- Widely used and cited
- Apache-2.0 licensed
Limitations
- Needs a capable GPU for anything beyond small models
- Many optional dependencies to manage
- Model weights have their own licenses
Practical use cases
Domain chatbot
LoRA fine-tune Qwen on your support conversations.
Preference tuning
Align a model with DPO using paired data.
Serve a fine-tune
Expose the result through an OpenAI-style API.
Installation
Install LlamaFactory
Commands come from LlamaFactory's README. AIRepoHub hasn't run them yet. View source
Prerequisites
- Python 3.11+
- PyTorch
- A GPU
Supported systems
- Linux
- Windows
- 1
Clone and install
Shellgit clone --depth 1 https://github.com/hiyouga/LlamaFactory.gitcd LlamaFactorypip install -e .pip install -r requirements/metrics.txt - 2
Check the CLI
Shellllamafactory-cli help
- 1
Run the prebuilt image
Ubuntu 22.04, CUDA 12.4, Python 3.11, PyTorch 2.6.
Shelldocker run -it --rm --gpus=all --ipc=host hiyouga/llamafactory:latest
- 1
Open the Colab notebook linked in the README
Trains in the cloud with no local GPU.
Configuration and API keys
| Setting | What it's for |
|---|
First run
- 1
Start the web UI
Shellllamafactory-cli webui
LlamaFactory's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.
Your first project
LoRA fine-tune Qwen3 in three commands
Fine-tune, chat with and merge a small model using the bundled examples.
Before you start
- LlamaFactory installed from source
- A GPU
- 1
Train a LoRA adapter
Shellllamafactory-cli train examples/train_lora/qwen3_lora_sft.yaml - 2
Chat with the result
Shellllamafactory-cli chat examples/inference/qwen3_lora_sft.yaml - 3
Merge the adapter into the model
Shellllamafactory-cli export examples/merge_lora/qwen3_lora_sft.yaml
What to expect
A Qwen3-4B-Instruct model fine-tuned with LoRA that you can chat with and export as a merged model.
Next steps
- Add your own dataset in data/dataset_info.json
- Try the LLaMA Board web UI
- Serve it with llamafactory-cli api and vLLM
Costs and requirements
What it costs to run
- License
- Apache-2.0. Model weights follow their own licenses.Free
- Software
- Free and open source.Free
- Compute
- Your GPU, or free cloud notebooks like Colab for small runs.Depends
Troubleshooting
Common setup issues
Something fails
Read the FAQs linked in the README first, and run llamafactory-cli help.
Custom dataset not found
Register it in data/dataset_info.json; see data/README.md for formats.
Out of GPU memory
Use LoRA or lower-bit QLoRA; check the hardware requirement table.
AMD GPU
Install PyTorch from AMD's index as the README describes.
Alternatives
Similar AI repositories
ollama
ollama
Run open models like Gemma, Qwen and DeepSeek on your own machine with a single command.
open-webui
open-webui
Self-hosted chat interface for Ollama and OpenAI-compatible models.
llama.cpp
ggml-org
Fast LLM inference in plain C/C++, from laptops to servers.
NextChat
ChatGPTNextWeb
Chat app for talking to many AI models like GPT, Claude and Gemini on web, desktop and mobile.