transformers copilot-instructions.md

Repository instructions for Hugging Face Transformers, a software library for working with machine-learning models that process text and other data.

In plain words
What is it for?
Planning edits to model implementations, adding or updating tests, and working with the library's documentation and source layout.
Why use it?
They explain where model code, tests, and documentation belong and help keep changes aligned with the project's coding and testing practices.

Instructions file for GitHub Copilot

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/huggingface/transformers/copilot-instructions
Clone the repo
git clone --depth 1 https://github.com/huggingface/transformers

Made for: GitHub Copilot.

Per session 773 This file is loaded in full into every session.
When invoked 773 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00773 $0.00773
Opus 5 $0.00387 $0.00387
Sonnet 5 $0.00155 $0.00155
Haiku 4.5 $0.00077 $0.00077

Measured 2d ago against content hash 51d12faef435, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

transformers copilot-instructions.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.github/copilot-instructions.md · 40 lines

How it starts

The opening of the file, as written. The whole thing — 40 lines — stays where its author put it; the contents beside it link to each section on GitHub.

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.

Read the full file on GitHub · 40 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 40 lines · 773 tokens per session scan A 51d12faef435

Subscribe to this mod's changes

transformers copilot-instructions.md is an instructions file published in the GitHub repository huggingface/transformers (164,637 stars, last pushed 2d ago), licensed Apache-2.0. It adds 773 tokens to every session, about $0.0039 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.