Transformers

by Hugging Face

Hugging Face's open-source Python library for loading, running and fine-tuning pretrained ML models across text, vision, audio and multimodal tasks.

framework-libraryopen-sourcepythonfree-tierself-hosted
Visit WebsiteGitHubhuggingface.co

At a Glance

Type

Frameworks and libraries

Pricing

FreeFree and open source (Apache License 2.0); compute and Hugging Face Hub usage are separate costs.

Best For

Loading a pretrained model from the Hugging Face Hub and running inference or fine-tuning it, without writing a model architecture from scratch.

Platforms

Python, CLI, Linux, macOS, Windows

Founded

2016

Headquarters

Brooklyn, New York, United States

Free Tier

Available

Licence

Open Source

Key Features

Pros & Cons

Strengths

  • Apache 2.0 licensed and free to install and use
  • Single library covers inference and training across text, vision, audio and multimodal models
  • Over 1M+ pretrained checkpoints available directly from the Hugging Face Hub
  • Model definitions are reused by major inference engines like vLLM, SGLang and TGI

Limitations

  • Requires PyTorch 2.5+ installed alongside it; TensorFlow and JAX are no longer supported as of v5 (users needing them must stay on the v4 LTS branch)
  • TensorFlow and JAX support was dropped entirely in Transformers v5; only PyTorch is supported going forward (TF/JAX users must stay on the v4 LTS line)
  • Large model checkpoints mean downloads and local storage can be substantial for bigger models

Integrations

PyTorchAxolotlUnslothDeepSpeedFSDPPyTorch-LightningvLLMSGLangTGIllama.cppmlxHugging Face Hub

What it is

Transformers is Hugging Face's open-source Python library for loading, running and fine-tuning pretrained machine learning models across text, vision, audio, video and multimodal tasks. The docs describe it as "the model-definition framework for state-of-the-art machine learning models," centralising model architectures so the same definition works across training frameworks (Axolotl, Unsloth, DeepSpeed, FSDP, PyTorch-Lightning), inference engines (vLLM, SGLang, TGI) and adjacent libraries (llama.cpp, mlx).

Interface and dependencies

It's installed with pip install "transformers[torch]" and requires Python 3.10+ plus PyTorch 2.5+; TensorFlow and JAX are no longer supported backends as of v5. Three core classes — configuration, model and preprocessor — back two main entry points: the Pipeline class for quick inference (text generation, image segmentation, speech recognition, document Q&A) and the Trainer class for PyTorch training with mixed precision, torch.compile and FlashAttention support.

Real use

A developer can pull any of the over 1M+ model checkpoints hosted on the Hugging Face Hub and run inference in a few lines via pipeline("text-generation"), or fine-tune a pretrained model with Trainer instead of training from scratch. It underpins many downstream inference servers (TGI, vLLM) that load models using its definitions.

Limits

TensorFlow and JAX support was removed in Transformers v5, so PyTorch is the only supported backend for training and inference; TF/JAX users must stay on the v4 LTS release. Model weights for large architectures can be several gigabytes, so local disk and bandwidth are practical constraints.

Frequently Asked Questions

Is Transformers free to use?
Yes. It's released under the Apache License 2.0 and installed via pip at no cost; you pay only for your own compute and any model downloads.
Does it work without a GPU?
Yes, models can run on CPU, though inference and training are much slower than on a GPU-backed PyTorch install (the only supported backend as of v5).

Last updated on