Check my levelCoursesProgramsFor teamsPricing
UKSign inSign up
Check my levelCoursesProgramsFor teamsPricingClaude quizPromptsBlogFAQSearchSign upUK
AcademlCoursesHugging Face LLM Course: Practical TransformersPipeline API: Run Models in Three Lines
LoRA tuning: a large weight matrix plus two thin onesThe ollama run command and a VRAM gauge the model fits intoA shelf of open-weight models: DeepSeek, Qwen, Mistral, Llama
Course

Hugging Face LLM Course: Practical Transformers

Module 1 · Transformers and Tokenization
01Pipeline API: Run Models in Three Lines02Tokenization: BPE, WordPiece, SentencePiece03Hugging Face Hub: Finding and Downloading Models
Module 2 · Fine-Tuning
04Dataset Preparation: load_dataset and Tokenization05Trainer API: Fine-Tuning a Classifier06PEFT and LoRA: Fine-Tuning Without Full Training
Module 3 · Advanced Capabilities
07Hugging Face Inference Providers: Serverless Inference08Gradio + Spaces: Deploy an ML Demo in 10 Minutes09vLLM + smolagents: Inference Server and Tool-Using Agents
Hugging Face LLM Course: Practical Transformers · Lesson 1

Pipeline API: Run Models in Three Lines

Hugging Face pipeline() lets you run NLP tasks without knowing the model's architecture, and with a chat model it handles generation, summarization and translation in messages format (transformers 5).

35 min readUpdated Nov 23, 20262 questions in quizReady prompt included

What is pipeline

pipeline() handles model selection, tokenization, and post-processing automatically. The examples below target transformers 5 (5.24.0 is current as of November 21, 2026). Version 5 is PyTorch-only and needs Python 3.11 or newer: pip install -U transformers torch.

from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
import torch

clf = pipeline("sentiment-analysis")
print(clf("This library is amazing!"))  # [{'label': 'POSITIVE', 'score': 0.9998}]
print(clf("This library is amazing!", top_k=None))  # probabilities for every class

model_name = "distilbert/distilbert-base-uncased-finetuned-sst-2-english"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSequenceClassification.from_pretrained(model_name)
inputs = tokenizer("I love transformers!", return_tensors="pt")
with torch.no_grad():
    logits = model(**inputs).logits
print(model.config.id2label[logits.argmax(-1).item()])

zs = pipeline("zero-shot-classification", model="facebook/bart-large-mnli")
print(zs("Python is a language", candidate_labels=["tech", "sport", "food"]))

The rest of this lesson opens after a free sign-up

Sign up with email or Google: the first two lessons of every course stay open for good, and the whole catalog is open for 7 days. No card needed.

Sign up freeOr a trial lesson, no sign-up →
In this lesson
What is pipelineText Generation: Chat ModelsSummarization, Translation and Question AnsweringSupported TasksPracticeReady promptQuiz
CoursesLLM coursesFor teamsPricingFAQBlogAboutPrivacy
© 2026 AcademlDevelopment & promotion —MMIX — Marketing Mix
Get started free