Repolode
huggingface

huggingface/transformers

Model-definition framework for state-of-the-art text, vision, audio and multimodal machine learning models, for inference and training.

Stars
167,893
Forks
34,917
Open issues
2,220
Last commit
6 hours ago

What is it?

Transformers provides a shared model-definition layer for state-of-the-art machine learning across text, computer vision, audio, video, and multimodal tasks. Each model is defined once in a consistent, readable form, so training frameworks, inference engines, and adjacent modeling libraries can build on the same definitions.

The library offers a high-level Pipeline API for running models in a few lines of code, covering tasks such as text generation, speech recognition, image classification, and visual question answering. Pretrained checkpoints are downloaded from the Hugging Face Hub and cached locally for reuse. Models can also be used directly for lower-level training and customization in PyTorch.

Installation requires Python 3.10+ and PyTorch 2.6+. The project is not a general toolbox of neural network building blocks; for generic training loops, the README points to Accelerate instead.

Key features

  • 01Pipeline API for inference across text, audio, vision, and multimodal tasks.
  • 02Access to over one million pretrained checkpoints on the Hugging Face Hub.
  • 03Consistent model definitions usable with PyTorch-based training and inference engines.
  • 04Chat with models directly from the command line via transformers serve and transformers chat.

Use cases

  • Running a pretrained language model for text generation or chat in a Python application.
  • Transcribing speech or classifying images with off-the-shelf models.
  • Fine-tuning a pretrained PyTorch model on a custom dataset.
  • Reproducing published model architectures for research experiments.

Quick start

  1. 1

    Create and activate a virtual environment with venv

    python -m venv .my-env
  2. 2

    Install Transformers with PyTorch support using pip

    pip install "transformers[torch]"
  3. 3

    Run a text-generation pipeline from Python code (see the Quickstart example)

Things to know

  • Requires Python 3.10+ and PyTorch 2.6+.
  • Running large models like Llama or Whisper-large needs substantial memory and ideally a GPU.

Topics

FAQ

What is transformers?
Model-definition framework for state-of-the-art text, vision, audio and multimodal machine learning models, for inference and training. Transformers provides a shared model-definition layer for state-of-the-art machine learning across text, computer vision, audio, video, and multimodal tasks. Each model is defined once in a consistent, readable form, so training frameworks, inference engines, and adjacent modeling libraries can build on the same definitions.
Is transformers free to use? What license does it have?
transformers is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
Is transformers still maintained?
Actively maintained. The last commit to transformers was on Oct 20, 2026.
What can I use transformers for?
Running a pretrained language model for text generation or chat in a Python application. Transcribing speech or classifying images with off-the-shelf models. Fine-tuning a pretrained PyTorch model on a custom dataset. Reproducing published model architectures for research experiments.
How do I install transformers?
Create and activate a virtual environment with venv: python -m venv .my-env Install Transformers with PyTorch support using pip: pip install "transformers[torch]" Run a text-generation pipeline from Python code (see the Quickstart example)
Where can I get transformers?
The source code and installation instructions are on GitHub: https://github.com/huggingface/transformers

Summary generated by AI from the project's README. GitHub stats refresh daily.

Related projects