Open-Source Wikis

/

Transformers

/

By the numbers

huggingface/transformers

By the numbers

Data collected on 2026-04-30 from the main branch at commit a752ba7af8.

Size

The repository ships ~149K lines of library Python code under src/transformers/, plus ~412K lines of test code under tests/. The 462 architecture-specific directories under src/transformers/models/ account for the majority of both.

xychart-beta horizontal
    title "Lines of code by area"
    x-axis ["src/transformers (lib)", "tests/", "examples/", "docs/", "utils/", "benchmark*/"]
    y-axis "Lines of code (×1000)" 0 --> 450
    bar [149, 412, 60, 110, 35, 12]

(Values are approximate; computed by wc -l over *.py and *.md files in each tree.)

Area Files Notes
Model directories 462 One per architecture under src/transformers/models/.
modeling_*.py 445 Standalone PyTorch modules.
modular_*.py 230 Modular shards expanded by make fix-repo.
configuration_*.py 444 One per architecture (some shared).
tokenization_*.py 99 Includes both slow and fast variants.
image_processing_*.py 194 Vision and multimodal preprocessors.
processing_*.py 131 Multimodal processor classes.
Pipeline tasks 28 Files under src/transformers/pipelines/.
Quantizers 23 Files matching quantizers/quantizer_*.py.
Integrations 40 Files under src/transformers/integrations/.

Top-level files by size (library code)

File Lines Purpose
src/transformers/modeling_utils.py 5,042 PreTrainedModel, weight init, mixins, attention dispatch
src/transformers/trainer.py 4,418 Full training loop
src/transformers/generation/utils.py 3,887 generate(), decoding strategies
src/transformers/tokenization_utils_base.py 3,580 Tokenizer base class
src/transformers/training_args.py 2,868 TrainingArguments dataclass
src/transformers/cache_utils.py 1,574 KV cache hierarchy
src/transformers/configuration_utils.py 1,362 PretrainedConfig base class
src/transformers/pipelines/base.py 1,370 Pipeline base class

Repository tooling files (largest)

File Lines Purpose
utils/modular_model_converter.py ≈3,400 Expands modular_*.py into modeling_*.py
utils/check_repo.py ≈1,900 Repo-consistency rules
utils/check_docstrings.py ≈2,500 Docstring validation
utils/create_dummy_models.py ≈2,400 Tiny model fixtures for fast tests
utils/tests_fetcher.py ≈1,500 Picks tests covering a diff

Activity

Commits per month over the last ~20 months (truncated; full list in git log):

xychart-beta horizontal
    title "Commits per month (recent)"
    x-axis ["2024-09", "2024-10", "2024-11", "2024-12", "2025-01", "2025-02", "2025-03", "2025-04", "2025-05", "2025-06", "2025-07", "2025-08", "2025-09", "2025-10", "2025-11", "2025-12", "2026-01", "2026-02", "2026-03", "2026-04"]
    y-axis "Commits" 0 --> 450
    bar [241, 352, 173, 181, 259, 229, 289, 398, 314, 326, 389, 394, 374, 369, 285, 283, 284, 303, 330, 266]

Total commits across the project's lifetime: 22,758 (since the initial commit on 2018-10-29).

Bot-attributed commits

Of all 22,758 commits in the history, 230 commits carry a Co-authored-by trailer mentioning a bot account such as dependabot[bot], github-actions[bot], factory-droid[bot], or copilot[bot]. That is roughly 1.0% of the history.

This number is a strict lower bound on AI-assisted work: inline tools such as Copilot or Cursor leave no trace in git log, and many AI-assisted PRs land without a Co-authored-by trailer. The current contributing guidelines explicitly discourage agent-only PRs (see CONTRIBUTING.md).

Test surface

Test grouping Files Notes
tests/models/ one dir per architecture Per-model unit tests
tests/test_modeling_common.py 291,137 LOC Shared ModelTesterMixin reused by every model
tests/test_processing_common.py 95,360 LOC Multimodal processor mixin
tests/test_pipeline_mixin.py 37,715 LOC Per-task pipeline test mixin
tests/test_tokenization_common.py 132,908 LOC Tokenizer mixin
tests/quantization/ 25 subdirs One per quantizer
tests/pipelines/ per-task tests Companion to per-model tests
tests/generation/, tests/trainer/, tests/tensor_parallel/, tests/sagemaker/ shared infra

Complexity

The library has a long-tail distribution of file sizes. A handful of central files dominate (see "Top-level files by size" above); most model files are 200-2,000 lines. The ruff config in pyproject.toml allows McCabe complexity up to 75 — the team has historically prioritized readability over short functions.

Dependencies

Mandatory runtime dependencies are declared in setup.py and the consolidated table at src/transformers/dependency_versions_table.py. Highlights:

Dependency Pinned version Use
torch 2.4+ Modeling backend
huggingface-hub 1.5+ to <2.0 Hub I/O
tokenizers from huggingface-hub Fast tokenizers
safetensors runtime Default checkpoint format
accelerate 1.1+ Distributed/mixed precision dispatch
kernels 0.12 Custom CUDA kernels via kernels-community
numpy 1.17+ Tensors and CPU paths
Pillow 10.0.1 to 15.0 Image I/O
tqdm 4.27+ Progress bars
regex runtime Tokenizer fast paths
requests / httpx runtime HTTP
pyyaml runtime Configs
packaging runtime Version checks
filelock runtime Cache concurrency

Optional extras ([torch], [dev], [quality], [testing], [audio], [vision], [integrations], [deepspeed], [sklearn], …) pull in roughly 200 additional packages spanning DeepSpeed, FSDP wrappers, peft, datasets, evaluate, sentencepiece, librosa, av, kenlm, scipy, Pillow, vlm libraries, and quantization backends (bitsandbytes, auto-gptq, autoawq, optimum-quanto, etc.).

See Dependencies for the full breakdown.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

By the numbers – Transformers wiki | Factory