Philosophy
Transformers is a PyTorch-first library. Hugging Face aims for models that are faithful to their papers, easy to use, and easy to hack.
Adapted for this playbook from the π€ Transformers documentation by Hugging Face. Official page: https://huggingface.co/docs/transformers/philosophy. Images Β© Hugging Face (
documentation-images) unless noted. This is not a substitute for the upstream docs β verify against the current version.Covers Hugging Face pages: philosophy
Who it is forβ
- Researchers and educators extending architectures
- Practitioners fine-tuning, evaluating or serving models
- Engineers who want a pretrained model with a predictable API
Three core classesβ
| Class | Role |
|---|---|
| Configuration | Hyperparameters (layers, hidden size, β¦) |
| Model | torch.nn.Module wrapped by PreTrainedModel |
| Preprocessor | Tokenizer, image/video processor, feature extractor, or multimodal processor |
All support:
from_pretrained()β download/cache/load from Hub or disksave_pretrained()β write a local folderpush_to_hub()β share to the Hub
High-level APIsβ
pipelineβ task inference with sensible defaultsTrainerβ train / fine-tune PyTorch models with mixed precision, compile, FlashAttention, distributed helpers
Core tenets (Hugging Face)β
From the official philosophy (also expanded in the Transformers tenets space):
- Source of truth β faithful to official results and intended behaviour
- One model, one file β core logic readable top-to-bottom
- Code is the product β optimise for reading and diffing
- Standardise, donβt abstract β model-specific behaviour stays in the model
- DRY* (repeat when it helps users) β end-user modelling files stay self-contained; infra is factored out
- Minimal user API β few code paths, predictable kwargs
- Backwards compatibility β Hub artefacts keep working
- Consistent public surface β naming, outputs, diagnostics aligned
Modular Transformersβ
Contributors write a small modular_*.py shard; the library expands it into the visible modeling_*.py users read. That preserves βone model, one fileβ without boilerplate drift. See Hugging Faceβs modular transformers guide.
Enterprise takeawayβ
Standardising on Transformers reduces vendor lock-in at the definition layer: the same checkpoint can move between research notebooks, Trainer jobs and production engines that consume Hugging Face model definitions.
Discussion
Commentsβ
Share feedback or questions about this page. No account required.
Loading commentsβ¦