Hugging Face Transformers Documentation
by Hugging Face
The model-definition layer the whole open-weight ecosystem agrees on - over 400 architectures behind three classes and two APIs.
Overview
Transformers is the model-definition layer the rest of the open-weight ecosystem agrees on: define an architecture here and it works with training stacks such as Axolotl, Unsloth, DeepSpeed, FSDP and PyTorch Lightning, inference engines such as vLLM, SGLang and TGI, and adjacent runtimes such as llama.cpp and MLX. The documentation is organised as Quickstart, Base classes, Inference, Training, Quantization, Export to production, task recipes and a full API reference. Its core claim is that every model reduces to three classes - PreTrainedConfig, PreTrainedModel and a preprocessor such as a tokenizer or image processor - plus two entry points, Pipeline for inference and Trainer for training. The docs walk through loading any checkpoint with the AutoClass API and from_pretrained, the device map and dtype settings that decide whether a large model fits your GPU, the generate method for text and vision-language models including streaming and multiple decoding strategies, and a complete Trainer loop with TrainingArguments, a data collator and push_to_hub. The current pages track v5, released December 2025, which is a genuine break from v4: TensorFlow and Flax support was removed in favour of PyTorch alone, the fast and slow tokenizer split was collapsed, quantization became a first-class citizen, attention implementations were standardised behind AttentionInterface, and a transformers serve command now exposes an OpenAI-compatible endpoint with continuous batching and paged attention. The library covers over 400 architectures and more than a million Hub checkpoints, and the repository carries roughly 163,000 GitHub stars under Apache-2.0.
At a Glance
- Topic
- Frameworks
- Level
- Intermediate
- Format
- Documentation
- Cost
- Free
- Duration
- Self-paced reference; the Quickstart is ~30 minutes end to end
- Provider
- Hugging Face
- Hands-on
- Yes — code/exercises
- Certificate
- None
What You’ll Learn
- ✓Load any Hub checkpoint with the AutoClass API and the from_pretrained method
- ✓Run inference across a dozen task types through the Pipeline class
- ✓Configure text generation for streaming and different decoding strategies
- ✓Fine-tune a model with Trainer, TrainingArguments and a data collator
- ✓Fit large models onto your GPU using device map and dtype settings
- ✓Apply quantization to cut memory use and speed up inference
- ✓Export a trained model to production and serve it over an OpenAI-compatible API
Highlights
- •The de facto model-definition standard - vLLM, SGLang, Unsloth and llama.cpp all consume it
- •Over 400 architectures and more than a million Hub checkpoints behind one consistent API
- •Docs are versioned per release, so you can read the exact page for the version you installed
- •v5 dropped TensorFlow and Flax, so examples are no longer split three ways across frameworks
- •Task recipes give end-to-end runnable code rather than bare API signatures
Who It’s For
Best For
- ✓Engineers running or fine-tuning open-weight models in Python
- ✓Developers migrating a v4 codebase onto the PyTorch-only v5 API
- ✓Anyone who needs reference-grade detail rather than another tutorial
Prerequisites
- •Working Python and comfort with pip, virtual environments and the command line
- •Basic PyTorch - tensors, devices and the shape of a training loop
- •A GPU for anything beyond small-model inference
FAQ
What is Hugging Face Transformers Documentation?
Official documentation for Transformers, the library that defines model architectures for the rest of the open-model ecosystem. It teaches loading any Hub checkpoint through the AutoClass API, running inference with Pipeline, generating text with streaming and decoding strategies, fine-tuning with Trainer, quantizing for memory, and exporting to production. Since v5 it is PyTorch-only, which makes the docs considerably less ambiguous than the three-framework era they replaced.
Is Hugging Face Transformers Documentation free?
Hugging Face Transformers Documentation is free to access.
What level is Hugging Face Transformers Documentation for?
Hugging Face Transformers Documentation is aimed at a intermediate audience. Recommended background: Working Python and comfort with pip, virtual environments and the command line, Basic PyTorch - tensors, devices and the shape of a training loop, A GPU for anything beyond small-model inference.
How long does Hugging Face Transformers Documentation take?
Expect roughly Self-paced reference; the Quickstart is ~30 minutes end to end. Most learners work through it at their own pace.
What will I learn from Hugging Face Transformers Documentation?
You'll learn: Load any Hub checkpoint with the AutoClass API and the from_pretrained method; Run inference across a dozen task types through the Pipeline class; Configure text generation for streaming and different decoding strategies; Fine-tune a model with Trainer, TrainingArguments and a data collator; Fit large models onto your GPU using device map and dtype settings; Apply quantization to cut memory use and speed up inference; Export a trained model to production and serve it over an OpenAI-compatible API.
Topics
Sources
This page was written from 3 sources, 1 on domains other than huggingface.co.