Natural Language Processing with Transformers
Building Language Applications with Hugging Face
Synopsis
Written by Lewis Tunstall, Leandro von Werra and Thomas Wolf, three contributors to the Hugging Face ecosystem, this book teaches transformer models through code built on the Transformers, Datasets and Tokenizers libraries. After an introduction to the encoder-decoder architecture, attention and transfer learning, each chapter centers on a realistic task: classifying the emotions expressed in tweets, recognizing named entities across several languages, generating text with different decoding strategies, summarizing dialogue, and building a question-answering system over product reviews. A chapter on transformer anatomy implements the architecture's components from scratch in PyTorch so that readers understand what the library abstracts.
Later chapters address problems practitioners meet after a first prototype. The authors show how to shrink and speed up models through knowledge distillation, quantization, pruning and ONNX export, how to cope with scarce labeled data using zero-shot and few-shot techniques, and how to train a code-generating model from scratch, including building a tokenizer and handling large-scale data. A closing chapter surveys scaling laws and multimodal directions as they stood in 2022. Companion Jupyter notebooks run on cloud GPUs. Readers gain practical fluency with the Hugging Face stack and a working understanding of why transformers succeed, though some of the code now needs updating.
Scorecard
Editorial score
How it scored
Editorial score: 77.5 / 1005 weighted criteria
- 22.5/30
Influence30%
- 22.5/25
Authority25%
- 16.0/20
Practical value20%
- 9.0/15
Currency15%
- 7.5/10
Readability10%
- 77.5/100
Editorial score
How the rank was computed
Rank No. 151 of 500 comes from a composite of 59.6: observable signals 24.7 of 55 points plus editorial review 34.9 of 45 points.
All 11 inputs
| Input | Points |
|---|---|
| Observable signals | 24.7/55 |
| Reach (Amazon ratings volume) | 8.9/16.5 |
| Consensus across best-of lists | 8.3/13.8 |
| Awards and bestseller evidence | 0.0/8.3 |
| Reader rating, sample-adjusted | 6.6/8.3 |
| Amazon sales rank | 0.9/5.5 |
| Recency | 0.0/2.8 |
| Editorial review | 34.9/45 |
| Author authority | 10.1/11.3 |
| Influence | 10.1/13.5 |
| Practical value | 7.2/9.0 |
| Readability | 3.4/4.5 |
| Currency | 4.1/6.8 |
Each criterion is scored from 1 to 10 and weighted, and the points add up to the editorial score. The rank combines observable signals (55 percent) with this score (45 percent). Read the methodology.
Verdict
Hugging Face's own developers teach transformer NLP through clear, working projects, though the fast-moving library has outpaced parts of the code.
Strengths
- Written by core Hugging Face library contributors
- Task-driven chapters with runnable companion notebooks
- Covers deployment efficiency, not only modeling
Keep in mind
Predates the instruction-tuned chat models that followed ChatGPT, and its repository notes untested TensorFlow code and an unmaintained question-answering chapter.
Key takeaways
- Transfer learning lets practitioners fine-tune a pretrained transformer for a new task with modest data and compute instead of training from scratch.
- Implementing self-attention and the encoder and decoder blocks by hand demystifies what high-level library calls are doing internally.
- Production deployment depends on efficiency: distillation, quantization and pruning can cut latency and model size with limited accuracy loss.
- When labels are scarce, zero-shot classification, data augmentation and domain adaptation can deliver usable models before investing in annotation.
Notable facts
- The official companion notebook repository on GitHub has roughly 4,800 stars. Source (opens in a new tab)
- The authors began the project around 2019 after cold-emailing Thomas Wolf, and the writing took about a year and a half. Source (opens in a new tab)
About the author
Questions
What is Natural Language Processing with Transformers about?
Is Natural Language Processing with Transformers still worth reading in 2026?
Who should read Natural Language Processing with Transformers?
Related books
- Deep Learning Christopher M. Bishop and Hugh Bishop
- Deep Learning Ian Goodfellow, Yoshua Bengio and Aaron Courville
- Deep Learning for Coders with fastai and PyTorch Jeremy Howard and Sylvain Gugger
- Understanding Deep Learning Simon J. D. Prince
- Speech and Language Processing Daniel Jurafsky and James H. Martin
- Dive into Deep Learning Aston Zhang, Zachary C. Lipton, Mu Li and Alexander J. Smola
Sources
As an Amazon Associate, Best AI Books earns from qualifying purchases. Best AI Books is sponsored by Iternal.ai, whose founder and CEO, John Byron Hanby IV, wrote The AI Strategy Blueprint, our #1 ranked book. How we rank books.






