No. 67 of 500 No. 6 in Generative AI & LLMs

Hands-On Large Language Models

Language Understanding and Generation

By Jay Alammar and Maarten Grootendorst

Print length
425 pages
Publisher
O'Reilly Media
Reading level
Intermediate
ISBN-13
978-1098150969
Published
October 15, 2024
Written for
Developers, data scientists and technical analysts who know Python and want to build LLM applications.

Synopsis

Jay Alammar, known for the visual machine learning explainers on his blog, and Maarten Grootendorst, creator of the BERTopic and KeyBERT libraries, built this O'Reilly guide around nearly three hundred custom figures. The first part develops intuition for how language models work: the history of language AI, tokens and embeddings, and a look inside the transformer, including attention and how a model generates text one token at a time. The second part applies pretrained models to practical tasks: text classification, clustering and topic modeling, prompt engineering, advanced generation with memory, tools and agents, semantic search with retrieval-augmented generation, and multimodal models.

The final part turns to training: building text embedding models with contrastive learning, fine-tuning representation models such as BERT for classification, and fine-tuning generative models through supervised instruction tuning and preference methods. Code throughout uses Python with Hugging Face libraries and runs in companion notebooks on the book's GitHub repository, designed for a free Google Colab GPU. Readers come away able to explain what happens inside an LLM and to assemble working pipelines for search, classification and generation. The book favors intuition over mathematics, so readers seeking derivations or production deployment practices will need supplementary sources.

Scorecard

Editorial score

How it scored

Editorial score: 79.3 / 1005 weighted criteria

  • Influence30%

    22.5/30
  • Authority25%

    20.0/25
  • Practical value20%

    17.0/20
  • Currency15%

    11.3/15
  • Readability10%

    8.5/10
  • Editorial score

    79.3/100

How the rank was computed

Rank No. 67 of 500 comes from a composite of 66.2: observable signals 30.5 of 55 points plus editorial review 35.7 of 45 points.

All 11 inputs
InputPoints
Observable signals30.5/55
Reach (Amazon ratings volume)9.3/16.5
Consensus across best-of lists11.0/13.8
Awards and bestseller evidence0.0/8.3
Reader rating, sample-adjusted6.6/8.3
Amazon sales rank1.9/5.5
Recency1.7/2.8
Editorial review35.7/45
Author authority9.0/11.3
Influence10.1/13.5
Practical value7.7/9.0
Readability3.8/4.5
Currency5.1/6.8

Each criterion is scored from 1 to 10 and weighted, and the points add up to the editorial score. The rank combines observable signals (55 percent) with this score (45 percent). Read the methodology.

Verdict

An unusually clear, illustrated route from tokens and embeddings to retrieval and fine-tuning for practitioners building LLM applications.

Strengths

  • Nearly three hundred explanatory custom figures
  • Runnable notebooks for every chapter
  • Balances concepts with practical pipelines

Keep in mind

Light on mathematics and deep transformer internals, and model-specific code examples from 2024 may need updating as libraries and models change.

Key takeaways

  1. Token embeddings and attention let transformer models represent words in context, which is the foundation for both text generation and semantic search.
  2. Many practical tasks, such as classification and topic modeling, can be solved with pretrained embedding models without training or prompting a large generative model.
  3. Retrieval-augmented generation combines dense retrieval and reranking with a generative model to ground answers in specific documents and reduce fabrication.
  4. Parameter-efficient methods such as LoRA and QLoRA make it practical to fine-tune generative models on a single consumer or free cloud GPU.

Notable facts

  • Andrew Ng, founder of DeepLearning.AI, praised the book's beautifully illustrated and insightful descriptions of complex topics. Source (opens in a new tab)
  • The book's companion GitHub repository has more than 30,000 stars, and the book contains nearly 300 custom figures. Source (opens in a new tab)

About the author

Jay Alammar and Maarten Grootendorst

Jay Alammar held a senior engineering role at Cohere when the book appeared, writes a widely read blog of visual machine learning explainers, and co-created machine learning and NLP courses on DeepLearning.AI and Udacity. Coauthor Maarten Grootendorst, trained in psychology and data science, was a senior clinical data scientist at the Netherlands Comprehensive Cancer Organization (IKNL) and created the open-source BERTopic, KeyBERT and PolyFuzz packages.

Questions

What is Hands-On Large Language Models about?
It is an illustrated O'Reilly guide to how large language models work and how to use them. Jay Alammar and Maarten Grootendorst explain tokens, embeddings and transformer architecture, then show in Python how to apply models to classification, clustering, semantic search, retrieval-augmented generation and multimodal tasks, and how to train embedding models and fine-tune both representation and generative models.
Do I need deep learning experience to read Hands-On Large Language Models?
No. The book assumes working knowledge of Python and some familiarity with machine learning concepts, but it builds intuition for transformers and embeddings from the ground up using diagrams rather than equations. Readers new to programming will struggle with the code, while experienced researchers may find the theory lighter than they want, since the book favors intuition and applied examples.
Is Hands-On Large Language Models still current in 2026?
Its core concepts remain current: tokenization, embeddings, attention, retrieval-augmented generation and fine-tuning still underpin today's systems. Specific models and library versions from 2024 have been superseded, and topics such as reasoning models and agent frameworks have advanced since publication, though the authors have published free follow-up visual guides on reasoning LLMs and mixture of experts.

Sources

As an Amazon Associate, Best AI Books earns from qualifying purchases. Best AI Books is sponsored by Iternal.ai, whose founder and CEO, John Byron Hanby IV, wrote The AI Strategy Blueprint, our #1 ranked book. How we rank books.