Sefism is free for learners. We are here to help you grow, one step at a time.Join for free
Sefism.
Book · AI & Machine Learningaround $50

Hands-On Large Language Models

An O'Reilly book from 2024 by Jay Alammar, author of The Illustrated Transformer, and Maarten Grootendorst, with almost 300 custom figures. It goes from tokens and embeddings through classification, clustering, prompting, semantic search and RAG to fine-tuning, with runnable Colab notebooks for every chapter. It suits developers who want visual intuition and working code rather than heavy mathematics.

Get access
Published

O'Reilly, 2024

Official GitHub repo · Sept 2026

Length

About 400 pages, 12 chapters

Official GitHub repo · Sept 2026

Figures

Almost 300 custom figures

Official GitHub repo · Sept 2026

Code repo stars

29.2k

GitHub · Sept 2026

Format

Book

Topic

AI & Machine Learning

Provider

Jay Alammar and Maarten Grootendorst

Level

Intermediate

Access

around $50

What the book covers

The book is about 400 pages across twelve chapters in three parts:

Understanding language models

  1. An introduction to language models
  2. Tokens and embeddings
  3. Looking inside transformer LLMs (an updated, expanded version of The Illustrated Transformer)

Using pretrained models 4. Text classification 5. Text clustering and topic modelling 6. Prompt engineering 7. Advanced text generation techniques and tools 8. Semantic search and retrieval-augmented generation 9. Multimodal large language models

Training and fine-tuning 10. Creating text embedding models 11. Fine-tuning representation models for classification 12. Fine-tuning generation models

What makes it different

Most LLM books are either theory with equations or recipes for one framework. This one teaches through diagrams first and code second. It also gives proper attention to the less glamorous but very practical uses of language models: embeddings, classification, clustering and search. Those are often what a real product needs, and many newer resources skip straight to chatbots.

The official code repository has one notebook per chapter, designed to run on Google Colab's free T4 GPU, so you do not need your own hardware. The repository had about 29,000 GitHub stars as of September 2026, and it also links to free bonus visual guides on topics such as quantisation, mixture of experts, Mamba and reasoning models.

Before you start

You should be comfortable with Python and basic data handling. Some exposure to machine learning helps, but the book explains what it needs. Heavy linear algebra is not required.

How long it takes and how to read it

Plan on several weeks at a few hours a week if you run the code, which you should. A good order:

  • Read chapters 1 to 3 closely; they are the foundation.
  • Work through chapters 4 to 8 with the notebooks open, changing the dataset or model in each.
  • Treat chapters 10 to 12 as reference until you actually need to fine-tune something.

Weak spots

  • The field moves fast. Library versions and specific models in a 2024 book will date; the concepts will not. Expect to adjust some code.
  • Agent frameworks and production concerns such as evaluation, monitoring and cost get little space. Pair it with an agents course and an evals guide.
  • It is paid. Check your university library or an O'Reilly subscription before buying.

Common questions

Is it for beginners? Beginners in LLMs, yes; beginners in Python, no.

Do I need a GPU? No. The notebooks are built for free Colab.

Best for: developers who want to understand and use language models through clear visuals and runnable code.

aillmmachine learning

Ready to start?

Opens on Jay Alammar and Maarten Grootendorst in a new tab.

Get access
Link broken or out of date?

Report a problem

With "Hands-On Large Language Models". Only Tauseef reads this.

Work with me

Stuck on something specific?

Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.