Source
Telegram: book_cube
Book review from Alexander Polomodov
Hands-On Large Language Models
Authors: Jay Alammar, Maarten Grootendorst
Publisher: O'Reilly Media, Inc.
Length: 428 pages
Jay Alammar and Maarten Grootendorst: visual guide to LLM with ~300 illustrations - tokenization, embeddings, transformers, RAG.
OriginalAbout the authors
The book was written by two ML/AI experts known for their visual explanations of complex concepts:
Jay Alammar
Engineering Fellow at Cohere, author of cult visual guides on ML and NLP. His diagrams are used in NumPy documentation, pandas, and deeplearning.ai courses.
jalammar.github.ioMaarten Grootendorst
Data Scientist, author of open-source libraries BERTopic and KeyBERT. Specialist in topic modeling and embedding.
newsletter.maartengrootendorst.comPhilosophy of the book
The authors follow the approach "intuition is primary": First develops a qualitative understanding of concepts through visualizations, and then reinforces it with formal description and code examples.
~300 original illustrations
Self-attention mechanisms, tokenizers, multidimensional embedding spaces - everything is explained through visual diagrams, graphs and drawings.
All code is available at GitHub.
Related chapter
AI Engineering (Chip Huyen)
An advanced look at production practices: RAG, agents, finetuning
Book structure
The book consists of three parts and 12 chapters: from the basics of LLM to their use for solving problems, and ending with methods for training models.
IUnderstanding Language Patterns
The first part lays the foundation by explaining the structure of language models.
Introduction to Language Models
Evolution from "bag of words" through word embeddings to transformers architecture. How do LLMs differ from previous approaches?
Tokenization and embeddings
How the LLM tokenizer works. Comparison of token types: words, subwords, characters, bytes. Construction of embeddings from word2vec to modern approaches.
Inside the transformer
Forward-pass models: processing input tokens, calculating the attention matrix, selecting the next token. An intuitive explanation of Self-Attention. Optimizations: KV-cache.
IIUsing Pretrained Models
Practical ways to use ready-made LLMs and embeddings to solve applied problems.
Text classification
Application of LLM for classification problems with minimal training
Clustering and Topic Modeling
BERTopic - one of the authors' library for topic analysis
Prompt engineering
Chain of Thought, ReAct, Tree of Thought and other techniques
Advanced text generation
LangChain, agents, Memory, Tools - complex pipelines
Semantic Search and RAG
Retrieval-Augmented Generation - expanding the model's knowledge
Multimodal models
Text + images: CLIP, BLIP-2, Vision-Language
IIITraining and fine tuning
Creating your own models and adapting existing LLMs for specific tasks.
Creating embedding models
Training your own text embeddings for specific domains
Fine-tuning for classification
Additional training of representation models for classification tasks
Fine-tuning generative models
Fine-tune LLM to generate text in a specific style or domain
Who is this book for?
- Beginners and advanced specialists in ML/NLP
- Developers and analysts implementing LLM into projects
- Anyone who wants to confidently navigate modern models: ChatGPT, Mistral, Claude
