Master the `pipeline()` function to run pre-trained transformer models for text tasks—sentiment analysis, named entity recognition, fill-mask, and zero-shot classification—without ML expertise. Build four independent Python scripts that leverage Hugging Face's model hub and PyTorch backend to solve real-world NLP problems in just a few lines of code.
Hugging Face transformers is a Python library that gives you a unified interface to thousands of pre-trained machine learning models for tasks like text classification, entity extraction, and language understanding. Before libraries like this existed, using a neural network model meant understanding its architecture, loading matching weights, writing preprocessing code to convert text into numbers the model understands (tokenization), running the model, and then writing postprocessing code to turn raw numeric output back into something readable. That is a lot of ML-specific knowledge just to get a prediction.
The pipeline() function collapses all of that into a few lines of code. You pick a task, optionally pick a model, and call the pipeline object with your input. You get back a readable result — a label, a score, a list of entities, predicted words — with no need to understand what happens inside the model. This course is built entirely around that one function, applied to four different tasks.
You do not need to know what a neural network layer is, how a model is trained, or how tokenization works internally. This course treats the model as a black box you configure and call. You are a Python developer consuming an API, not a machine learning engineer building one.
Every pipeline follows the same shape regardless of the task:
The pipeline function hides tokenization, model inference, and result formatting behind a single call.
You will call pipeline(task, model="...") where task is a string like "sentiment-analysis" and model is the name of a specific pre-trained model hosted on the Hugging Face Hub (an online repository of models, similar in spirit to how PyPI hosts Python packages). The first time you reference a model name, transformers downloads its weights and configuration files and caches them locally, typically under ~/.cache/huggingface. Every subsequent run reuses the cached copy, so only the first run per model incurs a download delay.
A "model" here means a specific set of pre-trained weights — the result of someone else having already trained a neural network on a large dataset for a specific kind of task. Models vary enormously in size, from tens of millions to many billions of parameters. If you let pipeline() pick a default model, you sometimes get one that is large, slow to download, and slow to run on a laptop CPU. This course always names an explicit, small model for every task so that examples run quickly without a GPU.
transformers does not execute neural network computations itself — it delegates that to a backend deep learning framework. This course uses PyTorch, specifically the CPU-only build, since none of the examples require or benefit from a GPU at this scale. You will install this backend during project setup before writing any pipeline code.
By the end of this course you will have written four independent, complete Python scripts, each demonstrating one task through the pipeline API:
[MASK]) in a sentence.Each lesson after project setup follows the same pattern: a short explanation of the task, a complete runnable script naming a small model, the terminal commands to run it, and an explanation of the output. Here is the project layout you will end up with:
hf-pipelines-course/
├── venv/ # virtual environment (created in setup)
├── requirements.txt # transformers + torch CPU build
├── 01_verify_install.py # setup verification script
├── 02_sentiment_analysis.py
├── 03_named_entity_recognition.py
├── 04_fill_mask.py
└── 05_zero_shot_classification.py
Each numbered file is self-contained: you can run any one of them on its own once the virtual environment is set up, without needing to have run the others first.