About This Book
Welcome to Hands-On Large Language Models by Jay Alammar and Maarten Grootendorst — a comprehensive guide to understanding and building with Large Language Models through nearly 300 custom-made figures and hands-on code examples. This documentation provides a companion to the book, making it easier to navigate chapters, run code examples, and explore advanced topics.All examples are designed to run on Google Colab with a free T4 GPU (16GB VRAM). You can also run them on any cloud provider or local setup.
What You’ll Learn
LLM Fundamentals
Understand how language models work, from tokens and embeddings to transformer architecture
Text Understanding
Learn text classification, clustering, and topic modeling with modern LLMs
Text Generation
Master prompt engineering and advanced generation techniques
Fine-Tuning
Create custom embedding models and fine-tune BERT and generation models
Key Features
Visual Learning Approach
Visual Learning Approach
Nearly 300 custom illustrations make complex LLM concepts accessible and easy to understand. Our visual teaching style has been praised by leaders in the field.
Hands-On Code Examples
Hands-On Code Examples
Every chapter includes working Jupyter notebooks with real code using PyTorch, Transformers, and sentence-transformers. All examples are tested and ready to run.
Comprehensive Coverage
Comprehensive Coverage
From basic tokens and embeddings to advanced topics like fine-tuning, RAG, multimodal models, and more. Plus bonus visual guides on cutting-edge topics.
Production-Ready Techniques
Production-Ready Techniques
Learn practical techniques you can apply immediately, including semantic search, Retrieval-Augmented Generation, and model optimization.
Book Structure
The book is organized into 12 chapters covering the full spectrum of LLM development:Foundations
- Chapter 1: Introduction to Language Models
- Chapter 2: Tokens and Token Embeddings
- Chapter 3: Looking Inside Transformer LLMs
Text Understanding & Generation
- Chapter 4: Text Classification
- Chapter 5: Text Clustering and Topic Modeling
- Chapter 6: Prompt Engineering
- Chapter 7: Advanced Text Generation Techniques
Advanced Applications
- Chapter 8: Semantic Search and RAG
- Chapter 9: Multimodal Large Language Models
Model Development
- Chapter 10: Creating Text Embedding Models
- Chapter 11: Fine-Tuning BERT for Classification
- Chapter 12: Fine-Tuning Generation Models
Get Started
Setup Your Environment
Install dependencies and set up your development environment
Prerequisites
Review the required background knowledge and tools
Explore Chapters
Jump into the first chapter and start learning
Advanced Topics
Explore bonus visual guides on cutting-edge topics
Praise for the Book
“Jay and Maarten have continued their tradition of providing beautifully illustrated and insightful descriptions of complex topics in their new book.” — Andrew Ng, founder of DeepLearning.AI
“This is an exceptional guide to the world of language models and their practical applications in industry.” — Nils Reimers, Director of ML at Cohere
“I can’t think of another book that is more important to read right now.” — Josh Starmer, StatQuest
Community & Resources
- GitHub Repository: HandsOnLLM/Hands-On-Large-Language-Models
- Purchase the Book: Available on Amazon, O’Reilly, and other retailers
- DeepLearning.AI Course: How Transformer LLMs Work
