LLaMA-Factory
CLAUDE.md76k starsChanged 48 days agoApache-2.0View on GitHub
The project uses uv as the preferred package manager. Commands automatically use uv run / uvx if uv is available. LlamaFactory has two parallel architectures controlled by the USE_V1 environment variable: Most active development happens in v0. The v1 architecture lives in src/llamafactory/v1/. CLI entry point is llamafactory-cli / lmf → src/llamafactory/cli.py:main(), which dispatches to launcher.py based on USE_V1. Available subcommands: train, chat, api, export, webchat, webui, env, version, help. Training is invoked with a YAML config: llamafactory-cli train examples/trainlora/llama3lora_sft.yaml
We split this CLAUDE.md into the rules it gives an agent
6 rules. About 0 are common, 0 are distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 61
All training parameters are YAML/JSON config files.
- Very specific: line 82
Add a prompt template to src/llamafactory/data/template.py in the TEMPLATES dict
- Very specific: line 83
Add any necessary model patches in src/llamafactory/model/patcher.py
- Very specific: line 84
Add multi-modal support in src/llamafactory/data/mm_plugin.py if needed
- Very specific: line 98
Always set WANDB_DISABLED=true when running tests
- Very specific: line 105
All new files must include Apache 2.0 license header (checked by make license)
≈ “Common” is an estimate: at least 1 in 5 of the 25,680 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Commands
# Code style (auto-fix)
make style
# Code quality check (no modifications)
make quality
# Run all tests
make test
# Run a single test file
WANDB_DISABLED=true pytest -vv --import-mode=importlib tests/path/to/test_file.py
# Run tests matching a pattern
WANDB_DISABLED=true pytest -vv --import-mode=importlib tests/ -k "test_name"
# License header check
make license
# Build package
make buildThe project uses uv as the preferred package manager. Commands automatically use uv run / uvx if uv is available.
Architecture
LlamaFactory has two parallel architectures controlled by the USE_V1 environment variable:
- v0 (default):
api, webui > chat, eval, train > data, model > hparams > extras - v1 (experimental,
USE_V1=1):trainers > core > accelerator, plugins, config > utils
Most active development happens in v0. The v1 architecture lives in src/llamafactory/v1/.
Entry Points
CLI entry point is llamafactory-cli / lmf → src/llamafactory/cli.py:main(), which dispatches to launcher.py based on USE_V1.
Available subcommands: train, chat, api, export, webchat, webui, env, version, help.
Training Flow (v0)
run_exp() [tuner.py]
→ read_args() → parse YAML/JSON config
→ get_train_args() → produces typed argument dataclasses
→ routes to: run_sft / run_dpo / run_ppo / run_rm / run_pt / run_kto
→ optional: export_model()Training is invoked with a YAML config: llamafactory-cli train examples/train_lora/llama3_lora_sft.yaml
Configuration System
All training parameters are YAML/JSON config files. Argument parsing in src/llamafactory/hparams/parser.py produces four typed dataclasses:
ModelArguments— model/tokenizer selection, quantizationDataArguments— datasets, templates, preprocessingFinetuningArguments— LoRA rank/target, training method (sft/dpo/ppo/rm/pt/kto)TrainingArguments— extends HuggingFace'sTrainingArguments
Key Modules
| Module | Purpose |
src/llamafactory/model/loader.py | Loads model + tokenizer; applies quantization, LoRA, patches |
src/llamafactory/model/patcher.py | Model-specific compatibility patches |
src/llamafactory/data/template.py | Prompt templates; TEMPLATES dict maps model family → format |
src/llamafactory/data/mm_plugin.py | Multi-modal (image/video/audio) data handling |
src/llamafactory/data/processor/ | Per-stage data processors (supervised, pairwise, pretrain, etc.) |
src/llamafactory/train/sft/ | SFT trainer; other stages follow same structure |
src/llamafactory/chat/ | Inference engines: hf_engine, vllm_engine, sglang_engine, kt_engine |
src/llamafactory/extras/constants.py | Enums and constants used across the project |
Adding Support for a New Model
- Add a prompt template to
src/llamafactory/data/template.pyin theTEMPLATESdict - Add any necessary model patches in
src/llamafactory/model/patcher.py - Add multi-modal support in
src/llamafactory/data/mm_plugin.pyif needed
Distributed Training
Multi-GPU automatically uses torchrun. Additional backends:
- Ray: Optional Ray cluster support
- HyperParallel FSDP2:
src/llamafactory/train/hyper_parallel/ - Megatron-core:
src/llamafactory/train/mca/
Testing
tests/— v0 tests;tests_v1/— v1 tests- Most training tests require GPU hardware
- pytest markers:
@pytest.mark.slow,@pytest.mark.runs_on(['cuda']) - Always set
WANDB_DISABLED=truewhen running tests
Code Style
- Ruff for linting and formatting (line length 119, Google-style docstrings)
- Python 3.11+ syntax
- Double quotes for strings
- All new files must include Apache 2.0 license header (checked by
make license)
Trending
Quiet since August.about the whole repository
Who's talking about hiyouga/LLaMA-Factory
- AI Anytime“Anyone can Fine Tune LLMs using LLaMA Factory: End-to-End Tutorial”YouTube · Jan 7, 2024 · 40k views
- Simone Rizzo“Addestrare un LLM È PIÙ Facile di Quanto Pensi…”YouTube · Nov 13, 2025 · 23k views
- WorldofAI“EASIEST Method To Fine-Tune and Train Large Language Models! (Llama Factory)”YouTube · Nov 14, 2023 · 14k views
- The walking fish 步行魚“【LLaMA-Factory】開源語言模型微調專案 方便微調各種大型語言模型|內建WebUI 方便使用|內建多種訓練方式讓使用者選擇”YouTube · Dec 10, 2023 · 13k views
- AI Anytime“Fine Tune Qwen2 VL Model using Llama Factory”YouTube · Sep 7, 2024 · 12k views
The biggest 5 of 93 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 93
Talked about on GitHub, YouTube, Bluesky, the web and Hacker News (93 times).
On GitHub · 50
- Aug 5, 2025[model] add gpt oss — hiyouga/LlamaFactory15 reactions · 18 comments
- Nov 12, 2024Serious misalignment in LLaVA implementation — hiyouga/LlamaFactory12 reactions · 6 comments
- Oct 30, 2024PaddleMIX 快乐开源活动 (2024 Q4) — PaddlePaddle/PaddleMIX12 reactions · 64 comments
- Mar 7, 2024Third-party benchmark — jiaweizzhao/GaLoresays it tested it12 reactions · 15 comments
- Apr 6, 2025[model] add llama4 — hiyouga/LlamaFactory9 reactions
45 more on GitHub
- Mar 11, 2025[model] Support InternVL2.5-3 Series — hiyouga/LlamaFactory8 reactions · 45 comments
- Oct 7, 2025[feat] support megatron-LM training by mcore_adapter — hiyouga/LlamaFactory7 reactions · 9 comments
- Mar 30, 2025[model] Add Qwen2.5-Omni — hiyouga/LlamaFactory7 reactions · 87 comments
- Oct 13, 2025[Roadmap] Integration of KTransformers as a LoRA Fine-Tuning Backend for LLaMA-Factory — hiyouga/LlamaFactory6 reactions
- Mar 31, 2025vLLM Ascend Roadmap Q2 2025 — vllm-project/vllm-ascend6 reactions · 7 comments
- Aug 14, 2025[feature] add support for dft loss — hiyouga/LlamaFactory4 reactions · 4 comments
- Feb 26, 2025[model][WIP]Support InternVL2_5 series — hiyouga/LlamaFactory4 reactions · 1 comment
- Jun 18, 2024feat: support stream api — jupyterhub/jupyter-server-proxy4 reactions · 25 comments
- Mar 25, 2024[REQUEST]Support Galore — deepspeedai/DeepSpeed4 reactions
- Dec 6, 2023ChatGLM3-6b合并lora微调模型后,通过ChatGLM3-6b官方代码载入该合并后权重后对话内容和效果与没微调一样.. — hiyouga/LlamaFactory4 reactions · 21 comments
- Dec 18, 2025step0 梯度溢出,后续loss为0 — hiyouga/LlamaFactory3 reactions · 3 comments
- Dec 1, 2025[V1] Refactor ascend MoE kernel patch logic & Support Qwen3-MoE — hiyouga/LlamaFactory3 reactions · 8 comments
- Jul 3, 2025Add workflow for building multi-arch container images for Ascend NPU — hiyouga/LlamaFactory3 reactions
- Mar 17, 2025add Sequence Parallelism (reopened #6506) — hiyouga/LlamaFactory3 reactions · 16 comments
- Feb 7, 2025Incorrect Video Processing in Qwen2-VL Model Due to Incorrect call of Video/Image processor — hiyouga/LlamaFactory3 reactions · 3 comments
- Jan 17, 2025A new training approach:RAFT — hiyouga/LlamaFactory3 reactions · 1 comment
- Jul 20, 2024关于最新代码的模型切分问题 — hiyouga/LlamaFactory3 reactions · 4 comments
- May 14, 2024add kto — hiyouga/LlamaFactory3 reactions · 7 comments
- Jun 10, 2026[feat] support HyperParallel Context Parallel feature — hiyouga/LlamaFactory2 reactions · 1 comment
- Apr 16, 2026fix: handle mm_token_type_ids in collator and packing tests — hiyouga/LlamaFactory2 reactions · 2 comments
- Oct 24, 2025feat: add a toggle for disabling caching — hiyouga/LlamaFactory2 reactions · 1 comment
- Oct 22, 2025deps: exclude yanked dependencies — hiyouga/LlamaFactory2 reactions
- Apr 2, 2025sft阶段使用streaming dataset和do_predict时报错 — hiyouga/LlamaFactory2 reactions · 1 comment
- Jan 15, 2025[Feature] Convert `report_to` from `Checkbox` to `Dropdown` in webUI — hiyouga/LlamaFactory2 reactions · 1 comment
- Jan 2, 2025add Sequence Parallelism — hiyouga/LlamaFactory2 reactions · 15 comments
- Dec 12, 2024Probably a more reasonable method of `packing` — huggingface/trl2 reactions · 4 comments
- Oct 21, 2024请教下作者,目前新版代码关于cutoff_len是怎么处理的? — hiyouga/LlamaFactory2 reactions · 6 comments
- Sep 12, 2024[WIP] add florence2 — hiyouga/LlamaFactory2 reactions · 1 comment
- Aug 13, 2024PermissionError: [WinError 5] — unslothai/unsloth2 reactions · 3 comments
- Jun 18, 2024Function tool calling inference without llama-factory openai style api. — hiyouga/LlamaFactory2 reactions
- Mar 8, 2024有计划支持LoRAMoE吗? — hiyouga/LlamaFactory2 reactions · 15 comments
- Nov 17, 2023Change the default argument settings for PPO training — hiyouga/LlamaFactory2 reactions · 6 comments
- May 7, 2026[data] qwen3_vl: relax default thought_words to handle single-newline </think> — hiyouga/LlamaFactory1 reaction · 1 comment
- Dec 16, 2025Update the trl version range to be between 0.18 and 0.24. — hiyouga/LlamaFactory1 reaction · 3 comments
- Nov 13, 2025Support slow skip and device skip in Uts — hiyouga/LlamaFactory1 reaction · 4 comments
- May 27, 2025[update] add argument data_shared_file_system — the-seeds/LLaMA-Factory-Doc1 reaction
- Apr 6, 2025fix llama4 training — huggingface/transformers1 reaction · 1 comment
- Mar 27, 2025Fix pixtral plugin — hiyouga/LlamaFactory1 reaction · 1 comment
- Mar 12, 2025Support sglang as the inference engine — hiyouga/LlamaFactory1 reaction · 3 comments
- Feb 25, 2025[NPU] update cann base image to py3.10 and fix the type error of args INSTALL_DEEPSPEED of npu docker-compose.yaml — hiyouga/LlamaFactory1 reaction · 4 comments
- Feb 6, 2025bug fix: ensure 4d input in _scaled_dot_product_attention_math_mps — pytorch/pytorch1 reaction · 7 comments
- Oct 23, 2024使用了 LLaMA Factory 的项目:RAG-Retrieval 使用LLaMA-Factory作为生成方法做Reranker任务的微调框架。 — hiyouga/LlamaFactory1 reaction
- Jul 30, 2024overwrite training_step for CustomDPOTrainer to clear cuda cache every train step — hiyouga/LlamaFactory1 reaction · 2 comments
- Jun 25, 2024Add CI with pre-commit — instructkr/LogicKor1 reaction · 1 comment
- May 24, 2024Improve `transformers-cli env` reporting — huggingface/transformers1 reaction · 6 comments
On YouTube · 22
- Jan 7, 2024Anyone can Fine Tune LLMs using LLaMA Factory: End-to-End Tutorial — AI Anytime40k views · 65 comments
- Nov 13, 2025Addestrare un LLM È PIÙ Facile di Quanto Pensi… — Simone Rizzo23k views · 50 comments
- Nov 14, 2023EASIEST Method To Fine-Tune and Train Large Language Models! (Llama Factory) — WorldofAI14k views · 12 comments
- Dec 10, 2023【LLaMA-Factory】開源語言模型微調專案 方便微調各種大型語言模型|內建WebUI 方便使用|內建多種訓練方式讓使用者選擇 — The walking fish 步行魚13k views · 29 comments
- Sep 7, 2024Fine Tune Qwen2 VL Model using Llama Factory — AI Anytime12k views · 24 comments
17 more on YouTube
- Jul 17, 2024فاین تیون llama3 - آموزش ساخت مدل هوش مصنوعی فارسی (رایگان) — tarfandoon8.9k views · 51 comments
- Aug 18, 2026Can You Fine-Tune a 27B Model on a Laptop? (I Did the Math) — Cloud Codes8k views · 10 comments
- Apr 30, 2024Fine-Tune Llama 3 with LlaMA Factory in Free Colab — Fahd Mirza7.7k views · 22 comments
- May 4, 2024Fastest finetuning of Phi3 with LlaMa-Factory in 15 mins #generativeai #llama #finetuning #microsoft — Super Lazy Coder3.4k views · 36 comments
- Mar 30, 2024Aula 39 - Como fazer FINE - TUNING de LLMs Open Source usando LLAMA FACTORY — PROF. FABIO SANTOS1.5k views · 11 comments
- Mar 22, 2025学习使用 Llama factory 成为 AI 模型训练专家 — Kan Deng1.5k views · 3 comments
- Oct 13, 2024How to Get your LLMs to OBEY | Easiest Fine-tuning Interface for Total Control over your LLMs — Prompt Engineer 48942 views · 5 comments
- Apr 17, 2024Windows单机单卡基于LLaMA-Factory来微调训练finetune无审查AI大语言模型(NSFW) — 刘悦的技术博客(LiuYue's Tech Blog)928 views · 1 comment
- Jun 28, 2024Windows基于LLaMA-Factory来微调训练finetune千问2(Qwen2)大模型,让大模型掌握绅士内容 — 刘悦的技术博客(LiuYue's Tech Blog)745 views · 6 comments
- Apr 30, 2026Old PC + RTX 3090 = local AI powerhouse (no cloud needed) 🔧 #HardwareHacks #AITools #Budget — Matek-Builds484 views · 1 comment
- Aug 7, 2026LLaMA-Factory: Fine-Tune 100+ LLMs Easily with Web UI & Memory-Efficient Training — Solopreneurs hub438 views
- Jan 14, 2024hiyouga/LLaMA-Factory - Gource visualisation — Gourcer237 views · 3 comments
- May 24, 2025🚀 Fine-Tune 100+ AI Models with LLaMA-Factory — Hamdi Boukamcha171 views
- Jun 18, 2025Unlock No-Code LLM Fine-Tuning with LLaMA-Factory 🚀 — SkillServer161 views
- Aug 20, 2024GitHub - hiyouga/LLaMA-Factory: A WebUI for Efficient Fine-Tuning of 100+ LLMs (ACL 2024) — GitHub Daily Trend AI Podcast75 views
- Apr 20, 2026Run AI Locally: No Cloud, No Budget, No CS Degree! — Matek-Builds54 views
- Sep 4, 20252403.13372 - LlamaFactory: Unified Efficient Fine Tuning of 100+ Language Models — AI Paper Cast29 views
On Bluesky · 15
- Oct 31, 2025🔥 Hot Repo! 🔥 (100+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 61,344 (+149) 🗒 Python Unified Efficient Fine-Tuning of 100+ LLMs & VLMs… — @github-trending.bsky.social2 likes and reposts
- Sep 19, 2025Llama-Factory: Unified, Efficient Fine-Tuning for 100 Open LLMs | Discussion — @hackernewsbot.bsky.social2 likes and reposts
- May 25, 2025🚀 Skyrocketing! 🚀 (200+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 50,063 (+470) 🗒 Python Unified Efficient Fine-Tuning of 100+ LLMs &… — @github-trending.bsky.social2 likes and reposts
- Nov 1, 2024🔥 Hot Repo! 🔥 (100+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 33,404 (+101) 🗒 Python Unified Efficient Fine-Tuning of 100+ LLMs (ACL 2024) — @github-trending.bsky.social2 likes and reposts · 1 reply
- Nov 17, 2023🔥 Hot Repo! 🔥 (100+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 6,434 (+117) 🗒 Python Easy-to-use LLM fine-tuning framework (LLaMA, BLOOM,… — @github-trending.bsky.social2 likes and reposts
10 more on Bluesky
- Sep 24, 2025Llama-Factory: Единая, эффективная тонкая настройка для 100 открытых LLM #ai #llama #llm — @ai-ru.at.thenote.app1 likes and repost
- Sep 20, 2025Llama-Factory: Unified, Efficient Fine-Tuning for 100 Open LLMs #ai #llama #llm — @ai-news.at.thenote.app1 likes and repost
- May 25, 2025github.com/hiyouga/LLaM... — @blurbify.bsky.social1 likes and repost
- Apr 30, 2025📦 hiyouga / LLaMA-Factory ⭐ 47,948 (+77) 🗒 Python Unified Efficient Fine-Tuning of 100+ LLMs & VLMs (ACL 2024) — @github-trending.bsky.social1 likes and repost
- Jul 16, 2024📦 hiyouga / LLaMA-Factory ⭐ 26,369 (+96) 🗒 Python A WebUI for Efficient Fine-Tuning of 100+ LLMs (ACL 2024) — @github-trending.bsky.social1 likes and repost
- Jan 13, 2024📦 hiyouga / LLaMA-Factory ⭐ 9,528 (+53) 🗒 Python Easy-to-use LLM fine-tuning framework (LLaMA, BLOOM, Mistral, Baichuan, Qwen, ChatGLM) — @github-trending.bsky.social1 likes and repost
- Jul 20, 2024🚀 Skyrocketing! 🚀 (200+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 27,138 (+204) 🗒 Python A WebUI for Efficient Fine-Tuning of 100+ LLMs… — @github-trending.bsky.social0 likes and reposts · 1 reply
- Apr 24, 2024🎉 Celebrating! 🎉 (500+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 19,016 (+557) 🗒 Python Unify Efficient Fine-Tuning of 100+ LLMs — @github-trending.bsky.social0 likes and reposts · 1 reply
- Mar 28, 2024🔥 Hot Repo! 🔥 (100+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 14,811 (+134) 🗒 Python Unify Efficient Fine-tuning of 100+ LLMs — @github-trending.bsky.social0 likes and reposts · 1 reply
- Mar 25, 2024🔥 Hot Repo! 🔥 (100+ new stars) 📦 hiyouga / LLaMA-Factory ⭐ 13,989 (+125) 🗒 Python Unify Efficient Fine-tuning of 100+ LLMs — @github-trending.bsky.social0 likes and reposts · 1 reply
On the web · 4
- May 30, 2026LLaMA-Factory download — google.com
- Oct 14, 2025What is LLaMA Factory? LLM Fine-Tuning — google.com
- Sep 2, 2024LlaMA-Factory WebUI Beginner's Guide: Fine-Tuning LLMs — google.com
- Mar 20, 2024Unified Efficient Fine-Tuning of 100+ Language Models — google.com
On Hacker News · 2
- Sep 18, 2025Llama-Factory: Unified, Efficient Fine-Tuning for 100 Open LLMs132 points · 19 comments
- Jul 17, 2024Llama-Factory: A WebUI for Efficient Fine-Tuning of 100 LLMs2 points
Other versions1 project uses a version of this.
Word for word · 1
- hiyouga/LlamaFactory★ 76k100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository3 other files it gives its agents.
- .github/copilot-instructions.mdCopilot instructions
- llamafactory-sftSkill
- llamafactory-v1-docsSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

