Book Profile
Natural Language Processing with Transformers Building Language Applications with Hugging Face
Lewis Tunstall, Leandro von Werra · 2022
A hands-on guide for data scientists and machine learning engineers to build, train, and optimize state-of-the-art language applications using transformer models with the Hugging Face ecosystem.
Get the book →For any data scientist or ML engineer who wants to leverage the revolutionary power of transformer models but feels overwhelmed by their complexity, 'Natural Language Processing with Transformers' provides a clear, practical, and hands-on path to mastery. Written by core contributors at Hugging Face, this book demystifies architectures like BERT and GPT, guiding you through the entire lifecycle of an NLP project. You'll learn to use the Hugging Face ecosystem—Transformers, Datasets, Tokenizers, and Accelerate—to tackle real-world tasks like text classification, named entity recognition, question answering, and text generation. More than just fine-tuning, the book dives into critical production concerns, teaching you how to make models smaller and faster with distillation and quantization, how to handle multilingual data or scenarios with few labels, and even how to train a large language model from scratch on a custom dataset. This is the definitive guide to building production-ready language applications with the coolest technology around.
What it argues
This model outlines the process of building successful, production-ready NLP applications using transformer models, as detailed in the book. It shows how applying specific techniques and tools from the Hugging Face ecosystem (Design Levers) enhances model and process characteristics (Mediators), leading to improved application performance and production viability (Outcomes).
Key ideas it contributes
- Use of Pretrained Models — The practice of initializing a model with weights from a transformer that has already been trained on a massive, general-domain text corpus, thereby transferring learned linguistic knowledge to a new task.
- Domain Adaptation — The intermediate step of continuing the self-supervised pretraining of a language model on a corpus of unlabeled text from the target domain, before fine-tuning on the final supervised task.
- Task-Specific Fine-Tuning — The process of adapting a pretrained language model to a new supervised task by adding a task-specific head (e.g., a classification layer) and training it on a labeled dataset.
- Data and Tokenizer Quality — The quality of the input pipeline, encompassing the cleanliness and representativeness of the dataset and the suitability of the tokenizer for the specific language and domain.
- Model Compression Techniques — A collection of methods designed to reduce the computational and memory requirements of a trained model, such as its size on disk and its inference latency.
- Appropriate Decoding Strategy — For generative tasks, this is the algorithm and set of hyperparameters used to select a sequence of tokens from the probabilistic output of the language model.
- Scalable Training Infrastructure — The use of a hardware and software stack capable of distributed training, allowing a training process to be parallelized across multiple compute units like GPUs.
- Model Efficiency — The performance of a model in terms of computational resources required for inference. Highly efficient models have low latency and a small memory footprint.