Transformers: Hugging Face's Free AI Library That Powers Nearly Every Modern AI Model (2026) — What It Is and How to Use It
Almost every AI model you have heard of in the last few years runs through the same piece of free software. It is called Transformers, it is made by Hugging Face, and the repository huggingface/transformers has about 169,400 stars. Its current release is v5.24.1, published on 24 November 2026, and it is released under the Apache 2.0 licence, free for any use, including commercial work.
Transformers is not a chatbot and not a single model. It is a Python library that loads, runs and trains thousands of different AI models through the same few lines of code: you name the model, and the library handles the rest. That sameness is why it has been downloaded more than 3 billion times from PyPI, about 120 million in the last 30 days alone. All numbers here were checked live on 24 November 2026.
What Transformers Actually Is
Transformers is a model-definition framework for state-of-the-art models in text, vision, audio and multimodal work, for both inference and training — the project's own description. The library does not contain the models themselves; the weights live on the Hugging Face Hub, which hosts over 3 million models. When you ask it to load a model, it downloads the weights, builds the right architecture in PyTorch, and hands you a working object.
Before Transformers, every model came with its own setup. Transformers replaced that with one interface — a tokenizer, a model, and a configuration file — and the same calls load BERT from 2018 and a 100-billion-parameter model from 2026. Its own documentation calls it the pivot across frameworks: training tools and serving engines such as vLLM and TGI build on the same model definitions. Think of it as a universal remote for AI models: Transformers is the remote, the Hub is the shop, the models are the televisions. Readers of the Tech Know posts on Ollama, LangChain and Whisper have met the neighbours — Transformers is the layer underneath all of them. It needs Python 3.11 or newer and PyTorch 2.6 or newer.
The Story: From a BERT Port in 2018 to 169,000 Stars
Transformers began in October 2018, almost by accident. Google had just released BERT, and Thomas Wolf and the Hugging Face team built an open-source PyTorch port so researchers could use it. The repository was created on 29 October 2018. Hugging Face had been founded in 2016 by Clement Delangue, Julien Chaumond and Thomas Wolf.
The port grew because the problem kept growing: GPT-2, then T5, then RoBERTa, then a flood. By 2020 the library was the default way to use a pretrained model, and when large language models went mainstream in 2023, Transformers was already the plumbing underneath them. The Hub grew with it to over 3 million models, with more than 18 million developers. The 2026 release pace is about one minor version a week — v5.22.1 on 30 October, v5.22.2 in early November, v5.23.0 in mid-November, v5.24.1 on 24 November — and the stars climbed from about 166,500 in late September to about 169,400 by 24 November, with around 35,270 forks. On 3 September 2026, NVIDIA announced it will pay 12.93 billion dollars to acquire Hugging Face. The deal was still pending, but the Apache 2.0 licence means the released code stays open whatever happens to the company.
The Licence, Explained Exactly: Apache 2.0 — and One Big Qualification
Transformers is genuinely open source under the Apache License, version 2.0, confirmed by the package index listing, the repository's licence file, and every tracker checked for this article. You may use it for any purpose, including commercial use, copy it, modify it, and distribute your modified version, free or for money. You must keep the copyright notice and licence text in your copies and note the changes you made. Apache 2.0 also adds an explicit patent grant, which is one reason companies prefer it over the simpler MIT licence. There is no paid tier.
The qualification is the mistake almost everyone makes about Hugging Face. Apache 2.0 covers the library — the code. It does not cover the models. Every model on the Hub carries its own licence, stated on its model card: some are Apache 2.0 or MIT, while Meta's Llama models use a community licence with conditions on large-scale commercial use, Google's Gemma models have their own terms, and some models are research-only. A gated model may require you to accept its terms and sign in before downloading. So the correct statement is two sentences: the library is open source under Apache 2.0, free for any use; the models are licensed individually — read each model's licence before commercial use. The Tech Know post on Claude Code made the same point in reverse — Claude Code is proprietary, and calling it open source is simply wrong.
How It Works: Tokenizers, Models and the Three-Step Flow
Every task follows the same three steps. First, a tokenizer turns raw input into numbers: text is split into tokens; an image is split into patches; audio becomes a waveform feature array. Second, the model runs: the numbers go in, the neural network works, and scores come out. Third, the output becomes human-readable again: scores become labels, token IDs become text.
The tokenizer must always match the model. Transformers loads both from the same Hub repository, and the Auto classes do the choosing: AutoTokenizer picks the right tokenizer, AutoModel picks the right architecture. Two details matter. First, weights are usually stored in the safetensors format — a JSON header plus a flat data buffer instead of Python's pickle format, which can run arbitrary code when loaded. Second, models can load in 8-bit or 4-bit precision through integrations such as bitsandbytes, shrinking memory use dramatically.
Pipelines: AI in Three Lines of Code
Pipelines are the easiest way into Transformers: one object that wraps the whole three-step flow and that you call like a function. The classic example from the official documentation classifies sentiment in three lines: create a text-classification pipeline, call it with "This restaurant is awesome", and get back POSITIVE at 0.9998. The pipeline downloads a default model on first use and returns plain Python objects.
The task range is wide. For text: text-classification, text-generation, token-classification for named entities, fill-mask, feature-extraction, and zero-shot-classification. For audio: automatic-speech-recognition — Whisper, covered on Tech Know on 22 November 2026 — plus audio-classification and text-to-audio. For vision: image-classification, object-detection, depth-estimation, and zero-shot-image-classification, which compares an image against your labels. One version 5 change matters for older tutorials: the v5 migration guide states that question-answering, summarization, translation, image-to-text, visual-question-answering and image-to-image pipelines were removed. The models still exist; they are just no longer one-line pipelines. Finally, the safety rule: some models ship custom code that runs on load, and the library only runs it if you explicitly allow it with the trust_remote_code option. Only load models from sources you trust, and never enable remote code for a model you have not inspected.
The Model Hub: Over 3 Million Models, and How to Choose One
The Hub is the other half of the story. The official Hub documentation calls it the reference platform for open machine learning, hosting over 3 million models, over 1 million datasets and over 2 million Spaces apps. Every model is a version-controlled repository holding the weights, the configuration, the tokenizer files, a model card, and the licence. You can browse by task, library, language and licence, and the library downloads your pick with a single call.
Choosing is a skill, because the Hub's size is also its problem: thousands of candidates per task, mostly fine-tuned copies of a few base models, many without documentation. The practical filters are downloads and likes; the model card, which should say what data the model trained on; the licence; and the library tag. A model with no card, no licence and ten downloads is a gamble. Good starting points: BERT and RoBERTa for understanding text, DistilBERT as a smaller faster BERT, the Llama, Qwen, DeepSeek, Gemma and Mistral families for generating text, Whisper for speech, and CLIP for matching images with text. New families arrive constantly — v5.24.0 alone added Meta's Omnilingual ASR (over 1,600 languages), Inkling 2 Mini, NVIDIA's Dory, Apertus 1.5, HY4-VL, WavTokenizer, Lara Mini, Sarvam AI's 105-billion and 30-billion parameter models, and LG's EXAONE 3.0, 3.5 and Deep. Before downloading gigabytes of weights, try the model's Space on the Hub.
Training and Fine-Tuning with Trainer
Running a pretrained model is only half of Transformers; the other half is training. The Trainer class is the standard tool: give it a model, a dataset and training arguments, and it handles the training loop, the optimizer, the learning-rate schedule, logging, checkpointing and evaluation. Hundreds of lines of boilerplate become a configuration object and a single train call.
The most common pattern is fine-tuning, not training from scratch: start from a pretrained model and train it a little further on your own data. Full fine-tuning updates every weight, which is expensive; the popular alternative is LoRA, low-rank adaptation, which freezes the original weights and trains a small set of extra adapter weights instead. LoRA adapters are tiny — a few megabytes against gigabytes for the full model. The PEFT library provides LoRA, and TRL builds on it for reinforcement-learning style training. Data comes from the Datasets library, which streams the Hub's million-plus datasets without downloading everything at once. The honest limits: training a large language model from scratch takes thousands of graphics cards and millions of dollars, and fine-tuning a 70-billion-parameter model needs multiple high-end cards or aggressive quantization. Trainer also assumes you know the basics — overfitting, evaluation sets, learning rates. The library removes the plumbing, not the knowledge.
Running Models Locally: Hardware, Quantization and GGUF
Whether Transformers runs on your computer depends on which model you choose: memory is the constraint. In 16-bit precision a model needs about 2 gigabytes per billion parameters, so a 7-billion model needs roughly 14 gigabytes, a 13-billion model about 26, and a 70-billion model about 140. That is why a laptop runs a small model comfortably and cannot run a large one at all.
Quantization changes the arithmetic. 8-bit loading roughly halves the memory, and 4-bit quarters it, so a 7-billion model fits in about 4 gigabytes in 4-bit — small enough for a good laptop or a mid-range graphics card, at a small accuracy cost. Transformers supports 8-bit and 4-bit loading through bitsandbytes, and version 5 keeps improving export options for runtimes such as ONNX, OpenVINO and ExecuTorch. A second route is GGUF, a format designed for the llama.cpp runtime, optimised for ordinary CPUs and consumer hardware. Transformers can export models to GGUF, and Ollama — covered on Tech Know on 13 November 2026 — can then run them directly from the Hub. If you only want to chat with a model, Ollama is easier; to build or fine-tune, use Transformers. DistilBERT, about 66 million parameters, runs on a laptop CPU in well under a second. A 7-billion chat model in 4-bit runs on a 16-gigabyte laptop, slowly but usably. The laptop in this blog's own hardware notes — a Dell Latitude with an Intel i5, 8 gigabytes of memory and no discrete graphics card — runs small Transformers models on CPU, but not a 7-billion model comfortably, even quantized.
Running Models in the Cloud: APIs, Spaces and Inference Endpoints
If your computer cannot run the model you want, the cloud can, in three ways. Inference Providers are a pay-per-use API: send text to a hosted model and pay for what you use, with no server to manage. Inference Endpoints are dedicated deployments — your own copy of a model on a rented graphics card, billed by the hour, with autoscaling. Spaces hosts demo apps, with a free CPU tier and paid graphics-card tiers, including ZeroGPU.
Local versus cloud is a trade-off. Local is private — your data never leaves your machine — but limited to models that fit your computer. Cloud runs any model and scales, but your data leaves your machine and the bill runs while the server runs. Experiment locally with small models, and move to the cloud when you need a large model or are serving users. The library is free either way; cloud costs are for computer power, not for Transformers. And the model licence follows the model, not the machine: running a restrictively licensed model in the cloud does not make the licence go away.
Costs and Limits: What Is Free and What Is Not
The library is free. The Hub's public models, datasets and Spaces are free to browse and download, and small models run free on your own computer — enough to learn, build prototypes, and run real tools. Costs begin with computer power: a graphics card if you buy one, or cloud rental by the hour, and the price rises steeply with model size. A dedicated endpoint running a large model costs real money every hour it stays up.
The honest limits are worth stating plainly. First, it is a developer tool: no graphical interface, no chat window. If you do not write Python, use Ollama, a Space, or an app built on top of it. Second, it moves fast, which means breaking changes: the v5 pipeline removals and the unified cache API in v5.24.0 mean code written a year ago may need updating. Third, it is a big dependency: installing it pulls in PyTorch, itself gigabytes, and version conflicts frustrate beginners. Fourth, models are gigabytes to download — a 7-billion model is about 14 gigabytes in full precision. Finally, the limit that belongs to the models: a model is only as good as its training data, and Transformers will happily run a bad, biased or outdated model with the same ease as a good one. The library does not check quality or bias — that judgement is yours.
Transformers vs Ollama vs LangChain vs llama.cpp
Transformers is often confused with the tools around it. Each does a different job.
| Transformers | Ollama | LangChain | llama.cpp | |
|---|---|---|---|---|
| What it is | Python library for loading, running and training models | App for running chat models locally | Framework for chaining models into applications | Runtime for running GGUF models fast on CPU and GPU |
| Who it is for | Developers and researchers | Anyone who wants a local chatbot | Developers building AI apps | Developers and power users |
| Needs coding? | Yes, Python | No, command line or app | Yes, Python or JavaScript | Mostly command line |
| Trains models? | Yes, Trainer and fine-tuning | No | No, it calls models | No |
| Model formats | safetensors and PyTorch, plus export to GGUF and ONNX | GGUF | Any, through providers | GGUF |
| Licence | Apache 2.0, genuinely open source | MIT, genuinely open source | MIT, genuinely open source | MIT, genuinely open source |
| Best for | Building and training with any model | Chatting locally, simply | Apps with memory, tools and retrieval | Fast local inference on weak hardware |
Use them together. Load, test and fine-tune a model in Transformers, export it to GGUF, run it in Ollama or llama.cpp for cheap local use, and build an application around it with LangChain — retrieval over your documents, tool use, memory. If you only want to chat with a model on your laptop, start with Ollama, covered on Tech Know on 13 November 2026. To understand how AI models work, or build something original, start here.
Who Should Use It, and Who Should Not
Transformers is worth learning if you write Python and want to work with AI models directly — as a student, developer, researcher, or hobbyist. It is the standard skill for the field: job listings routinely name it, tutorials assume it, and almost every open model loads through it. To fine-tune a model on your own data or understand what a model is doing, there is no better place to start, and it is free.
It is not the right starting point if you do not code. A non-developer who wants a local chatbot should use Ollama; one who wants to try a model should open its Space on the Hub. It is also not the tool for production serving at scale on its own — pair it with a serving engine such as vLLM, or use a hosted endpoint. And it is not a shortcut around learning: the library removes boilerplate, but it still expects you to understand tokenization, training and evaluation.
How to Try Transformers Safely
Trying Transformers takes an afternoon and costs nothing. Install Python 3.11 or newer, create a virtual environment, and install the library with its PyTorch support. Then run the three-line sentiment pipeline from the official documentation. Then try a second pipeline — speech recognition with a small Whisper model, or image classification — and notice how little changes: the task name and the input, and nothing else. Three safety habits: only load models from sources you trust, and never enable remote code for a model you have not inspected; read the model card and licence before commercial use; and mind your disk — models are gigabytes, so start small, with DistilBERT for text or a tiny Whisper model for speech.
Frequently Asked Questions
Is Transformers really free?
Yes. The library is free under Apache 2.0, with no account, no subscription and no paid tier. Costs, where they exist, are for computer power — your hardware or rented cloud GPUs — not for the software. Public models, datasets and Spaces on the Hub are also free, subject to each model's own licence.
What is the difference between Transformers and Hugging Face?
Hugging Face is the company and the platform — the Hub hosting models, datasets and Spaces, plus the libraries. Transformers is one library from that company: the one that loads, runs and trains models.
Do I need a graphics card to use Transformers?
Not for small models. A classifier such as DistilBERT runs on an ordinary laptop CPU in well under a second. A 7-billion-parameter chat model needs a graphics card or a cloud service.
What is the licence, exactly?
The library is Apache License 2.0 — genuinely open source, free for commercial use, with a patent grant. Each model on the Hub has its own licence, and some are restrictive. Read the model card before commercial use.
What is a pipeline?
A pipeline wraps preprocessing, the model and post-processing into one callable object. Name a task, such as text-classification, and it handles the tokenizer, the model and the output.
What is the difference between a tokenizer and a model?
The tokenizer turns raw input into numbers the model can process, and turns its output back into text or labels. The model is the neural network doing the work. They must always match.
Can Transformers train a model?
Yes. The Trainer class handles the training loop, and fine-tuning a pretrained model on your own data is the most common pattern. Full training from scratch is out of reach for individuals, but fine-tuning a small model is realistic on a single consumer graphics card.
What is safetensors, and why does it matter?
Safetensors is the format most Hub models now use for their weights: a JSON header plus a flat data buffer, instead of Python's pickle format, which can run arbitrary code when loaded. Loading a safetensors file cannot execute code.
Why do some old tutorials not work with version 5?
Version 5 removed several older pipelines — question-answering, summarization, translation, image-to-text, visual-question-answering and image-to-image — and v5.24.0 replaced the older cache parameters with a single cache parameter.
Should I use Transformers or Ollama?
It depends on your goal. To chat with a model on your computer with no coding, use Ollama. To build with models, compare them, fine-tune them, or understand how they work, use Transformers. Many people use both: Transformers to prepare and train, Ollama to run the result cheaply.
The Bottom Line
Transformers is the quiet infrastructure underneath the entire modern AI boom. It has no chat window and will not impress anyone in a demo — but nearly every model you have heard of loads through it, over 1 million Hub checkpoints use it, and it has been downloaded more than 3 billion times. It is free under Apache 2.0, developed at roughly a release a week, and v5.24.1 from 24 November 2026 supports the newest model families.
The verdict is straightforward. If you write Python and want to work with AI models, learn Transformers: it is the standard tool, and the free ecosystem around it is enough to learn, build and ship real things. Start with pipelines and small models, read every model card and licence before commercial use, never enable remote code you do not trust. Models will keep changing — a new family arrives every week — but the interface for using them has stayed the same for eight years, and that stability is why this library, of all the projects in this GitHub series, is the one the whole field is built on.
By Umar Farooq, Tech Know.


0 Comments