LLaMA-Factory
Copilot instructions76k starsChanged 48 days agoApache-2.0View on GitHub
LLaMA Factory is an efficient fine-tuning framework for 100+ large language models (LLMs). It provides: - Support for various models: LLaMA, LLaVA, Mistral, Qwen, DeepSeek, Yi, Gemma, ChatGLM, Phi, etc. - Multiple training methods: pre-training, supervised fine-tuning, reward modeling, PPO, DPO, KTO, ORPO - Scalable resources: 16-bit full-tuning, freeze-tuning, LoRA and QLoRA variants - Advanced algorithms: GaLore, BAdam, APOLLO, Adam-mini, Muon, OFT, DoRA, etc. - Web UI (LLaMA Board) and CLI interfaces LLaMA Factory has two parallel architectures that can…
- Installs packages
We split this copilot-instructions.md into the rules it gives an agent
11 rules. About 0 are common, 8 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈8
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 60
Follow the Google Python Style Guide
- Distinctive: line 61
Use ruff for linting and formatting
- Distinctive: line 65
Use Google-style docstrings for documentation
- Distinctive: line 71
Use 2 blank lines after imports
- Distinctive: line 75
Before committing code, run:
- Distinctive: line 89
Use pytest for testing
- Very specific: line 91
Run tests with: make test (which runs WANDB_DISABLED=true pytest -vv --import-mode=importlib tests/ tests_v1/)
- Distinctive: line 104
All source files must include the Apache 2.0 license header
- Very specific: line 105
Check license headers with: make license
- Distinctive: line 167
Create a development branch
- Very specific: line 170
Run quality checks: make style && make quality
≈ “Common” is an estimate: at least 1 in 5 of the 3,669 Copilot instructions 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
GitHub Copilot Instructions for LLaMA Factory
Project Overview
LLaMA Factory is an efficient fine-tuning framework for 100+ large language models (LLMs). It provides:
- Support for various models: LLaMA, LLaVA, Mistral, Qwen, DeepSeek, Yi, Gemma, ChatGLM, Phi, etc.
- Multiple training methods: pre-training, supervised fine-tuning, reward modeling, PPO, DPO, KTO, ORPO
- Scalable resources: 16-bit full-tuning, freeze-tuning, LoRA and QLoRA variants
- Advanced algorithms: GaLore, BAdam, APOLLO, Adam-mini, Muon, OFT, DoRA, etc.
- Web UI (LLaMA Board) and CLI interfaces
Architecture Versions
LLaMA Factory has two parallel architectures that can be switched via the USE_V1 environment variable:
v0 (default) - File hierarchy:
api,webui→chat,eval,train→data,model→hparams→extras
v1 - File hierarchy:
trainers→core→accelerator,plugins,config→utils
Set USE_V1=1 to enable v1 architecture.
Code Structure
v0 Architecture (Default)
src/llamafactory/- Main package directoryapi/- OpenAI-style API implementationchat/- Chat interface implementationcli.py- Command-line interfacedata/- Data processing and dataset handlingeval/- Model evaluation utilitiesextras/- Additional utilities and helpershparams/- Hyperparameter definitionsmodel/- Model loading, patching, and utilitiestrain/- Training pipeline implementationwebui/- Gradio-based web interface
src/train.py- Training entry script (delegates tollamafactory.train.tuner)src/webui.py- Web UI entry script (delegates tollamafactory.webui.interface)src/api.py- API server entry script (delegates tollamafactory.api.app)tests/- Test suiteexamples/- Example configurations for various training scenariosdata/- Dataset definitions and examples
v1 Architecture (USE_V1=1)
src/llamafactory/v1/- Version 1 package directorytrainers/- Training implementationscore/- Core training utilitiesaccelerator/- Acceleration and distributed trainingplugins/- Pluggable components (model, data, sampler, trainer)config/- Configuration managementutils/- Utility functions
Development Practices
Code Style
- Follow the Google Python Style Guide
- Use ruff for linting and formatting
- Line length: 119 characters
- Indentation: 4 spaces
- Quote style: double quotes
- Use Google-style docstrings for documentation
Import Organization
- Known first-party:
llamafactory - Known third-party:
accelerate,datasets,gradio,numpy,peft,torch,transformers,trl - Use 2 blank lines after imports
Quality Checks
Before committing code, run:
make style # Auto-fix style issues
make quality # Check code quality
make test # Run test suiteOr use the combined command:
make commit # Run pre-commit hooksTesting
- Use pytest for testing
- Tests are located in
tests/andtests_v1/directories - Run tests with:
make test(which runsWANDB_DISABLED=true pytest -vv --import-mode=importlib tests/ tests_v1/) - Disable wandb during testing to avoid external dependencies
- Note: Training configurations require GPU machines, so training is typically not tested end-to-end. Use
make testto validate file-level functionality.
Building
Build the package with:
pip3 install build && python3 -m buildLicense
- All source files must include the Apache 2.0 license header
- Check license headers with:
make license
Common Patterns
Configuration Files
- Training configurations are typically YAML or JSON files in
examples/directory - Hyperparameters are defined using dataclasses in
src/llamafactory/hparams/
Model Support
- New model support is added through model patches in
src/llamafactory/model/ - Visual models use the visual utilities in
src/llamafactory/model/model_utils/visual.py - Quantization support is in
src/llamafactory/model/model_utils/quantization.py
Data Processing
- Dataset definitions are in
data/dataset_info.json - Data templates and processors are in
src/llamafactory/data/
Training
- Training pipelines are in
src/llamafactory/train/ - Support for different training methods: SFT, DPO, PPO, RM, PT, KTO, ORPO
Key Dependencies
- Python >= 3.9.0
- PyTorch and transformers for model handling
- datasets for data processing
- peft for parameter-efficient fine-tuning
- accelerate for distributed training
- gradio for web UI
- trl for reinforcement learning
- Optional: vllm/sglang for inference, flash-attention-2, unsloth, liger-kernel
Entry Points
- CLI Training:
llamafactory-cli train --config examples/train_lora/llama3_lora_sft.yaml - Web UI:
llamafactory-cli webuiorpython src/webui.py - API Server:
llamafactory-cli apiorpython src/api.py - Chat Interface:
llamafactory-cli chat --model_name_or_path MODEL_PATH
Environment Setup
For development:
pip install -e ".[dev]"Important Notes
- The project supports multiple backends: default PyTorch, vLLM, SGLang
- Megatron-core training is supported via mcore_adapter
- SwanLab and W&B are supported for experiment tracking
- Docker support is available with pre-built images
- Day-0/Day-1 support for latest cutting-edge models
- Multi-modal support for vision and audio understanding tasks
Contribution Guidelines
- Fork the repository
- Create a development branch
- Set up development environment with
pip install -e ".[dev]" - Make changes following the style guide
- Run quality checks:
make style && make quality - Run tests:
make test - Submit a pull request
Common Commands
make style- Format codemake quality- Run lintersmake test- Run testsmake commit- Install and run pre-commit hooksmake license- Check license headers
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.
Where files are headingNew Copilot instructions files have more rules about branches and pull requests, and fewer about code style.
Of the Copilot instructions files we read, the 2,297 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository3 other files it gives its agents.
- .ai/CLAUDE.mdCLAUDE.md
- 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.

