huggingface/transformers
Dependencies
The dependency surface declared by setup.py and the auto-generated mirror at src/transformers/dependency_versions_table.py.
Hard install requirements
Listed in setup.py as install_requires. Installing pip install transformers (no extras) pulls these:
| Package | Version pin | Why |
|---|---|---|
huggingface-hub |
>=1.5.0,<2.0 |
Hub I/O |
numpy |
>=1.17 |
Tensors and CPU paths |
packaging |
>=20.0 |
Version checks |
pyyaml |
>=5.1 |
Model card metadata |
regex |
>=2025.10.22 |
Tokenizer fast paths |
tokenizers |
>=0.22.0,<=0.23.0 |
Fast tokenizers |
typer |
(latest) | CLI |
safetensors |
>=0.4.3 |
Default checkpoint format |
tqdm |
>=4.27 |
Progress bars |
filelock is bundled transitively. The fallback HTTP stack uses requests (also transitive).
torch is in an extra, not the install requirements
pip install transformers does not install torch. The recommendation is pip install "transformers[torch]", which adds:
torch>=2.4
accelerate>=1.1.0The library raises clear errors if you try to use any modeling feature without torch. Some pipelines, tokenizers, and processors work without torch.
Major optional extras
Defined in setup.py:
| Extra | Adds | Purpose |
|---|---|---|
torch |
torch, accelerate | Required for modeling |
vision |
torchvision, Pillow | Image processors |
audio |
torchaudio, librosa, pyctcdecode, phonemizer, kenlm (Py<3.13) | Audio processors / ASR |
video |
av | Video decode |
timm |
timm | Vision backbones |
kernels |
kernels | Hub kernels |
sentencepiece |
sentencepiece, protobuf | Slow tokenizer backends |
tiktoken |
tiktoken, blobfile | OpenAI BPE |
mistral-common |
mistral-common[image] | Mistral tokenizer backend |
chat_template |
jinja2, jmespath | Chat-template engine |
sklearn |
scikit-learn | Metrics |
accelerate |
accelerate | Distributed dispatch (also pulled by torch) |
retrieval |
faiss-cpu, datasets | RAG |
sagemaker |
sagemaker | AWS SageMaker |
deepspeed |
deepspeed, accelerate | DeepSpeed |
optuna |
optuna | Hyperparameter search |
ray |
ray[tune] | Hyperparameter search (Py<3.14) |
integrations |
kernels, optuna, codecarbon, ray (Py<3.14) | Aggregate of common integrations |
codecarbon |
codecarbon | Carbon emissions tracking |
serving |
openai, pydantic, uvicorn, fastapi, starlette, rich + torch |
transformers serve |
num2words |
num2words | Some preprocessors |
benchmark |
optimum-benchmark | make benchmark |
ja |
fugashi, ipadic, unidic_lite, unidic, rhoknp, sudachipy/dict (Py<3.14) | Japanese tokenization |
open-telemetry |
opentelemetry-api/exporter-otlp/sdk | Metrics in continuous batching |
quality |
datasets, ruff, GitPython, urllib3, libcst, rich, ty, tomli, transformers-mlinter | Repo quality tooling |
docs |
hf-doc-builder | Docs build |
testing |
pytest + asyncio/random-order/rich/xdist/order/rerunfailures/timeout/env, parameterized, psutil, dill, evaluate, rouge-score, nltk, sacremoses, rjieba, beautifulsoup4, tensorboard, sacrebleu, filelock + extras docs, quality, retrieval, sentencepiece, serving, mistral-common |
All testing deps |
deepspeed-testing |
deepspeed + testing + optuna + sentencepiece |
DeepSpeed CI |
all |
aggregate of inference-time extras | "Most users want this" |
dev |
all + testing + ja + sklearn |
Heaviest install |
The pip install -e ".[dev]" install pulls roughly 200 packages.
Auto-generated mirror
src/transformers/dependency_versions_table.py is the runtime version of setup.py's _deps list, regenerated by python utils/checkers.py deps_table (a step of make fix-repo). src/transformers/dependency_versions_check.py enforces minimum versions at import time.
Tooling versions
These are pinned for reproducible CI:
| Package | Pin | Reason |
|---|---|---|
ruff |
==0.14.10 |
Lint output deterministic |
transformers-mlinter |
==0.1.1 |
Custom rules in utils/rules.toml |
ty |
==0.0.20 |
Type checker |
pandas |
<2.3.0 |
Compatibility (datasets) |
pytest |
>=7.2.0,<9.0.0 |
Test framework |
Heavy optional dependencies
Quantization backends each declare their own dependency outside this list (consumed via pip install bitsandbytes, pip install autoawq, pip install hqq, etc.) and are checked at runtime by is_<backend>_available helpers in src/transformers/utils/import_utils.py.
See also
- Tooling —
make fix-reporegeneratesdependency_versions_table.py. - Quantization — backend dependencies and
is_<backend>_available. - Integrations — third-party adapters live in
src/transformers/integrations/.
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.