Archive of AI

Source Snapshot / 2025-12-01-huggingface-transformers-v5-1

Transformers v5: Simple model definitions powering the AI ecosystem

Linked event: 2025-12-01 · Hugging Face Launches Transformers v5 Architectural Overhaul as Cumulative Installations Surpass 1.2 Billion

Publisher
Hugging Face Blog
Archived
2026-11-23
Capture Method
Direct page capture
HTTP / SHA-256
200 / c6e71b28f1a5911d
Original URL
Open source ↗
Wayback Backup
Not archived
This page preserves a plain-text static snapshot against link rot. When citing figures, tables, or full legal terms, verify against the original URL and Wayback Machine archive.

[来源关键摘录] 2025 年 12 月 1 日官方公告,披露 Transformers 12 亿次累计安装量、超 400 种模型架构及 v5 并行权重加载重构。

[正文前段节选] Hugging Face

Search models, datasets, users... ⌘K

Back to Articles

Transformers v5: Simple model definitions powering the AI ecosystem

December 1, 2025

Update on GitHub

Arthur Zucker

Cyril Vallez

Vaibhav Srivastav

Transformers' version v4.0.0rc-1, the initial release candidate for version 4, was released on November 19th, 2020. Five years later, we now release v5.0.0rc-0.

Today, as we launch v5, Transformers is installed more than 3 million times each day via pip - up from 20,000/day in v4 🤯. Altogether, it has now surpassed 1.2 billion installs!

The ecosystem has expanded from 40 model architectures in v4 to over 400 today, and the community has contributed more than 750,000 model checkpoints on the Hub compatible with Transformers, up from roughly 1,000 at the time of v4.

This growth is powered by the evolution of the field and the now mainstream access to AI. As a leading model-definition library in the ecosystem, we need to continuously evolve and adapt the library to continue being relevant. Reinvention is key for longevity in AI.

We’re fortunate to collaborate with many libraries and apps built on transformers, in no specific order: llama.cpp, MLX, onnxruntime, Jan, LMStudio, vLLM, SGLang, Unsloth, LlamaFactory, dLLM, MaxText, TensorRT, Argmax, among many other friends.

For v5, we wanted to work on several notable aspects: simplicity, training, inference, and production. We detail the work that went into them in this post.

The first focus of the team was on simplicity. Working on transformers, we see the code as the product. We want our model integrations to be clean, so that the ecosystem may depend on our model definitions and understand what’s really happening under the hood, how models differ from each other, and the key features of each new model. Simplicity results in wider standardization, generality, and wider support.

Model Additions

Transformers is the backbone of hundreds of thousands of projects, Unsloth included. We build on Transformers to

help people fine-tune and train models efficiently, whether that’s BERT, text-to-speech (TTS), or others; to run

fast inference for reinforcement learning (RL) even when models aren’t yet supported in other libraries. We're

excited for Transformers v5 and are super happy to be working with the Hugging Face team!

-- Michael Han at Unsloth

Transformers, at the core, remains a model architecture toolkit. We aim to have all recent architectures and to be the “source of truth” for model definitions. We’ve been adding between 1 - 3 new models every week for 5 years, shown in the timeline below:

We’ve worked on improving that model-addition process.

Modular Approach

Over the past year, we’ve heavily pushed our modular design as a significant step forward. This allows for easier maintenance, faster integration, and better collaboration across the community.

We give a deeper overview in our Maintain the Unmaintainable blog post. For brevity, we aim to achieve a much easier model contribution process, as well as a lower maintenance burden. One metric we can highlight is that the number of lines of code to contribute (and review), drop significantly when modular is used:

While we respect the “One model, one file” philosophy, we continue introducing some abstractions making the management of common helpers simpler. The prime example of this is the introduction of the AttentionInterface, which offers a centralized abstraction for attention methods. The eager method will remain in the modeling file; others, such as FA1/2/3, FlexAttention, or SDPA, are moved to the interface.

Over the past couple of years, the increasing amount of 0-day support for new model architectures and

standardization of attention handling has helped to simplify our support for post-training modern LLMs.

-- Wing Lian, Axolotl

Tooling for Model Conversion

We’re building tooling to help us identify which existing model architecture a new model resembles. This feature uses machine learning to find code similarities between independent modeling files. Going further, we aim to automate the conversion process by opening a draft PR for the model to be integrated into our transformers format. This process reduces manual effort and ensures consistency.

Code Reduction

Streamlining Modeling & Tokenization/Processing Files

We’ve significantly refactored the modeling and tokenization files. Modeling files have been greatly improved thanks to the modular approach mentioned above, on top of standardization across models. Standardization contributes to abstracting most of the tools that don’t make up a model, so that the modeling code only contains the relevant parts for a model’s forward/backward passes.

Alongside this work, we’re simplifying the tokenization and processing files: going forward, we’ll only focus on the tokenizers backend, removing the concept of “Fast” and “Slow” tokenizers.

We'll use tokenizers as our main tokenization backend, just as we do for PyTorch-based models. We’ll offer alternatives for Sentencepiece or MistralCommon backed tokenizers, which will be non-default but will be supported. Image processors will now only exist with their fast variant, which depends on the torchvision backend.

Finally, we’re sunsetting our Flax/TensorFlow support in favor of focusing on PyTorch as the sole backend; however,

we're also working with partners in the Jax ecosystem to ensure we have compatibility between our models and this

With its v5 release, transformers is going all in on PyTorch. Transformers acts as a source of truth and

foundation for modeling across the field; we've been working with the team to ensure good performance

across the stack.

We're excited to continue pushing for this in the future across training, inference, and deployment.

-- Matt White, Executive Director, PyTorch Foundation. GM of AI, Linux Foundation

Training remains a big focus of the team as we head into v5: whereas previously we would focus heavily on fine-tuning rather than pre-training/full-training at scale, we’ve recently done significant work to improve our support for the latter as well.

Pre-training at scale

Supporting pre-training meant reworking the initialization of our models, ensuring that they worked at scale with different parallelism paradigms, and shipping support for optimized kernels for both the forward and backward passes.

Going forward, we’re excited to have extended compatibility with torchtitan, megatron, nanotron, as well as any other pre-training tool that is interested in collaborating with us.

Fine-tuning & Post-training

We continue collaborating closely with all fine-tuning tools in the Python ecosystem. We aim to continue providing model implementations compatible with Unsloth, Axolotl, LlamaFactory, TRL and others in the PyTorch ecosystem; but we are also working with tools such as MaxText, in the JAX ecosystem, to have good interoperability between their frameworks and transformers.

All fine-tuning and post-training tools can now rely on transformers for model definitions; further enabling Agentic use-cases through OpenEnv or the Prime Environment Hub.

We’re putting a significant focus on inference for v5, with several paradigm changes: the introduction of specialized kernels, cleaner defaults, new APIs, support for optimized inference engines.

Similarly to training, we’ve been putting some effort in packaging kernels so that they’re automatically used in case your hardware and software permits it. If you haven’t heard of kernels before, we recommend taking a look at this doc.

Alongside this effort, we ship two new APIs dedicated to inference:

We ship support for continuous batching and paged attention mechanisms. This has now been used internally for some time, and we’re working on finalizing the rough edges and writing usage guides.

We introduce transformers serve as the new transformers-specific serving system, which deploys an OpenAI API-compatible server.

[...内容已截断,完整版请查看原文或 Wayback 快照]