Hugging Face in 2026: The Beginner’s Guide to the Most Important ML Platform
It’s Monday morning and someone hands you 5,000 customer support tickets with one instruction: sort the angry ones from the rest by Friday. No labeled dataset. No GPU budget. No time to read three research papers first.
A few years ago that was a multi-week project. Today it’s a few lines of Python, because someone already trained a model that understands English and put it online for free. The place that happened is Hugging Face.
This Hugging Face transformers tutorial takes you from zero to a fine-tuned model. By the end you’ll have loaded a model from the Hub, run it through a pipeline, looked under the hood at the tokenizer, loaded a dataset, and fine-tuned a model on your own examples. Not just read about it. Done it.
If you’ve already worked through the scikit-learn tutorial, you know how a consistent API makes a library learnable. Hugging Face applies the same idea to deep learning. And if you’re still deciding which framework sits underneath, the TensorFlow vs PyTorch comparison matters more than it used to, because Transformers v5 is built around PyTorch alone.
Table of Contents
What Is Hugging Face? The Hub, the Library, and Why Both Matter
People say “Hugging Face” and mean three different things, which is the first source of confusion for beginners.
The Hub is a website that hosts models, datasets, and demo apps in Git-based repositories, a bit like GitHub for machine learning. The Transformers library is the Python package that downloads and runs those models. And Spaces hosts small apps so you can share a working demo with a link. You can use any one without the others, but they’re designed to snap together.
The scale explains why this is the default starting point. When Hugging Face announced Transformers v5 in December 2025, it reported more than 3 million pip installs per day, support for over 400 model architectures, and more than 750,000 compatible checkpoints on the Hub [3]. The Hub itself kept growing through 2026: public model repositories went from roughly 2.43 million in January to about 2.96 million in August, according to Hugging Face’s State of Open Models report [4].
Definition: Hugging Face is an open-source platform and company that hosts pre-trained machine learning models, datasets, and demo apps on a shared Hub, and maintains the Transformers library for loading and running those models in Python. Its core idea is transfer learning: instead of training from scratch, you start from a model someone else already trained and adapt it.
That idea, starting from a pre-trained model, is the reason a laptop can now do work that used to need a research lab. A model like BERT has already read enormous amounts of text. You borrow what it learned about language and spend your own compute only on the narrow task you care about. The original Transformers paper by Wolf et al. describes the goal as exposing state-of-the-art architectures to the wider community through one unified API [1], and that design choice is what makes everything below so short.
Hugging Face Model Hub: How to Find a Model You Can Trust
Before any code, you need to know how to choose a model, because the Hub has millions of them and most won’t help you.
Every model lives in a repository with a model card: a README describing what the model does, what data it was trained on, where it fails, and what license it carries. Read it before you install anything. Three things matter most:
- Task tag. Filter by task (text classification, speech recognition, image classification) so you only see models built for your problem.
- License. Open weights aren’t automatically free for commercial use. The license is on the model card, and it’s a real constraint if you’re building a product.
- Downloads. Downloads measure what people actually run. Likes measure what people find exciting.
That last distinction comes from Hugging Face’s own data. The Summer 2026 report notes that likes flow to frontier models shortly after they ship, while downloads pile up on small, stable models wired into real pipelines [4]. If you want a model that works, sort by downloads.
One more habit worth building: prefer repositories that ship weights in the safetensors format. Unlike older pickle-based files, safetensors stores only tensors, so loading one can’t execute arbitrary code on your machine.
Hugging Face Pipeline: Run Your First Model in Minutes
Install the libraries first. Transformers v5 runs on PyTorch, so you need that too:
pip install -U transformers datasets accelerate torchThen try the pipeline function, the fastest route from zero to a working model:
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
)
tickets = [
"My order arrived broken and nobody answers my emails.",
"Thanks, the replacement showed up a day early!",
]
for text, result in zip(tickets, classifier(tickets)):
print(result["label"], round(result["score"], 3), "|", text)The first call downloads the model weights from the Hub and caches them locally, so it’s slow once and fast afterward. Passing model= explicitly is a good habit. Without it, the pipeline picks a default for the task, and defaults can change between releases. Also note that "sentiment-analysis" is just an alias for the general text-classification task [6].
A pipeline does three jobs in order: it tokenizes your text, runs the model, and converts the raw output into readable labels. The next section opens that box. First, one more pipeline, because it solves the Monday morning problem with no labeled data at all:
from transformers import pipeline
zero_shot = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
result = zero_shot(
"The app crashes every time I open my invoice.",
candidate_labels=["billing", "bug report", "feature request"],
)
print(result["labels"][0], round(result["scores"][0], 3))Zero-shot classification lets you invent the categories at run time. You never trained anything on “billing” or “bug report”, and the model still ranks them. It’s rarely as accurate as a model fine-tuned on your own data, but it’s an excellent baseline to beat.
The same one-line pattern covers text-generation, automatic-speech-recognition, image-classification, token-classification, fill-mask, and more [5]. One v5 detail that will trip you up if you follow older tutorials: the summarization, translation, and text2text-generation pipelines were removed, and the library now points you to text-generation with a chat model instead [6].
Hugging Face Tokenizer and AutoModel: What the Pipeline Hides
Pipelines are great until you need to change something. At that point you need the two objects underneath: the tokenizer and the model.
A tokenizer converts text into the integer IDs a model can read. The model never sees the word “great”. It sees the number that represents a piece of it. Every model is trained with one specific tokenizer, so the pairing is not optional. The Auto classes handle it for you: AutoTokenizer and AutoModelForSequenceClassification read the repository’s configuration and build the right architecture, which is why the same code works across hundreds of different models.
import torch
from transformers import AutoTokenizer, AutoModelForSequenceClassification
checkpoint = "distilbert/distilbert-base-uncased-finetuned-sst-2-english"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
model = AutoModelForSequenceClassification.from_pretrained(checkpoint)
texts = ["I love this library.", "This tutorial lost me."]
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="pt")
with torch.no_grad():
logits = model(**inputs).logits
probs = torch.softmax(logits, dim=-1)
print(model.config.id2label) # which column is which label
print(probs)Two details are worth noticing. model.config.id2label tells you which output column maps to which label, so you never have to guess. And the model returns logits, raw scores, which softmax turns into probabilities that sum to one.
Here’s the mistake that bites almost every beginner: loading a tokenizer from one checkpoint and a model from another. The code runs without complaint. The predictions are quietly wrong, because the IDs the tokenizer produces don’t mean what the model thinks they mean. Always load both from the same checkpoint string.
One v5 note: Hugging Face’s release announcement says it’s dropping the old split between “fast” and “slow” tokenizers in favor of a single tokenizers backend [3]. Older tutorials still treat that as a choice you have to make. It’s no longer something you need to think about.
Hugging Face Datasets: Loading Data Without Writing a Parser
Fine-tuning needs data, and the Hub hosts that too. Public datasets on the Hub passed 1 million in summer 2026, up from about 711,000 in January [4]. The datasets library loads one by name in a single call. It’s backed by Apache Arrow, so large datasets are read from disk instead of being pulled into memory all at once [2].
from datasets import load_dataset
dataset = load_dataset("stanfordnlp/imdb")
print(dataset) # DatasetDict with train, test and unsupervised splits
print(dataset["train"][0]) # one example: a review and its labelThe method you’ll use most is .map(), which applies a function to every example. Pass batched=True when you tokenize so many rows are processed per call, which is dramatically faster than one at a time. For datasets too large to download at all, load_dataset(..., streaming=True) reads examples on the fly.
IMDB arrives with a train and test split already made. When you use your own data, make that split before anything else. The train, validation, and test set post explains why getting it wrong inflates every number you measure afterward.
How to Fine-Tune a Hugging Face Model on Your Own Data
Zero-shot and off-the-shelf models get you surprisingly far. Fine-tuning is what you do when they don’t.
Fine-tuning continues training a pre-trained model on your labeled examples, so it adapts to your vocabulary and your definition of “angry”. The Trainer class handles the training loop, batching, evaluation, and checkpointing so you don’t write them by hand [8].
import numpy as np
from datasets import load_dataset
from transformers import (
AutoTokenizer,
AutoModelForSequenceClassification,
DataCollatorWithPadding,
Trainer,
TrainingArguments,
)
checkpoint = "distilbert/distilbert-base-uncased"
tokenizer = AutoTokenizer.from_pretrained(checkpoint)
dataset = load_dataset("stanfordnlp/imdb")
def tokenize(batch):
return tokenizer(batch["text"], truncation=True)
tokenized = dataset.map(tokenize, batched=True)
train_set = tokenized["train"].shuffle(seed=42).select(range(2000))
eval_set = tokenized["test"].shuffle(seed=42).select(range(500))
model = AutoModelForSequenceClassification.from_pretrained(checkpoint, num_labels=2)
def compute_metrics(eval_pred):
logits, labels = eval_pred
predictions = np.argmax(logits, axis=-1)
return {"accuracy": float((predictions == labels).mean())}
args = TrainingArguments(
output_dir="imdb-distilbert",
num_train_epochs=2,
per_device_train_batch_size=16,
learning_rate=2e-5,
eval_strategy="epoch",
)
trainer = Trainer(
model=model,
args=args,
train_dataset=train_set,
eval_dataset=eval_set,
data_collator=DataCollatorWithPadding(tokenizer),
compute_metrics=compute_metrics,
)
trainer.train()When you run this, you’ll see a warning that some weights were newly initialized. That’s expected. The pre-trained body loads from the checkpoint, and a fresh classification head is added on top. Fine-tuning trains that head and nudges the body along with it.
Two choices keep this beginner-friendly. First, it trains on a 2,000-example slice, so it finishes in minutes on a free cloud GPU instead of hours. Second, it uses DistilBERT, a smaller model distilled from BERT. Its authors report that it keeps about 97% of BERT’s language-understanding performance while being 40% smaller and 60% faster [7].
Watch the evaluation line printed after each epoch. If training loss keeps falling while evaluation accuracy stalls, you’re overfitting. And before you fine-tune anything on a real project, check whether better prompting would do the job for less money. The fine-tuning vs prompt engineering post covers how to decide.
The Trainer runs on PyTorch, which is the practical meaning of v5 going PyTorch-only. If you want the full reasoning behind that shift, the TensorFlow vs PyTorch comparison lays it out. When your model is ready to share, authenticate with a Hugging Face access token and call trainer.push_to_hub().
Hugging Face Spaces and Inference Providers: Sharing What You Built
A model sitting in a notebook helps nobody. Spaces turns it into a link.
A Space is a small hosted app, usually built with Gradio or Streamlit, that runs from a Git repository on the Hub. By August 2026 there were roughly 1.44 million public Spaces, up from about 1 million in January [4]. A minimal Gradio app for the classifier from earlier looks like this:
import gradio as gr
from transformers import pipeline
classifier = pipeline(
"sentiment-analysis",
model="distilbert/distilbert-base-uncased-finetuned-sst-2-english",
)
def predict(text):
result = classifier(text)[0]
return {result["label"]: result["score"]}
demo = gr.Interface(fn=predict, inputs="text", outputs="label")
demo.launch()Save that as app.py, add a requirements.txt listing transformers, torch, and gradio, push both to a new Space, and it’s live at a public URL.
If you’d rather not host the model yourself, Inference Providers lets you call hosted models through a single API, with Hugging Face routing requests to partner inference services [9]. Older tutorials call this the serverless Inference API, so don’t be thrown if the names differ. And for local serving, v5 adds transformers serve, which exposes a model through an OpenAI-compatible API [3].
The Part Most Tutorials Get Backwards
Here’s the contrarian take: most beginners spend their first week hunting for the biggest, newest model and almost no time asking whether a small one already does the job.
Hugging Face’s own usage data points the other way. In the Summer 2026 report, models under 1 billion parameters account for about 83% of all-time downloads, while models above 100 billion account for about 1% [4]. The same report finds that roughly 85.6% of repositories have fewer than 200 lifetime downloads [4]. The Hub is enormous, but the part people actually run is small and concentrated.
That changes the practical advice. Start with a small, well-downloaded model with a clear model card. Get it working end to end: data in, predictions out, metrics measured. Only then ask whether a larger model is worth the cost in latency, memory, and money. Most projects never need to go there.
What usually decides whether a project works isn’t the checkpoint. It’s whether your labels are clean, whether your evaluation is honest (the cross-validation post is specific about this), and whether the model’s license allows what you’re building. Those three are boring, and they’re where projects actually fail.
What This Post Skipped
Two things I deliberately left out.
The first is parameter-efficient fine-tuning and quantization: LoRA, QLoRA, and running large models in 4-bit. They’re what make fine-tuning big language models practical on modest hardware, but they belong after you’ve fine-tuned a small model the plain way. The fine-tuning vs prompt engineering post covers when they’re worth reaching for.
The second is everything beyond text: image, audio, and multimodal models. The pipeline pattern in this post carries over directly, so once it feels comfortable, swapping sentiment-analysis for image-classification or automatic-speech-recognition is a small step. Both topics are worth coming back to once the basics stick.
FAQ
Is Hugging Face free to use?
Mostly. The Hub, the Transformers library, and the Datasets library are free and open source, and you can host public models, datasets, and Spaces at no cost. Paid options exist for extra compute, such as upgraded Space hardware and dedicated inference endpoints. Individual models carry their own licenses, which are separate from the cost, so always check the model card before using one commercially.
Do I need a GPU to use Hugging Face?
Not for inference with small models. A pipeline with DistilBERT runs fine on a laptop CPU. Fine-tuning is where a GPU starts to matter. The fine-tuning example in this post is sized to finish in minutes on a free cloud GPU, such as the ones Google Colab offers, and larger models need more memory than most laptops have.
What is the difference between Hugging Face, the Hub, and the Transformers library?
Hugging Face is the company. The Hub is the website where models, datasets, and Spaces are hosted. Transformers is a Python library that downloads and runs the models. You can browse the Hub without the library, and you can use the library with public models without ever creating an account.
Does Hugging Face Transformers still work with TensorFlow?
Transformers v5 focuses on PyTorch as its sole backend, and Hugging Face has said it is sunsetting TensorFlow and Flax support while working with partners in the JAX ecosystem on compatibility. If you are starting now, use PyTorch. If you have older TensorFlow code, pinning to a v4 release is the safe path until you migrate.
Do I need an access token to use Hugging Face models?
Not for public models. You need a token to push your own models or datasets to the Hub, and to download gated models, which require you to accept the publisher’s terms first. Create a token in your Hugging Face account settings and keep it out of your code and your Git history.
You’ve covered the whole workflow: finding a model on the Hub, running it with a pipeline, opening up the tokenizer and model, loading data, fine-tuning, and sharing the result. The next thing to do isn’t read another tutorial. It’s to take a small text problem you actually have, like sorting your own emails or support tickets, and run it through this workflow end to end. That’s the only way the pieces stick together.
Citations
[1] Wolf, T., Debut, L., Sanh, V., Chaumond, J., Delangue, C., Moi, A., … Rush, A. M. (2020). Transformers: State-of-the-Art Natural Language Processing. Proceedings of the 2020 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, 38–45. Available at: https://aclanthology.org/2020.emnlp-demos.6/
[2] Lhoest, Q., Villanova del Moral, A., Jernite, Y., Thakur, A., von Platen, P., Patil, S., … Wolf, T. (2021). Datasets: A Community Library for Natural Language Processing. Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing: System Demonstrations, arXiv:2109.02846. Available at: https://arxiv.org/abs/2109.02846
[3] Hugging Face. (2025, December 1). Transformers v5: Simple model definitions powering the AI ecosystem. Available at: https://huggingface.co/blog/transformers-v5
[4] Hugging Face. (2026). State of Open Models: Summer 2026 Observations. Available at: https://huggingface.co/blog/state-of-open-models-summer-2026
[5] Hugging Face. (2026). Transformers documentation: Pipelines for inference. Available at: https://huggingface.co/docs/transformers/pipeline_tutorial
[6] Hugging Face. (2026). Transformers v5 source code, pipelines/__init__.py (task registry and removed tasks). Available at: https://github.com/huggingface/transformers/blob/main/src/transformers/pipelines/__init__.py
[7] Sanh, V., Debut, L., Chaumond, J., & Wolf, T. (2019). DistilBERT, a distilled version of BERT: smaller, faster, cheaper and lighter. arXiv:1910.01108. Available at: https://arxiv.org/abs/1910.01108
[8] Hugging Face. (2026). Transformers documentation: Fine-tune a pretrained model. Available at: https://huggingface.co/docs/transformers/training
[9] Hugging Face. (2026). Inference Providers documentation. Available at: https://huggingface.co/docs/inference-providers