liveBook · Manning

What you will learn in Transformers in Action

by Nicole Koenigstein
Foreword by Luis Serrano

Chapter by chapter

Chapter 1: The need for transformers

1.1 The transformers breakthrough · 1.1.1 Translation before transformers · 1.1.2 How are transformers different? · 1.1.3 Unveiling the attention mechanism · 1.1.4 The power of multihead attention · 1.2 How to use transformers · 1.3 When and why to use transformers · 1.4 From transformer to LLM: The lasting blueprint · 1.5 Summary

What you learn in chapter 1 →

Chapter 2: A deeper look into transformers

2.1 From seq-2-seq models to transformers · 2.1.1 The difficulty of training RNNs · 2.1.2 Introducing attention mechanisms · 2.1.3 Vanishing gradients: Transformer to the rescue · 2.1.4 Exploding gradients: When large gradients disrupt training · 2.2 Model architecture · 2.2.1 Encoder and decoder stacks · 2.2.2 Positional encoding · 2.2.3 Attention · 2.2.4 Position-wise FFNs · 2.3 Summary

What you learn in chapter 2 →

Chapter 3: Model families and architecture variants

3.1 Decoder-only models · 3.2 The decoder-only architecture · 3.3 Encoder-only models · 3.3.1 Masked language modeling as a pretraining strategy · 3.4 Embedding models and RAG · 3.4.1 What is an embedding? · 3.5 MoE in LLMs · 3.5.1 How MoE works · 3.6 Summary

What you learn in chapter 3 →

Chapter 4: Text generation strategies and prompting techniques

4.1 Decoding and sampling methods for text generation · 4.1.1 Greedy search decoding for text generation · 4.1.2 Beam search decoding for text generation · 4.1.3 Top-k sampling for text generation · 4.1.4 Nucleus sampling for text generation · 4.1.5 Temperature sampling for text generation · 4.2 The art of prompting · 4.2.1 Zero-shot prompting · 4.2.2 One- and few-shot prompting · 4.2.3 CoT prompting · 4.2.4 Structured CoT with Instructor · 4.2.5 Contrastive CoT prompting · 4.2.6 CoVe prompting · 4.2.7 ToT prompting · 4.2.8 ThoT prompting · 4.3 Summary

What you learn in chapter 4 →

Chapter 5: Preference alignment and retrieval-augmented generation

5.1 Reinforcement learning from human feedback · 5.1.1 From MDP to reinforcement learning · 5.1.2 Improving models with human feedback and reinforcement learning · 5.2 Aligning LLMs with direct preference optimization · 5.2.1 The SFT step · 5.2.2 Training the LLM with DPO · 5.2.3 Running the inference on the trained LLM · 5.2.4 Optimized versions for DPO · 5.2.5 Group Relative Policy Optimization · 5.3 MixEval: A benchmark for robust and cost-efficient evaluation · 5.4 Retrieval-augmented generation · 5.4.1 A first look at RAG · 5.4.2 Why and when to use RAG · 5.4.3 Core components and design choices · 5.5 Summary

What you learn in chapter 5 →

Chapter 6: Multimodal models

6.1 Getting started with multimodal models · 6.2 Combining modalities from different domains · 6.3 Modality-specific tokenization · 6.3.1 Images and visual embeddings · 6.3.2 Image analysis with an MLLM · 6.3.3 From image patches to video cubes · 6.3.4 Video information extraction · 6.3.5 Audio embeddings · 6.3.6 Audio-only pipeline: Extraction and inference · 6.4 Multimodal RAG: From PDF to images, tables, and cross-model comparison · 6.5 Summary

What you learn in chapter 6 →

Chapter 7: Efficient and specialized small language models

7.1 The power of small · 7.2 Small models as agents in a system of specialists · 7.3 Classification with SLMs · 7.3.1 Evaluating classification performance · 7.3.2 Accuracy and the F1-score · 7.3.3 Fine-tuning SLMs on the Financial PhraseBank dataset · 7.4 Adapting Gemma 3 270M for empathy and prosocial tone · 7.5 Adapting Gemma 3 270M for English–Spanish translation · 7.6 Broader use cases and complementary models · 7.7 Summary

What you learn in chapter 7 →

Chapter 8: Training and evaluating large language models

8.1 Deep dive into hyperparameters · 8.1.1 How parameters and hyperparameters factor into gradient descent · 8.2 Model tuning and hyperparameter optimization · 8.2.1 Tracking experiments · 8.3 Parameter-efficient fine-tuning LLMs · 8.3.1 Low-rank adaptation · 8.3.2 Weight-decomposed low-rank adaptation · 8.3.3 Quantization · 8.3.4 Efficient fine-tuning of quantized LLMs with QLoRA · 8.3.5 Quantization-aware low-rank adaptation · 8.3.6 Low-rank plus quantized matrix decomposition · 8.3.7 Bringing it all together: Choosing the right PEFT strategy · 8.4 Summary

What you learn in chapter 8 →

Chapter 9: Optimizing and scaling large language models

9.1 Model optimization · 9.1.1 Model pruning · 9.1.2 Model distillation · 9.2 Sharding for memory optimization · 9.3 Inference optimization · 9.4 GPU-level optimization: Tiling, threads, and memory · 9.4.1 FlashAttention: Tiled attention at scale · 9.5 Extending long-context windows · 9.5.1 Rotary embeddings and refinements · 9.5.2 Refinements: YaRN, positional interpolation, and iRoPE · 9.6 Summary

What you learn in chapter 9 →

Chapter 10: Ethical and responsible large language models

10.1 Understanding biases in LLMs · 10.1.1 Identifying bias · 10.1.2 Model interpretability and bias in AI · 10.2 Transparency and explainability of LLMs · 10.2.1 Using Captum to analyze the behavior of generative language models · 10.2.2 Using local interpretable model-agnostic explanations to explain a model prediction · 10.3 Responsible use of LLMs · 10.3.1 The foundation model transparency index · 10.4 Safeguarding your language model · 10.4.1 Jailbreaks and lifecycle vulnerabilities · 10.4.2 Shielding your model against hazardous abuse · 10.5 Summary

What you learn in chapter 10 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.