huggingface/transformers
Models
src/transformers/models/ is the largest directory in the repository: 462 architecture-specific subdirectories as of this generation. This section organizes them by primary modality and lists representative entries; the model-doc reference at docs/source/en/model_doc/ covers each architecture in detail.
What every model directory contains
src/transformers/models/<arch>/
├── __init__.py # lazy exports
├── configuration_<arch>.py # <Arch>Config
├── modeling_<arch>.py # <Arch>Model, <Arch>For<Task>, <Arch>PreTrainedModel
├── modular_<arch>.py # (optional) modular shard, expanded into the above
├── tokenization_<arch>.py # (optional) slow tokenizer
├── tokenization_<arch>_fast.py # (optional) fast tokenizer
├── image_processing_<arch>.py # (optional) image preprocessor
├── feature_extraction_<arch>.py # (optional) audio preprocessor
├── video_processing_<arch>.py # (optional) video preprocessor
├── processing_<arch>.py # (optional) multimodal processor
└── convert_<arch>_*.py # (optional) one-off weight conversion scripts230 directories ship a modular_<arch>.py shard that is expanded by make fix-repo. The remaining 232 use hand-written modeling_<arch>.py files, often with # Copied from ... markers to keep shared code in sync.
Layout by modality
graph TD
Root[src/transformers/models/] --> Text[Text models]
Root --> Vision[Vision models]
Root --> Audio[Audio / speech models]
Root --> Multimodal[Multimodal / VLM]
Root --> TimeSeries[Time-series & forecasting]
Root --> Specialty[Specialty: depth, OCR, retrieval, …]
Root --> Deprecated[deprecated/]The library does not group models into modality folders on disk — every model is a sibling under src/transformers/models/. The pages below carve up the same flat space conceptually.
Modality pages
- Text models — encoder, decoder, encoder-decoder LMs and discriminative text models.
- Vision models — image classification, detection, segmentation, depth, keypoints, OCR backbones.
- Audio models — ASR, audio classification, TTS, speech generation.
- Multimodal models — VLMs, image-text-to-text, vision encoders + LM, any-to-any, document AI.
Deprecated bin
src/transformers/models/deprecated/ houses architectures that the team intends to remove. They are still importable but emit deprecation warnings on use; over the lifetime of the V5 series several have been removed entirely (TF/Flax-only models for instance).
The deprecate_models.py helper in utils/ automates the move; models_to_deprecate.py records the policy.
Cross-architecture wrappers
A few entries are not "models" in the usual sense; they wrap others:
auto/— the auto-class factories (see Auto classes).encoder_decoder/,vision_encoder_decoder/,speech_encoder_decoder/,vision_text_dual_encoder/— generic wrappers that compose any encoder with any decoder/text model.timm_backbone/,timm_wrapper/— bridges to thetimmlibrary sotimmbackbones can be used inside detection/segmentation models.rag/— retrieval-augmented generation orchestration.
Reference
For a per-model deep-dive, the user-facing docs at docs/source/en/model_doc/<arch>.md (and the matching auto-generated pages on huggingface.co) are the canonical place. This wiki section provides a curated bird's-eye view that complements those references.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.