# transformers

> Shared model definitions for text, vision, audio and multimodal AI models

- Repository: https://github.com/huggingface/transformers
- Category: Models & local AI
- Stars: 168,014 · Forks: 34,946 · Language: Python · License: Apache-2.0
- Experience: Some experience
- Page: https://ir.adyog.com/repos/huggingface/transformers/

Machine learning models come in many architectures, and research teams often publish their own code. Transformers collects those model definitions in one library with a common interface. You can load a model from the Hugging Face Hub and use it without learning a new codebase each time.

The quickest way in is the Pipeline class. You name a task, such as text generation or speech recognition, and a model. It downloads the model, prepares the input, runs it and returns the result. For more control, the library exposes model internals and includes a training API for PyTorch models.

The README says these model definitions are meant to be the agreed reference across the ecosystem. Training frameworks (Axolotl, Unsloth, DeepSpeed, FSDP, PyTorch-Lightning), inference engines (vLLM, SGLang, TGI) and libraries like llama.cpp and mlx reuse them. It says it is not a modular toolbox of neural net building blocks, and for generic training loops it points to Accelerate.

## What it does

- **Pipeline API**: A high-level class that handles preprocessing and output for text, audio, vision and multimodal tasks. The README shows text generation, chat, speech recognition, image classification and visual question answering.
- **Hub of pretrained checkpoints**: Works with over a million checkpoints on the Hugging Face Hub, across hundreds of architectures. Models are downloaded and cached on first use.
- **Wide modality coverage**: Example models include Whisper and Parakeet for speech, MusicGen for audio, SAM and DINO v2 for vision, and Qwen and Llama for text.
- **Chat from the command line**: With transformers serve running, the transformers chat command lets you talk to a model directly from the terminal.
- **Readable, customizable model code**: Model files are deliberately not wrapped in extra abstractions, so researchers can edit one model without digging through shared layers. Examples reproduce results published by the original authors.

## What you could build

- Transcribe audio files with a speech recognition model such as Whisper.
- Run a chat model locally and build a simple assistant on top of it.
- Classify images or answer questions about them with a pretrained vision model.
- Fine-tune a pretrained model on your own data using the training API.
- Read a model's source code to learn how a modern architecture is put together.

## Who it's for

Developers, students and researchers who know basic Python and want to run or adapt pretrained models; some PyTorch familiarity helps for training.

## Get started

Create a virtual environment with Python 3.11 or newer and install the library with the torch extra. Then build a pipeline for a task and a model name and pass it some input.

```
pip install "transformers[torch]"
```
```
uv pip install "transformers[torch]"
```
```
transformers chat Qwen/Qwen2.5-0.5B-Instruct
```

Tags: transformers, pytorch, llm, nlp, pretrained-models
