Copilot instructions
.github/copilot-instructions.mdCopilot instructions
Quality
97/100
Scores the file, not the repository.Length
835 words
24 headings · 4 code blocksRepository
74k
— · pushed 2 days agoLast changed
2 days ago
First indexed 2 days ago.1# GitHub Copilot Instructions for LLaMA Factory23## Project Overview45LLaMA Factory is an efficient fine-tuning framework for 100+ large language models (LLMs). It provides:6- Support for various models: LLaMA, LLaVA, Mistral, Qwen, DeepSeek, Yi, Gemma, ChatGLM, Phi, etc.7- Multiple training methods: pre-training, supervised fine-tuning, reward modeling, PPO, DPO, KTO, ORPO8- Scalable resources: 16-bit full-tuning, freeze-tuning, LoRA and QLoRA variants9- Advanced algorithms: GaLore, BAdam, APOLLO, Adam-mini, Muon, OFT, DoRA, etc.10- Web UI (LLaMA Board) and CLI interfaces1112### Architecture Versions1314LLaMA Factory has two parallel architectures that can be switched via the `USE_V1` environment variable:1516**v0 (default)** - File hierarchy:17- `api`, `webui` → `chat`, `eval`, `train` → `data`, `model` → `hparams` → `extras`1819**v1** - File hierarchy:20- `trainers` → `core` → `accelerator`, `plugins`, `config` → `utils`2122Set `USE_V1=1` to enable v1 architecture.2324## Code Structure2526### v0 Architecture (Default)2728- `src/llamafactory/` - Main package directory29 - `api/` - OpenAI-style API implementation30 - `chat/` - Chat interface implementation31 - `cli.py` - Command-line interface32 - `data/` - Data processing and dataset handling33 - `eval/` - Model evaluation utilities34 - `extras/` - Additional utilities and helpers35 - `hparams/` - Hyperparameter definitions36 - `model/` - Model loading, patching, and utilities37 - `train/` - Training pipeline implementation38 - `webui/` - Gradio-based web interface39- `src/train.py` - Training entry script (delegates to `llamafactory.train.tuner`)40- `src/webui.py` - Web UI entry script (delegates to `llamafactory.webui.interface`)41- `src/api.py` - API server entry script (delegates to `llamafactory.api.app`)42- `tests/` - Test suite43- `examples/` - Example configurations for various training scenarios44- `data/` - Dataset definitions and examples4546### v1 Architecture (USE_V1=1)4748- `src/llamafactory/v1/` - Version 1 package directory49 - `trainers/` - Training implementations50 - `core/` - Core training utilities51 - `accelerator/` - Acceleration and distributed training52 - `plugins/` - Pluggable components (model, data, sampler, trainer)53 - `config/` - Configuration management54 - `utils/` - Utility functions5556## Development Practices5758### Code Style5960- Follow the [Google Python Style Guide](https://google.github.io/styleguide/pyguide.html)61- Use ruff for linting and formatting62- Line length: 119 characters63- Indentation: 4 spaces64- Quote style: double quotes65- Use Google-style docstrings for documentation6667### Import Organization6869- Known first-party: `llamafactory`70- Known third-party: `accelerate`, `datasets`, `gradio`, `numpy`, `peft`, `torch`, `transformers`, `trl`71- Use 2 blank lines after imports7273### Quality Checks7475Before committing code, run:76```bash77make style # Auto-fix style issues78make quality # Check code quality79make test # Run test suite80```8182Or use the combined command:83```bash84make commit # Run pre-commit hooks85```8687### Testing8889- Use pytest for testing90- Tests are located in `tests/` and `tests_v1/` directories91- Run tests with: `make test` (which runs `WANDB_DISABLED=true pytest -vv --import-mode=importlib tests/ tests_v1/`)92- Disable wandb during testing to avoid external dependencies93- **Note**: Training configurations require GPU machines, so training is typically not tested end-to-end. Use `make test` to validate file-level functionality.9495### Building9697Build the package with:98```bash99pip3 install build && python3 -m build100```101102### License103104- All source files must include the Apache 2.0 license header105- Check license headers with: `make license`106107## Common Patterns108109### Configuration Files110111- Training configurations are typically YAML or JSON files in `examples/` directory112- Hyperparameters are defined using dataclasses in `src/llamafactory/hparams/`113114### Model Support115116- New model support is added through model patches in `src/llamafactory/model/`117- Visual models use the visual utilities in `src/llamafactory/model/model_utils/visual.py`118- Quantization support is in `src/llamafactory/model/model_utils/quantization.py`119120### Data Processing121122- Dataset definitions are in `data/dataset_info.json`123- Data templates and processors are in `src/llamafactory/data/`124125### Training126127- Training pipelines are in `src/llamafactory/train/`128- Support for different training methods: SFT, DPO, PPO, RM, PT, KTO, ORPO129130## Key Dependencies131132- Python >= 3.9.0133- PyTorch and transformers for model handling134- datasets for data processing135- peft for parameter-efficient fine-tuning136- accelerate for distributed training137- gradio for web UI138- trl for reinforcement learning139- Optional: vllm/sglang for inference, flash-attention-2, unsloth, liger-kernel140141## Entry Points142143- **CLI Training**: `llamafactory-cli train --config examples/train_lora/llama3_lora_sft.yaml`144- **Web UI**: `llamafactory-cli webui` or `python src/webui.py`145- **API Server**: `llamafactory-cli api` or `python src/api.py`146- **Chat Interface**: `llamafactory-cli chat --model_name_or_path MODEL_PATH`147148## Environment Setup149150For development:151```bash152pip install -e ".[dev]"153```154155## Important Notes156157- The project supports multiple backends: default PyTorch, vLLM, SGLang158- Megatron-core training is supported via mcore_adapter159- SwanLab and W&B are supported for experiment tracking160- Docker support is available with pre-built images161- Day-0/Day-1 support for latest cutting-edge models162- Multi-modal support for vision and audio understanding tasks163164## Contribution Guidelines1651661. Fork the repository1672. Create a development branch1683. Set up development environment with `pip install -e ".[dev]"`1694. Make changes following the style guide1705. Run quality checks: `make style && make quality`1716. Run tests: `make test`1727. Submit a pull request173174## Common Commands175176- `make style` - Format code177- `make quality` - Run linters178- `make test` - Run tests179- `make commit` - Install and run pre-commit hooks180- `make license` - Check license headers181
Also in hiyouga/LlamaFactory
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiyouga/LlamaFactory.ai/CLAUDE.md · 74k | CLAUDE.md | buildtestlint-formatstyle+2 | 92/100 | 2 days ago |
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| pytorch/pytorch.github/copilot-instructions.md · 102k | Copilot instructions | setupbuildteststyle+5 | 100/100 | 3 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 24 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 3 days ago | |
| iloveitaly/llm-ide-rules.github/copilot-instructions.md · 13 | Copilot instructions | teststyledo-notagent-behaviour+1 | 92/100 | 3 days ago | |
| photoprism/photoprism.github/copilot-instructions.md · 40k | Copilot instructions | buildtestlint-formatstyle+5 | 90/100 | 2 days ago | |
| bytedance/deer-flow.github/copilot-instructions.md · 79k | Copilot instructions | setupbuildtestlint-format+6 | 89/100 | 3 days ago | |
| iloveitaly/llm-ide-rules.github/instructions/python.instructions.md · 13 | Copilot instructions | setupstyletypesdo-not | 88/100 | 3 days ago | |
| Significant-Gravitas/AutoGPT.github/copilot-instructions.md · 186k | Copilot instructions | setupbuildtestlint-format+10 | 88/100 | 3 days ago | |
| u9401066/nsforge-mcp.github/copilot-instructions.md · 4 | Copilot instructions | setuptestlint-formatgit+2 | 85/100 | 3 days ago |
