Favicon of Transformers

Transformers

An open-source Python library for running and training text, vision, audio and multimodal models locally, with Apache 2.0 licensing and PyTorch support.

Screenshot of Transformers website

Transformers is a Python library for developers and researchers who want to run pretrained AI models or train their own on hardware they control. It covers language, images, audio, video and multimodal work through a shared way of defining models. The library runs in a local Python environment; pretrained checkpoints are available from the separate Hugging Face Hub.

For inference, its Pipeline interface handles tasks such as text generation, speech recognition, image segmentation and questions about documents. Its generation tools support streaming output from large language and vision language models. Training is covered too: Trainer works with PyTorch models and supports distributed training, mixed precision and FlashAttention.

A model definition in Transformers can also be used by tools across the wider ecosystem, including Axolotl and Unsloth for training, vLLM and SGLang for inference, and libraries such as llama.cpp and mlx. That makes it useful if you expect to experiment with a model before choosing how to train or serve it. Researchers can inspect and customize model code, while developers can start from pretrained checkpoints instead of building a model from scratch. Transformers is released under Apache 2.0.

Similar to Transformers