agentleFS
Hugging FaceKnown publisherhuggingface/new-model-addition-cwm/.github/copilot-instructions.md

new-model-addition-cwm

Copilot instructions0 starsChanged 15 months agoApache-2.0View on GitHub

This copilot-instructions.md file provides guidance for code agents working with this codebase. Many models in the codebase have similar code, but it is not shared by inheritance because we want each model file to be self-contained. We use two mechanisms to keep this code in sync: - "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 These comments are actively checked by…

  • Installs packages

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 1

    1. huggingface/transformers★ 169k100% 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,336 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 repository2 other files it gives its agents.

The file

We split this copilot-instructions.md into the rules it gives an agent

4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    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:

    When writing tests, they should be added to an existing file.

    line 16
  2. Very specific:

    When adding new models, you should prefer modular style and inherit as many classes as possible from existing models.

    line 31
  3. Very specific:

    After making changes, you should usually run make fixup to ensure any copies and modular files are updated, and then test all affected …

    line 35
  4. Very specific:

    If your changes affect code in other classes like tokenizers or processors, you should run those tests instead, like …

    line 37

≈ “Common” is an estimate: at least 1 in 5 of the 3,779 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

copilot-instructions.md Guide for Hugging Face Transformers

This copilot-instructions.md file provides guidance for code agents working with this codebase.

Core Project Structure

  • /src/transformers: This contains the core source code for the library
    • /models: Code for individual models. Models inherit from base classes in the root /src/transformers directory.
  • /tests: This contains the core test classes for the library. These are usually inherited rather than directly run.
    • /models: Tests for individual models. Model tests inherit from common tests in the root /tests directory.
  • /docs: This contains the documentation for the library, including guides, tutorials, and API references.

Coding Conventions for Hugging Face Transformers

  • 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.
  • 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.
  • 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.

Copying and inheritance

Many models in the codebase have similar code, but it is not shared by inheritance because we want each model file to be self-contained. We use two mechanisms to keep this code in sync:

  • "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 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 should 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.
  • "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 tools 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 file 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.

When adding new models, you should prefer modular style and inherit as many classes as possible from existing models.

Testing

After 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 both the 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 If 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.

In 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.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.