Back to index
OtherAround 430 pages across 12 chapters, a few weeks working through the notebooks·Around $60 in print, or included with an O'Reilly subscription

Hands-On Large Language Models (Alammar and Grootendorst)

4.5

Jay Alammar's diagrams in book form, with working notebooks attached. If you have been building with LLM APIs without understanding what is underneath, this closes that gap faster than anything else.

What We Liked

  • The visual explanations are exceptional, which is unsurprising given who wrote them
  • Every chapter has runnable code in a maintained public repository
  • Covers the practical spectrum from embeddings and search through to fine tuning
  • The semantic search and reranking material is unusually good and directly applicable
  • Pitched so that both API users and people training models get something out of it

What Could Be Better

  • A 2024 book in a field that moves quarterly, so specific model references have already dated
  • The image generation chapter feels bolted on and is the weakest part by some distance
  • Does not go deep enough on transformer internals for anybody wanting real depth
  • Some of the fine tuning labs want GPU access you may not have to hand
  • Assumes Python competence and offers nothing to a non programmer

Detailed review

Jay Alammar's Illustrated Transformer has probably done more to explain attention to working engineers than every paper on the subject combined, and the obvious question when this book was announced was whether that particular talent would survive the transition to four hundred pages. It largely does, and the result is the book I now hand to developers who have been calling an API for a year and have realised they do not actually know what happens after the request leaves their machine. The book splits into three movements. The first covers understanding, working through tokens and embeddings, what a transformer actually does, and how text classification and clustering work with modern representations.

The second covers using models, prompt engineering, retrieval and semantic search, multimodal models, and building applications. The third covers training and tuning, including creating embedding models, fine tuning representation models, and fine tuning generation models with the parameter efficient methods people actually use. The diagrams are the reason to buy it. Attention, positional encoding, how a decoder generates a token at a time, how contrastive learning shapes an embedding space, what a reranker is doing relative to a bi encoder.

These are ideas that are genuinely hard to convey in prose and genuinely easy to convey with the right picture, and Alammar has spent years getting good at finding the right picture. The tokenisation chapter in particular does something valuable, which is to make visible a component that most people treat as a black box and then get confused by later when character counting or non English text behaves strangely. The semantic search material is the most immediately useful part for most readers. Dense retrieval, the practical differences between embedding approaches, why a reranker earns its latency cost, hybrid search combining sparse and dense signals.

This is the substance of what most people are actually building when they say they are building with LLMs, and it is covered with real care rather than as a preliminary to the fun generative parts. Grootendorst brings genuine depth here, and the sections that clearly come from his work on topic modelling and clustering are strong. Everything is backed by a public notebook repository that is maintained, and the code runs. That sounds like a low bar and it is one that a surprising number of technical books fail to clear.

Being able to read an explanation and then immediately execute the thing being explained is the difference between a book you finish and a book you learn from. Now the honest problems. The first is unavoidable, which is that this came out in 2024 and the field re prices itself every few months. Specific model names, specific context windows, specific capability claims and specific library APIs have moved.

The conceptual material holds up entirely, because tokenisation and attention and retrieval are not changing, but you will hit passages where the example model is no longer the one you would reach for. Read it for the concepts and substitute current models as you go. The second is the image generation chapter, which is the weakest thing in the book by a clear margin. Diffusion is a large topic and it gets a compressed treatment that neither satisfies somebody who wants to understand it nor equips somebody who wants to use it.

The book would be tighter without it, and its presence feels like a response to a table of contents requirement rather than an authorial conviction. The third is depth, and this is a scope judgement rather than a failure. The transformer coverage is excellent at making the mechanism intuitive and stops short of the mathematics. If you want to actually understand attention as an operation you can derive, or you want to write one from scratch, you need Raschka's build from scratch book or Karpathy's videos instead.

This book is aimed at the person who needs an accurate mental model, not the person who needs to implement one, and it is clear about that if you read the title. Some of the fine tuning material also assumes compute you may not have. The parameter efficient methods keep it within reach of a single consumer GPU or a Colab session in most cases, but a reader on a laptop with no accelerator will be reading rather than running for parts of the final third. And it assumes you write Python comfortably.

What it does not cover is worth naming, because it matters. There is very little on evaluation, which is arguably the hardest unsolved problem in shipping anything built on these models, and nothing on production concerns like cost management, latency, monitoring or the operational side. Chip Huyen's AI Engineering is the natural companion for that half of the job. My 4.5 reflects a book that does its specific job better than anything else in the category.

The illustrations are worth the price on their own, the code works, and the coverage matches what people building on language models actually need to know. It loses ground for a weak chapter, for the inevitable pace of obsolescence, and for leaving evaluation almost untouched. If you build with LLMs and cannot currently explain what an embedding is to a colleague, buy this.

[ final ]

The verdict.

The best single book for developers who use language models and want to understand them. Pair it with something on evaluation and production, which this does not cover.