agentleFS
hiyougahiyouga/LLaMA-Factory/.github/copilot-instructions.md

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
  1. Distinctive:

    Follow the Google Python Style Guide

    line 60
  2. Distinctive:

    Use ruff for linting and formatting

    line 61
  3. Distinctive:

    Use Google-style docstrings for documentation

    line 65
  4. Distinctive:

    Use 2 blank lines after imports

    line 71
  5. Distinctive:

    Before committing code, run:

    line 75
  6. Distinctive:

    Use pytest for testing

    line 89
  7. Very specific:

    Run tests with: make test (which runs WANDB_DISABLED=true pytest -vv --import-mode=importlib tests/ tests_v1/)

    line 91
  8. Distinctive:

    All source files must include the Apache 2.0 license header

    line 104
  9. Very specific:

    Check license headers with: make license

    line 105
  10. Distinctive:

    Create a development branch

    line 167
  11. Very specific:

    Run quality checks: make style && make quality

    line 170

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

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 directory
    • api/ - OpenAI-style API implementation
    • chat/ - Chat interface implementation
    • cli.py - Command-line interface
    • data/ - Data processing and dataset handling
    • eval/ - Model evaluation utilities
    • extras/ - Additional utilities and helpers
    • hparams/ - Hyperparameter definitions
    • model/ - Model loading, patching, and utilities
    • train/ - Training pipeline implementation
    • webui/ - Gradio-based web interface
  • src/train.py - Training entry script (delegates to llamafactory.train.tuner)
  • src/webui.py - Web UI entry script (delegates to llamafactory.webui.interface)
  • src/api.py - API server entry script (delegates to llamafactory.api.app)
  • tests/ - Test suite
  • examples/ - Example configurations for various training scenarios
  • data/ - Dataset definitions and examples

v1 Architecture (USE_V1=1)

  • src/llamafactory/v1/ - Version 1 package directory
    • trainers/ - Training implementations
    • core/ - Core training utilities
    • accelerator/ - Acceleration and distributed training
    • plugins/ - Pluggable components (model, data, sampler, trainer)
    • config/ - Configuration management
    • utils/ - 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 suite

Or use the combined command:

make commit     # Run pre-commit hooks

Testing

  • Use pytest for testing
  • Tests are located in tests/ and tests_v1/ directories
  • Run tests with: make test (which runs WANDB_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 test to validate file-level functionality.

Building

Build the package with:

pip3 install build && python3 -m build

License

  • 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 webui or python src/webui.py
  • API Server: llamafactory-cli api or python 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

  1. Fork the repository
  2. Create a development branch
  3. Set up development environment with pip install -e ".[dev]"
  4. Make changes following the style guide
  5. Run quality checks: make style && make quality
  6. Run tests: make test
  7. Submit a pull request

Common Commands

  • make style - Format code
  • make quality - Run linters
  • make test - Run tests
  • make commit - Install and run pre-commit hooks
  • make license - Check license headers

Download now (ZIP)

Trending

Quiet since August.about the whole repository

Dec 2025: 3 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 3 mentionsMay 2026: 2 mentionsJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 2 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the hiyouga/LLaMA-Factory repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about hiyouga/LLaMA-Factory

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

45 more on GitHub

On YouTube · 22

17 more on YouTube

On Bluesky · 15

10 more on Bluesky

On the web · 4

  • Other versions1 project uses a version of this.

    Word for word · 1

    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.

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.