Find your next open-source project

Search by name, purpose, or keyword — or paste a GitHub repository URL

huggingface/transformers

Machine Learning

A model-definition framework for loading, running and fine-tuning text, vision, audio and multimodal models from the Hugging Face Hub.

168,896
35,221
Python
Apache-2.0
8 years old

What it does

Transformers is the model-definition framework behind the Hugging Face ecosystem. Instead of providing model weights, it defines how architectures are loaded, configured and executed, so the same model definition can be shared across training frameworks such as Axolotl, Unsloth, DeepSpeed and PyTorch-Lightning, inference engines such as vLLM, SGLang and TGI, and adjacent libraries such as llama.cpp and mlx. It covers text, vision, audio, video and multimodal models for both inference and training, with over 1M compatible checkpoints on the Hub model checkpoints.

It suits researchers and engineers who want a unified API over many pretrained architectures rather than reimplementing each model, and who need to move a single model between PyTorch, JAX and TensorFlow or between experimentation and production.

Install and run a first pipeline

Transformers requires Python 3.11+ and PyTorch 2.6+ PyTorch. Create and activate a virtual environment, then install with the torch extra:

python -m venv .my-env
source .my-env/bin/activate
pip install "transformers[torch]"

The uv route replaces the install step with uv pip install "transformers[torch]" installation steps. For the latest unreleased code, clone the repository, cd into it and run pip install '.[torch]'; that version may be unstable, so report problems through the issue tracker.

The high-level Pipeline handles preprocessing and returns task-appropriate output. This example downloads and caches a text-generation model, then prompts it quickstart:

from transformers import pipeline

pipe = pipeline(task="text-generation", model="Qwen/Qwen2.5-1.5B")
pipe("the secret to baking a really good cake is ")

The result is a list of dictionaries with a generated_text field. The same API pattern applies to chat (pass a list of {"role", "content"} messages), automatic speech recognition with openai/whisper-large-v3, image classification with facebook/dinov2-small-imagenet1k-1-layer, and visual question answering with Salesforce/blip-vqa-base. A CLI is also available: with transformers serve running, transformers chat Qwen/Qwen2.5-0.5B-Instruct opens an interactive chat serving docs.

Browse the model catalog to pick a checkpoint; the model card shows the exact task name to pass to pipeline.

Constraints

  • Model weights are not bundled with the library. The first run downloads checkpoints from the Hub and caches them locally, so network access and disk space are needed, and gated models require accepting their terms and authenticating.
  • GPU execution and quantized or large models depend on the installed PyTorch build, available hardware and memory; CPU-only setups work but are slower for large models.
  • The training API is optimized for Transformers-provided PyTorch models. For generic training loops the project points to Accelerate instead.
  • Model files are intentionally verbose rather than abstracted into a modular neural-net toolbox, to let researchers modify individual architectures directly.
  • Licensed under Apache-2.0 license.

HotRepo's take

The recorded daily snapshots show steady organic growth rather than a spike: daily gains moved from 69 stars on 2026-08-11 to around 100 on later dates, with a 528-star day on 2026-09-14 and a 536-star day on 2026-09-15, and the Python daily list placed it at rank 11 on 2026-11-12. At that scale, hundreds of stars a day reflect the project's role as shared infrastructure rather than a single launch. Hacker News discussion is sparse and mostly historical: a 2019 thread on TensorFlow/PyTorch interoperability drew 103 points, with commenters already calling it the most important NLP library thread comment; a 2024 post about tool-use and RAG model support and a 2026 note on v5 add little commentary. The interesting signal is architectural: by being the definition layer that training frameworks and inference engines both consume, Transformers stays relevant even as the surrounding tooling changes.

Written by AI from the project's README, updated . The project's own docs are the source of truth.

Hacker News

Transformers 2.0: Deep interoperability between TensorFlow 2.0 and PyTorch
▲ 103 · 3 comments · September 27, 2019
Transformers V5 is out!
▲ 10 · 0 comments · January 26, 2026