huggingface /transformers
🤗 Transformers: the model-definition framework for state-of-the-art machine learning models in text, vision, audio, and multimodal models, for both inference and training.
★ 168,729⑂ 35,148👁 1,243⑃ 29,843● 19,811▤ 282◈ 0
168,729
stars
+45+278+1,749
35,148
forks
1,243
watchers
29,843
prs
19,811
issues
282
releases
0
discussions
README
English |
简体中文 |
繁體中文 |
한국어 |
Español |
日本語 |
हिन्दी |
मराठी |
Русский |
Português |
తెలుగు |
Français |
Deutsch |
Italiano |
Tiếng Việt |
العربية |
اردو |
বাংলা |
فارسی |
Română |
Türkçe
State-of-the-art pretrained models for inference and training
Transformers acts as the model-definition framework for state-of-the-art machine learning with text, computer
vision, audio, video, and multimodal models, for both inference and training.
It centralizes the model definition so that this definition is agreed upon across the ecosystem. transformers is the
pivot across frameworks: if a model definition is supported, it will be compatible with the majority of training
frameworks (Axolotl, Unsloth, DeepSpeed, FSDP, PyTorch-Lightning, ...), inference engines (vLLM, SGLang, TGI, ...),
and adjacent modeling libraries (llama.cpp, mlx, ...) which leverage the model definition from transformers.
We pledge to help support new state-of-the-art models and democratize their usage by having their model definition be
simple, customizable, and efficient.
There are over 1M+ Transformers model checkpoints on the Hugging Face Hub you can use.
Explore the Hub today to find a model and use Transformers to help you get started right away.
Installation
Transformers works with Python 3.11+, and PyTorch 2.6+.
Create and activate a virtual environment with venv or uv, a fast Rust-based Python package and project manager.
py
venv
python -m venv .my-env
source .my-env/bin/activate
uv
uv venv .my-env
source .my-env/bin/activate
Install Transformers in your virtual environment.
py
pip
pip install "transformers[torch]"
uv
uv pip install "transformers[torch]"
Install Transformers from source if you want the latest changes in the library or are interested in contributing. However, the latest version may not be stable. Feel free to open an issue if you encounter an error.
shell
git clone https://github.com/huggingface/transformers.git
cd transformers
pip
pip install '.[torch]'
uv
uv pip install '.[torch]'
Quickstart
Get started with Transformers right away with the Pipeline API. The Pipeline is a high-level inference class that supports text, audio, vision, and multimodal tasks. It handles preprocessing the input and returns the appropriate output.
Instantiate a pipeline and specify model to use for text generation. The model is downloaded and cached so you can easily reuse it again. Finally, pass some text to prompt the model.
py
from transformers import pipeline
pipeline = pipeline(task="text-generation", model="Qwen/Qwen2.5-1.5B")
pipeline("the secret to baking a really good cake is ")
[{'generated_text': 'the secret to baking a really good cake is 1) to use the right ingredients and 2) to follow the recipe exactly. the recipe for the cake is as follows: 1 cup of sugar, 1 cuTop issues
#33260Community contribution: Adding GGUF support for more architectures52 comments · 2024-09-02#7675Add FAVOR+ / Performer attention47 comments · 2020-10-09#21079TokenGT35 comments · 2023-01-10#14839Fine-tuning GPT-J-6B in colab: 8-bit weights with low-rank adaptors34 comments · 2021-12-19#15451Adding RelationExtraction head to layoutLMv2 and layoutXLM models31 comments · 2022-02-01#24295Add training support for EnCodec27 comments · 2023-06-15#35308Multi-GPU training crashes with IterableDataset and different length input (e.g. Next token prediction)21 comments · 2024-12-17#29293Whisper - get probability of detected language21 comments · 2024-02-26
Latest release
Patch release v5.22.2 v5.22.2 2026-11-06Patch release v5.22.2 Some in between patch for security and distributed fixes. See the included commits :hugs: - [Distributed] Set device_id only for NCCL (50281) by @michaelbenayoun and @3outeille - Harden our Jinja sandboxing (50431) by @Rocketknight1 Full Changelog: https://github.com/huggingface/transformers/compare/v5.22.1...v5.22.2
相关报道 (5)
News & coverage (14)
Hacker NewsTransformers 2.0: Deep interoperability between TensorFlow 2.0 and PyTorch▲ 103 · 3 comments · 2019-09-27Hacker NewsHuggingFace releases support for tool-use and RAG models▲ 59 · 0 comments · 2024-07-03Hacker NewsTransformers.js 3.0 Released with WebGPU Support▲ 33 · 1 comments · 2024-10-22Hacker NewsAsk HN: Are you training and running custom LLMs and how are you doing it?▲ 15 · 2 comments · 2023-08-14Hacker NewsTransformers V5 is out!▲ 10 · 0 comments · 2026-01-26Hacker NewsAdding Support for Qwen3.5▲ 5 · 0 comments · 2026-02-09Hacker NewsQwen3 Is Dropping Soon▲ 5 · 0 comments · 2025-03-23Hacker NewsWhy is GitHub search so terrible?▲ 3 · 2 comments · 2023-04-28Pasquale PillitteriThe Open Source Stack Every AI Startup Uses: 7 GitHub Repos (With Real Star Counts)2026-08-13The Hacker NewsMini Shai-Hulud Worm Compromises TanStack, Mistral AI, Guardrails AI & More Packages2026-05-12