

Also from Kynth Studios


Also from Kynth Studios


Also from Kynth Studios
1# copilot-instructions.md Guide for Hugging Face Transformers23This copilot-instructions.md file provides guidance for code agents working with this codebase.45## Core Project Structure67- `/src/transformers`: This contains the core source code for the library8 - `/models`: Code for individual models. Models inherit from base classes in the root `/src/transformers` directory.9- `/tests`: This contains the core test classes for the library. These are usually inherited rather than directly run.10 - `/models`: Tests for individual models. Model tests inherit from common tests in the root `/tests` directory.11- `/docs`: This contains the documentation for the library, including guides, tutorials, and API references.1213## Coding Conventions for Hugging Face Transformers1415- PRs should be as brief as possible. Bugfix PRs in particular can often be only one or two lines long, and do not need large comments, docstrings or new functions in this case. Aim to minimize the size of the diff.16- When writing tests, they should be added to an existing file. The only exception is for PRs to add a new model, when a new test directory should be created for that model.17- Code style is enforced in the CI. You can install the style tools with `pip install -e .[quality]`. You can then run `make fixup` to apply style and consistency fixes to your code.1819## Copying and inheritance2021Many models in the codebase have similar code, but it is not shared by inheritance because we want each model file to be self-contained.22We use two mechanisms to keep this code in sync:2324- "Copied from" syntax. Functions or entire classes can have a comment at the top like this: `# Copied from transformers.models.llama.modeling_llama.rotate_half` or `# Copied from transformers.models.t5.modeling_t5.T5LayerNorm with T5->MT5`25 These comments are actively checked by the style tools, and copies will automatically be updated when the base code is updated. If you need to update a copied function, you should26 either update the base function and use `make fixup` to propagate the change to all copies, or simply remove the `# Copied from` comment if that is inappropriate.27- "Modular" files. These files briefly define models by composing them using inheritance from other models. They are not meant to be used directly. Instead, the style tools28 automatically generate a complete modeling file, like `modeling_bert.py`, from the modular file like `modular_bert.py`. If a model has a modular file, the modeling file29 should never be edited directly! Instead, changes should be made in the modular file, and then you should run `make fixup` to update the modeling file automatically.3031When adding new models, you should prefer `modular` style and inherit as many classes as possible from existing models.3233## Testing3435After making changes, you should usually run `make fixup` to ensure any copies and modular files are updated, and then test all affected models. This includes both36the model you made the changes in and any other models that were updated by `make fixup`. Tests can be run with `pytest tests/models/[name]/test_modeling_[name].py`37If your changes affect code in other classes like tokenizers or processors, you should run those tests instead, like `test_processing_[name].py` or `test_tokenization_[name].py`.3839In order to run tests, you may need to install dependencies. You can do this with `pip install -e .[testing]`. You will probably also need to `pip install torch accelerate` if your environment does not already have them.40
One 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 |
|---|---|---|---|---|---|
| huggingface/transformers.ai/AGENTS.md · 163k | AGENTS.md | setuptestlint-formatgit+1 | 82/100 | 14 days ago |
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 | 14 days ago | |
| hiyouga/LlamaFactory.github/copilot-instructions.md · 74k | Copilot instructions | setupbuildtestlint-format+5 | 97/100 | 13 days ago | |
| darkmatter/nixmac.github/copilot-instructions.md · 25 | Copilot instructions | setupbuildtestlint-format+8 | 96/100 | 14 days ago | |
| iloveitaly/llm-ide-rules.github/copilot-instructions.md · 13 | Copilot instructions | teststyledo-notagent-behaviour+1 | 92/100 | 14 days ago | |
| photoprism/photoprism.github/copilot-instructions.md · 40k | Copilot instructions | buildtestlint-formatstyle+5 | 90/100 | 13 days ago | |
| gasbasd/mtg-utils.github/copilot-instructions.md · 0 | Copilot instructions | setupbuildtestlint-format+3 | 89/100 | 8 days ago | |
| bytedance/deer-flow.github/copilot-instructions.md · 80k | Copilot instructions | setupbuildtestlint-format+6 | 89/100 | 14 days ago | |
| iloveitaly/llm-ide-rules.github/instructions/python.instructions.md · 13 | Copilot instructions | setupstyletypesdo-not | 88/100 | 14 days ago |
A badge carrying the measured quality of the strongest agent config file in this repository, out of 100. It reads from this index every time somebody loads your page, so it changes when the measurement changes and there is nothing to keep up to date. Free, no account, and the value is not something you or we can set by hand.
[](https://rulestack.kynth.studio/configs/huggingface-transformers-github-copilot-instructions)Would rather not hotlink us? Every badge is also served in shields.io’s endpoint schema, so shields renders the image and your readers never talk to our domain:
Published by Toolproof, the masthead over this index and eight others. The method behind the number is at toolproof.kynth.studio/methodology, and the whole thing is readable as JSON with no key at /api.