1 / 11
Learn modern natural language processing with transformers by building a real system on an ordinary CPU: tokenizers, pipelines, model anatomy, the Hugging Face Hub and datasets library, honest baselines, fine-tuning DistilBERT with Trainer and plain PyTorch, evaluation and error analysis, named…
Classify, Extract, Search, and Serve Text with Hugging Face
Read before you buy: the PDF here is a free sample — the first 20 pages of the 445-page book (payments, sales and reviews on this demo site are sample data). Get the full e-book at thenexbooks on Gumroad.
Turn piles of text into working features — classify it, extract from it, search it, and serve it — with transformers that run on your laptop.
Every business that talks to customers collects text: reviews, chat messages, emails, tickets. Transformer models make it possible for one developer to sort that text by meaning, pull out the details that matter, and find the right answer in a policy document. The hard part is not getting a model to run; it is choosing the right model, knowing whether it really works, and shipping it responsibly.
This book teaches that practical skill set with the Hugging Face stack. You build one complete system step by step, every model is measured against honest baselines, and every example is sized to finish in minutes on a CPU — no GPU required.
What's inside
- How transformers handle language, what they are good at, and when a simpler model is the better choice
- Tokenization in depth: WordPiece, BPE, and SentencePiece, special tokens, padding, truncation, attention masks, offsets, and training your own tokenizer
- Ready-made pipelines for sentiment, zero-shot classification, entities, fill-mask, and generation — and what changed in recent library versions
- Model anatomy: embeddings, self-attention, transformer blocks, and how encoders, decoders, and encoder-decoders differ
- The Hugging Face Hub and datasets library: model cards, licenses, caching, offline use, mapping, splitting, and cleaning text
- Baselines first: majority class, TF-IDF with logistic regression, and evaluation splits that do not leak
- Fine-tuning DistilBERT with Trainer, then rebuilding the training loop in plain PyTorch
- Evaluation that tells the truth: accuracy, macro-F1, confusion matrices, error analysis, calibration, and challenge sets
- Small data, class imbalance, messy labels, hyperparameters, reproducibility, and experiment tracking
- Named entity recognition for room numbers, dates, times, and requested items; extractive question answering; summarization and translation
- Sentence embeddings, semantic search, re-ranking, duplicate detection, multilingual queries, and clustering feedback into topics
- Production: ONNX export, int8 quantization, batching, a validated FastAPI service, monitoring and drift, privacy, and fairness
One running example, start to finish. You build the Copperline Guest Router for Copperline Hotels, a fictional group of three hotels. Guest reviews, app chats, and emails are routed to housekeeping, maintenance, the front desk, billing, food and beverage, or the concierge; room numbers, dates, times, and requested items are extracted automatically; guest questions are matched to hotel policies; and the whole thing runs as a fast, quantized API. The 1,200 guest messages come from a seeded generator printed in the book, so you can reproduce every number yourself.
Current and honest. The book uses recent versions of Transformers, Datasets, sentence-transformers, PyTorch, ONNX Runtime, and FastAPI, and points out where APIs changed. Results come from real, small CPU runs and are labeled as such — no invented benchmarks or statistics. When a simple TF-IDF baseline beats a transformer, the book shows it and explains why. Every chapter includes runnable code, Tips, Notes, Warnings, exercises, and Key Takeaways, and the appendices give you a cheat sheet, templates and reference tables, a production checklist, and a glossary.
Format: PDF, 445 pages (A4), linked table of contents and bookmarks. English. First Edition, 2026. Published by thenexbooks. Requires Python 3 and a computer that can run PyTorch on a CPU. This book is independent and is not affiliated with, sponsored by, or endorsed by Hugging Face or any other company mentioned.
Table of Contents
Part I — Foundations
- Ch 1 · Transformers for Language: What They Do and How This Book Works
- Ch 2 · Setting Up: Python, PyTorch, Hugging Face, and the Copperline Dataset
- Ch 3 · Tokenization: From Text to Token IDs
- Ch 4 · Tokenizer Families: WordPiece, BPE, SentencePiece, and Training Your Own
- Ch 5 · Pipelines: Ready-Made NLP in a Few Lines
Part II — Models and Data
- Ch 6 · Model Anatomy: Embeddings, Attention, and Transformer Blocks
- Ch 7 · Encoders, Decoders, and Encoder-Decoders
- Ch 8 · The Hugging Face Hub: Model Cards, Licenses, Caching, and Offline Use
- Ch 9 · The datasets Library: Loading, Mapping, Splitting, and Cleaning Text
- Ch 10 · Baselines and Honest Evaluation Splits
Part III — Fine-Tuning Classifiers
- Ch 11 · Fine-Tuning DistilBERT with Trainer: The Copperline Router
- Ch 12 · Under the Hood: A Training Loop in Plain PyTorch
- Ch 13 · Evaluating Classifiers: Metrics, Confusion Matrices, and Error Analysis
- Ch 14 · Small Data, Imbalance, and Messy Labels
- Ch 15 · Hyperparameters, Reproducibility, and Experiment Tracking
Part IV — Beyond Classification
- Ch 16 · Named Entity Recognition: Extracting Request Details
- Ch 17 · Extractive Question Answering over Hotel Policies
- Ch 18 · Summarization and Translation with Encoder-Decoder Models
- Ch 19 · Zero-Shot Classification: Routing Without Labels
- Ch 20 · Text Generation and Decoding Strategies
Part V — Embeddings and Search
- Ch 21 · Sentence Embeddings with sentence-transformers
- Ch 22 · Semantic Search, Re-Ranking, and Duplicate Detection
- Ch 23 · Multilingual Text: One Model for Many Languages
- Ch 24 · Clustering and Topic Discovery in Guest Feedback
Part VI — Production
- Ch 25 · Efficient Inference: ONNX, Quantization, and Batching
- Ch 26 · Serving NLP Models with FastAPI
- Ch 27 · Responsible NLP in Production: Monitoring, Drift, Privacy, and Fairness
- Ch 28 · Case Study: The Complete Copperline Guest Router
Appendices
A · NLP with Transformers Cheat Sheet
B · Templates and Reference
C · Production Checklist
D · Glossary
Book details
| Detail | |
|---|---|
| Pages | 445 |
| Format | PDF (A4) |
| Language | English |
| Level | Beginner to Intermediate |
| Edition | 1st Edition (2026) |
| Download on this site | Free sample, first 20 pages (PDF) |
| Publisher | thenexbooks |
Files you get
No reviews yet. Only buyers can review.
More from thenexbooks