Back to glossary

Term

Transformers (Library)

Open-source Python library from Hugging Face that gives unified access to thousands of pretrained models across text, vision and audio.

Transformers (Library) — in more detail

The transformers library is the de facto standard toolkit for loading and running pretrained models from the Hugging Face Hub in Python. It offers a unified API across model families (BERT, GPT, Llama, Whisper, ViT, Stable Diffusion components, etc.) and supports PyTorch, TensorFlow and JAX as backends.

Example / practical context

A model can be used for a concrete task in just a few lines — the pipeline() helper abstracts tokenization, inference and postprocessing:

from transformers import pipeline
classifier = pipeline("sentiment-analysis")
classifier("I love open source.")

For more control, AutoTokenizer and AutoModel pick the right modules based on the model name. The library is also widely used for fine-tuning, often paired with accelerate for multi-GPU training and peft for parameter-efficient methods such as LoRA.

Delineation from similar terms

The Transformers library should not be confused with the Transformer architecture itself (the neural network from the paper “Attention Is All You Need”). Unlike inference engines such as llama.cpp or vLLM, transformers targets training and research workflows; for pure high-throughput production inference, specialized engines are more efficient.

Entdecke mehr

Themenuebersicht