hiyouga/LlamaFactory

Unified Efficient Fine-Tuning of 100+ LLMs & VLMs (ACL 2024)

LlamaFactory – One‑click fine‑tuning for dozens of LLMs

What it is – LlamaFactory is an open‑source Python toolkit that lets you fine‑tune, evaluate, and serve more than 100 large language models (LLMs) with virtually no code. It ships a command‑line interface and a Gradio‑based web UI (the LlamaBoard) so you can run experiments locally or in the cloud (Colab, SageMaker, AMD/Ascend GPUs, etc.).

Why it matters – Training or adapting modern LLMs usually requires deep knowledge of distributed training, quantization, and optimizer tricks. LlamaFactory bundles a huge collection of state‑of‑the‑art methods (LoRA, QLoRA, FlashAttention‑2, GaLore, BAdam, ORPO, DPO, PPO, KTO, …) and makes them selectable via a simple YAML config. The result is a “zero‑code” workflow that still gives you access to the latest research.


Core capabilities

Category What you can do
Model coverage LLaMA‑1/2/3/4, LLaVA, Mistral, Mixtral‑MoE, Qwen 2/3/2.5‑VL, DeepSeek, Gemma 3, GLM‑4, Phi‑4, InternLM, MiniCPM‑o, PaliGemma, etc.
Training paradigms Full‑parameter, freeze‑tuning, 8‑bit/4‑bit/2‑bit QLoRA, LoRA+, LongLoRA, DoRA, block‑expansion, continuous pre‑training, supervised fine‑tuning, multimodal (image/video/audio) fine‑tuning, reward‑modeling, PPO/DPO/ORPO/KTO, reinforcement‑learning via EasyR1
Optimizers & tricks GaLore, BAdam, APOLLO, Adam‑mini, Muon, OFT/​OFTv2, NEFTune, rsLoRA, RoPE scaling, FlashAttention‑2, Unsloth, Liger‑Kernel, KTransformers, SGLang/vLLM inference back‑ends
Hardware support NVIDIA GPUs, AMD ROCm, Ascend NPU, Intel Gaudi, SageMaker HyperPod, Docker containers, Colab notebooks
Monitoring TensorBoard, Weights & Biases, MLflow, SwanLab, built‑in LlamaBoard UI
Deployment OpenAI‑compatible REST API, Gradio UI, vLLM or SGLang workers for high‑throughput serving
Data handling Built‑in dataset loaders, data‑centric pipelines (DataFlow, DataFlex), automatic packing to avoid contamination

Typical workflow (quick‑start)

  1. Installpip install llamafactory or pull the Docker image hiyouga/llamafactory.
  2. Prepare data – place your training set in a folder or use one of the provided examples (e.g., glaive_toolcall_en for tool‑use). LlamaFactory can also download from ModelScope/Modelers Hub.
  3. Create a config – a short YAML file selects the model, dataset, tuning method (e.g., lora), quantization bits, and any special tricks (use_unsloth: true).
  4. Runllamafactory train path/to/config.yaml (CLI) or launch the GUI with llamafactory gui and start the job with a few clicks.
  5. Track – metrics appear in LlamaBoard; optionally push logs to WandB/MLflow/SwanLab.
  6. Serve – after training, run llamafactory serve path/to/ckpt.yaml to expose an OpenAI‑style endpoint or a Gradio chat interface.

Who should use it?

  • Researchers who need to prototype new fine‑tuning recipes without writing boiler‑plate training loops.
  • Product teams that want to adapt a public LLM (e.g., Llama 3, Qwen 3) to a domain‑specific corpus quickly.
  • Educators & students looking for a ready‑made environment for labs on RL‑HF, preference learning, or multimodal LLMs.
  • Ops engineers who prefer a containerised, reproducible pipeline that can run on cloud GPUs, SageMaker, or on‑prem NPU clusters.

Installation & deployment options

  • Pippip install llamafactory (adds llamafactory CLI).
  • Dockerdocker pull hiyouga/llamafactory then run with your GPU device mounted.
  • Colab / DSW – ready‑made notebooks linked in the README for free‑tier experiments.
  • vLLM / SGLang – set infer_backend: vllm (or sglang) in the serving config for up to 2‑3× faster inference.

Community & ecosystem

  • Stars & activity – > 1 k GitHub stars, CI tests, frequent releases.
  • Industry adoption – used by Amazon, NVIDIA, Alibaba Cloud for production fine‑tuning.
  • Support channels – Discord, WeChat groups, official blog, and a growing list of tutorials.
  • Citation – a paper “LlamaFactory: Unified Efficient Fine‑Tuning of 100+ Language Models” (arXiv) is provided for academic credit.

TL;DR

LlamaFactory is a comprehensive, zero‑code platform for fine‑tuning a wide variety of LLMs on many hardware back‑ends. It bundles the latest training tricks, offers both CLI and a friendly GUI, supports experiment tracking, and can instantly spin up an OpenAI‑compatible API for serving the resulting model.

Related

  • Project
  • Project
  • Project
  • Project
  • Project