Sahin Boydas
Random theme
Select theme
Hands-On Large Language Models cover

Hands-On Large Language Models by Jay Alammar and Maarten Grootendorst: how LLMs work, drawn and coded

by Jay Alammar & Maarten Grootendorst · O'Reilly, 2024

By Sahin Boydas✓ Updated December 2026On 1 book list

Jay Alammar became known for The Illustrated Transformer, a blog post whose diagrams taught a generation of engineers how attention works. Maarten Grootendorst created BERTopic and KeyBERT, open-source libraries for topic modeling and keyword extraction. Their book, published by O'Reilly in 2024, combines those strengths: close to 300 original figures alongside code that runs in a free notebook.

It starts with how language models represent text, through tokens and embeddings, and what happens inside a transformer as it generates. It then moves to uses: classifying and clustering text, prompt engineering, chaining calls and agents, semantic search and retrieval-augmented generation, and models that handle images as well as text. The final chapters cover training your own embedding models and fine-tuning models that produce embeddings or text.

The balance between understanding and use is what readers praise. Each application comes with enough of the mechanism to know why it works and when it fails.

How Tech People Read It

Andrew Ng

Ng, founder of DeepLearning.AI and a cofounder of Coursera, recommended it in the reviews on the book's repository as a resource for understanding how language models are built. From the person behind many of the most-taken AI courses, the endorsement places it as a course companion for practitioners.

Nils Reimers

Reimers, who created the sentence-transformers library and leads machine learning at Cohere, praised it as a guide to language models in industry. Embeddings and semantic search are his specialty, and the book's chapters on them, and on training embedding models, are among its strongest.

Josh Starmer

Starmer, who explains statistics and machine learning on his StatQuest channel, said he could not think of a more important book to read right now. His audience values visual explanation over formulas, which is the book's approach.

The Main Ideas

  • Tokens and embeddings turn text into numbers whose geometry carries meaning.
  • A transformer generates text one token at a time, attending to everything before it.
  • Many useful applications, such as search, clustering and classification, need embedding models more than chat models.
  • Retrieval-augmented generation grounds a model's answers in documents it fetches at query time.
  • Fine-tuning adapts a pretrained model to a task or a style with modest data.

Who Should Read It

Read it if you build products or tools with language models and want to see their internals, or if you learn best from diagrams. Python experience helps. Skip it if you want to code a model from scratch; Build a Large Language Model (From Scratch) does that, while this book uses existing models and libraries.

The Book

Cover of Hands-On Large Language Models by Jay Alammar & Maarten Grootendorst

Book 01 Intermediate

Hands-On Large Language Models

by Jay Alammar & Maarten Grootendorst

Publisher
O'Reilly, 2024
Free online
No
Goodreads
4.28 of 5 from 327 ratings

Why read it

A visual guide, with close to 300 figures, to how transformer language models work and how to use them: tokens and embeddings, text classification and clustering, prompt engineering, semantic search and retrieval-augmented generation, multimodal models, and fine-tuning both embedding and generation models. Read it if you build with language models and want to know what happens inside them. The code is free on GitHub.

What people said

  • “… their book is a valuable resource for anyone looking to understand the main techniques behind how Large Language Models are built.”

    Andrew Ng, founder of DeepLearning.AI, in the reviews on the book's repository github.com ↗

  • “This is an exceptional guide to the world of language models and their practical applications in industry.”

    Nils Reimers, Director of Machine Learning at Cohere, creator of sentence-transformers github.com ↗

  • “I can’t think of another book that is more important to read right now.”

    Josh Starmer, StatQuest github.com ↗

Watch

Jay Alammar - "Hands-On Large Language Models: Language Understanding and Generation"Rohan AlexanderJay Alammar's talk on the book at the Toronto Data Workshop.

On These Book Lists

Frequently Asked Questions

Is Hands-On Large Language Models good for beginners?

Yes, for readers who know some Python. The figures carry much of the explanation, and the code runs in free notebooks.

Who are the authors?

Jay Alammar, known for The Illustrated Transformer and his work at Cohere, and Maarten Grootendorst, creator of BERTopic and KeyBERT.

Does the book cover RAG and agents?

Yes. It has chapters on semantic search and retrieval-augmented generation, and on chains, memory and agents.

Hands-On Large Language Models or Build a Large Language Model?

This book teaches you to use and adapt existing models. Raschka's book has you build one from scratch; many readers do both.