LlamaFactory: Unified Efficient Fine-Tuning for 100+ LLMs & VLMs

May 31, 2025

Introduction

Fine-tuning large language models (LLMs) often involves complex configurations, significant engineering effort, and a steep learning curve for managing VRAM and hyperparameters. LlamaFactory, with over 73k GitHub stars, is a unified, open-source framework designed to democratize the process of adapting pre-trained models to specific tasks. It replaces the need for writing extensive boilerplate code by providing a standardized interface for fine-tuning over 100 different language and vision-language models (VLMs).

What Is LlamaFactory?

LlamaFactory is a unified efficient fine-tuning framework that provides a standardized interface for training and adapting over 100 large language models (LLMs) and vision-language models (VLMs). Maintained by hiyouga and licensed under the Apache License 2.0, it abstracts the complexity of the training pipeline—including tokenizers, data loaders, and adapters—into a coherent, platform-agnostic system.

The project focuses on providing a “code-free” experience, allowing users to launch training jobs via a Gradio-based web interface (LlamaBoard) or a command-line interface (CLI), making it accessible to researchers and developers who may not be deep-learning experts.

Why LlamaFactory Matters

Before LlamaFactory, fine-tuning an LLM typically required deep knowledge of the Hugging Face Transformers library, PyTorch, and complex YAML configurations. Developers had to manually handle data formatting, adapter merging, and memory optimization techniques like QLoRA. This created a high barrier to entry for those wanting to specialize a model on domain-specific data.

LlamaFactory fills this gap by unifying a variety of efficient fine-tuning methods (SFT, RLHF, DPO, PPO) and optimization algorithms (GaLore, DoRA, LoRA+) into a single toolkit. Its rapid adoption, evidenced by its massive star count and frequent updates, shows a clear industry shift toward tools that prioritize developer experience and accessibility without sacrificing the power of low-level optimizations.

Investing time in LlamaFactory now is critical because it provides a single entry point to the most cutting-edge models (like Llama 3, Qwen 3, and DeepSeek) and the most efficient training methods (like Unsloth and FlashAttention-2), ensuring that your fine-tuning workflows remain current with the latest AI research.

Key Features

  • Multi-Model Support: Supports over 100 LLMs and VLMs, including Llama, Mistral, Qwen, Phi, Gemma, DeepSeek, and GLM, ensuring compatibility with almost any open-source model.
  • Diverse Training Methods: Integrated support for (continuous) pre-training, supervised fine-tuning (SFT), reward modeling, and preference optimization methods like PPO, DPO, KTO, and ORPO.
  • Advanced Computation Precision: Offers 16-bit full-parameter fine-tuning, freeze-tuning, and a wide range of QLoRA options (2/3/4/5/6/8-bit) via AQLM, AWQ, GPTQ, and HQQ.
  • Cutting-Edge Optimization Algorithms: Implements advanced algorithms such as GaLore, BAdam, DoRA, LongLoRA, and PiSSA to reduce memory overhead and improve training stability.
  • LlamaBoard Web UI: A Gradio-based, no-code interface that allows users to configure hyperparameters, select datasets, and monitor training progress visually.
  • Integrated Dataset Management: Simplifies the process of adding custom datasets via a dataset_info.json file, supporting formats like JSON, JSONL, CSV, and Parquet.
  • High-Performance Acceleration: Integrates FlashAttention-2 and Unsloth to significantly speed up training and reduce VRAM usage.
  • Experiment Monitoring: Native integration with TensorBoard, WandB, MLflow, and SwanLab for detailed tracking of loss curves and training metrics.
  • Model Export and Deployment: Provides tools to merge LoRA adapters and export models to formats like GGUF or vLLM for faster inference.
  • Multimodal Capabilities: Supports fine-tuning for vision-language models (VLMs) for tasks like image understanding and visual grounding.

How LlamaFactory Compares

Feature LlamaFactory Unsloth Axolotl
Web UI (No-Code) Yes (LlamaBoard) No No
Primary Focus Unified Interface & Accessibility Raw Speed & VRAM Efficiency Config-Driven (YAML) Flexibility
Model Support 100+ (Extensive) Selective (Optimized) Broad
Training Methods SFT, RLHF, DPO, PPO, KTO SFT, LoRA/QLoRA SFT, LoRA, RLHF
Ease of Setup High (Web UI) Medium Medium

LlamaFactory is the most comprehensive tool for those who want a single, unified interface for experimenting with many different models and training methods. While Unsloth is significantly faster for specific models it optimizes, LlamaFactory actually integrates Unsloth as a backend to provide the best of both worlds: accessibility and speed. Axolotl is preferred by power users who prefer a strict YAML-based configuration for reproducibility in professional pipelines.

The primary tradeoff is that LlamaFactory’s abstraction layer adds a small amount of overhead. However, for 95% of developers, the time saved in configuration and the ability to rapidly prototype across different model families (e.g., switching from Llama 3 to Qwen 3) is far more valuable than the raw performance gains of a specialized tool.

Getting Started: Installation

LlamaFactory requires Python 3.11–3.13 and CUDA 11.8 or 12.1 for NVIDIA GPUs. Ensure you have the necessary GPU drivers installed before proceeding.

Installation from Source

git clone --depth 1 https://github.com/hiyouga/LlamaFactory.git
cd LlamaFactory
pip install -e ".[torch,metrics]"

Installation with Docker

