Hugging Face Transformers
Transformers is a free, open-source Python library that lets you download a ready-trained AI model by name and run or train it with a short piece of code.
Hugging Face Transformers is a free, open-source Python library for using AI models that someone else has already trained. You name a model, and the library fetches it from the Hugging Face Hub, a website where people share models. Then you can run it, or train it further on your own examples. It works with text, pictures, sound, video and mixes of these.
Every model in the library is built from the same three parts. A configuration is a settings file that lists the model’s attributes, such as how many different tokens it knows. The model holds the learned numbers, called weights. A preprocessor turns raw input into numbers. For text, this is a tokenizer. It splits words into small pieces called tokens. Because every model follows that pattern, the same few commands work across many different models.
The quickest way in is a pipeline. You name a task, such as speech recognition, and hand it your input. You can also pick a model if you want. The pipeline prepares the input and returns the output. Many other AI tools, for training models or running them for users, read the same model definitions. The code uses the Apache 2.0 licence.
Using someone else's trained model raises three problems a shared library can solve.
Follow one prompt through a small text-generation model.
- 1 · pickYou pick a model by its Hugging Face Hub name. The Hub is a website where people share models.
- 2 · loadThe from_pretrained step reads the model's settings file, picks the matching classes and downloads the weights.
- 3 · tokenizeA tokenizer turns your text into token ids, the numbers a model reads.
- 4 · generateThe model uses those numbers to produce new token ids.
- 5 · decodeThe tokenizer turns the new ids back into words you can read.
A pipeline prepares the input and returns the output for you.
| Who | What they ask | What it works with |
|---|---|---|
| Student | “Can I try a speech-to-text model on my laptop this afternoon?” | A speech recognition pipeline with a model from the Hub |
| App developer | “Which small chat model fits my prompt style best?” | The same pipeline code with a different model name |
| Researcher | “Can I fine-tune this model on my own labelled examples?” | The Trainer class and a saved, already-trained model |
| Machine learning engineer | “Will this model load in the tool we use to run models for users?” | The shared model definition that other tools read |
- It loads many kinds of model through the same few commands.
- It handles text, images, audio, video and mixed inputs.
- It covers both running models and training them further.
- Its model definitions are reused by many other training and serving tools.
- It does not include the models; they download from the Hub when you first load them.
- It is not a kit of small building blocks for designing new kinds of neural network.
- Its training tools are built for its own PyTorch models, not any machine learning loop.
- Its example scripts may need changes before they work for your task.
Sources used
This explainer is written in original language. The links below support its factual claims.
- repohuggingface/transformers: model-definition framework for state-of-the-art machine learning, Hugging Face · read 28 Sept 2026
- docsTransformers, Hugging Face · read 28 Sept 2026
- docsQuickstart, Hugging Face · read 28 Sept 2026
- docsPipeline, Hugging Face · read 28 Sept 2026
- docsTokenizers, Hugging Face · read 28 Sept 2026
- paperHuggingFace's Transformers: State-of-the-art Natural Language Processing, arXiv · read 28 Sept 2026
- repoTransformers LICENSE, Hugging Face · read 28 Sept 2026