docker pull hiyouga/llamafactory:latest
docker run --gpus all \
  -v ./hf_cache:/root/.cache/huggingface \
  -v ./data:/app/data \
  -v ./output:/app/output \
  -p 7860:7860 \
  -e GRADIO_SHARE=1 \
  hiyouga/llamafactory:latest

To verify the installation, you can launch the Web UI using the following command:

llamafactory-cli webui

How to Use LlamaFactory

The simplest way to start is using the LlamaBoard Web UI. Once launched, you can select your model (e.g., Llama-3-8B) and a dataset from the dropdown menus. You can then configure the learning rate, epochs, and training method (e.g., QLoRA) using the sliders and input fields.

For those who prefer the CLI, LlamaFactory uses YAML configuration files to define the training job. You can find examples in the examples/ directory of the repository. To start a training job, run:

llamafactory-cli train examples/train_lora/qwen3_lora_sft.yaml

This command tells LlamaFactory to load the model, prepare the data, and load the LoRA adapters, then begin the supervised fine-tuning process based on the parameters defined in the YAML file.

Code Examples

To add a custom dataset, you must modify the data/dataset_info.json file. This file acts as a registry for all datasets available to the framework. Here is an example of how to define a custom dataset in Alpaca format:

{
  "my_custom_dataset": {
    "hf_hub_url": "https://huggingface.co/datasets/user/my-data",
    "file_name": "data.json",
    "formatting": "alpaca",
    "columns": {
      "prompt": "instruction",
      "query": "input",
      "response": "output"
    }
  }
}

This configuration tells LlamaFactory where to find the data, what format it is in, and which columns map to the prompt, input, and response fields required for SFT.

After defining the dataset, it will appear in the LlamaBoard Web UI dropdown, allowing you to select it for training.

Real-World Use Cases

LlamaFactory shines in scenarios where rapid experimentation and domain specialization are required:

  • Domain-Specific Chatbots: A developer can use LlamaFactory to fine-tune a Llama 3 model on a company’s internal documentation and technical manuals to create a highly accurate technical support bot.
  • Medical AI Assistants: A researcher can use QLoRA to fine-tune a Mistral model on medical journals and patient records (anonymized) to specialize the model in medical terminology and diagnostic suggestions.
  • Legal Document Analysis: A legal tech startup can use LlamaFactory’s DPO (Direct Preference Optimization) to align a model’s output to follow strict legal formatting and professional tone, ensuring the model doesn’t hallucinate legal citations.
  • VLM Fine-Tuning: An e-commerce company can fine-tune a vision-language model (VLM) on their product catalog images and descriptions to enable high-accuracy visual grounding and product search.

Contributing to LlamaFactory

LlamaFactory is an active open-source project. You can contribute by reporting bugs via GitHub Issues, submitting Pull Requests for new model support, or improving the documentation. The project follows a standard GitHub flow for contributions. If you are interested in contributing, refer to the CONTRIBUTING.md file in the root of the repository for detailed guidelines on coding standards and PR submission process.

Community and Support

The LlamaFactory community is massive and growing. Official support is and primarily handled through GitHub Discussions and the official documentation site at llamafactory.readthedocs.io. Because of its popularity, there are numerous community-led tutorials and guides on platforms like DataCamp and Medium.

Conclusion

LlamaFactory is the definitive tool for anyone looking to customize large language models without the engineering overhead of writing custom training scripts. By unifying over 100 models and the most efficient training methods into a single, accessible interface, it has effectively democratized the process of AI model specialization.

Whether you are a researcher prototyping a new alignment method or a developer building a domain-specific AI application, LlamaFactory is the right choice when you need to rapidly iterate across different model families and training techniques. It is not the recommended tool for those who are seeking the absolute maximum raw performance of a specialized, single-model optimizer, but for the vast majority of users, the accessibility and breadth of support is an unbeatable advantage.

Star the repo, try the quickstart, and join the community to start fine-tuning your first custom LLM today.

What is LlamaFactory and what problem does it solve?

LlamaFactory is an open-source framework that simplifies the fine-tuning of over 100 large language models (LLMs) and vision-language models (VLMs). It solves the problem of complex configuration and high engineering overhead associated with traditional fine-tuning workflows by providing a unified, no-code interface.

How do I install LlamaFactory?

LlamaFactory can be installed from source via git clone and pip install, or via a Docker image. It requires Python 3.11–3.13 and CUDA 11.8 or 12.1 for NVIDIA GPUs.

How does LlamaFactory compare to Unsloth?

LlamaFactory is a unified framework that prioritizes accessibility and broad model support, whereas Unsloth is a specialized optimizer that focuses on raw speed and VRAM efficiency. LlamaFactory actually integrates Unsloth as a backend to provide both ease of use and high performance.

Can I use LlamaFactory for multimodal fine-tuning?

SFT for vision-language models (VLMs) is fully supported, allowing you to fine-tune models for tasks like image understanding and visual grounding.

What are the VRAM requirements for LlamaFactory?

VRAM requirements depend on the training method. QLoRA (4-bit) typically requires 8GB VRAM for 7B models, while full fine-tuning requires significantly more (approx 14GB per 7B parameters plus optimizer states).

What license does LlamaFactory use?

LlamaFactory is licensed under the Apache License 2.0, which allows for free use, modification, and distribution of the software.

Can I use LlamaFactory to fine-tune Llama 3?

SFT and preference optimization (DPO/PPO) are fully supported for Llama 3 and other cutting-edge models like Qwen 3 and DeepSeek.