Hands-On Large Language Models is the code companion repository for the O’Reilly book of the same name, but unlike most book companion repos, the notebooks here stand on their own as one of the cleaner applied LLM curricula on GitHub. If you learn by running code rather than reading prose, this is the free layer of a paid book that holds up entirely on its own. 27,786 stars says the community agrees.
View Hands-On Large Language Models on GitHub

- 27,786 stars
- 6,459 forks
- Jupyter Notebook
- Apache 2.0 License
Hands-On Large Language Models: the O’Reilly book’s free code layer
The book (Hands-On Large Language Models, published by O’Reilly) is a paid, structured walkthrough of applied LLM engineering: understanding, training, fine-tuning, and shipping language models. The repository is the code companion: every example, dataset loader, training script, and evaluation use referenced in the book, runnable independently. You don’t need to own the book to use the repo, and you don’t need the repo to read the book, but if you’re a learn-by-doing person, the repo is the higher-leverage half of the pair.
This split matters because most book companion repos are throwaway: five scripts in a code/ folder, last commit two years ago, README that says “see Chapter 4.” This one isn’t. It’s actively maintained, has a coherent structure, and the notebooks are written to be readable as standalone artifacts. That’s rare for a book repo.
What the notebooks actually cover
The repository walks through the applied LLM surface in roughly the order you’d encounter it on a real project: understanding pre-trained models, generating and embedding text, building retrieval-augmented generation pipelines, fine-tuning models on domain data, and the engineering around deploying them. Each major topic gets its own notebook or set of notebooks.
The retrieval section is the strongest. Where most “RAG tutorial” notebooks stop at “embed and cosine similarity,” this one continues into hybrid retrieval, re-ranking, evaluation, and the engineering decisions that decide whether your RAG system actually works in production. If your RAG demo works but production doesn’t, this is the section to re-read.
The fine-tuning section is similarly above average. It covers the major patterns, including full fine-tuning, parameter-efficient fine-tuning (LoRA and variants), and instruction tuning, without pretending fine-tuning is a one-liner. The tradeoffs (data requirements, compute, evaluation) are surfaced explicitly.
How to use it
The intended workflow is notebook-driven, like GenAI Agents. Clone the repo, install the requirements in a virtualenv or Colab, then open notebooks in the suggested order. The repository’s README lists dependencies clearly and the requirements file is per-notebook where it matters, which avoids the “install everything, hope it works” pattern that breaks most ML repos.
For the fine-tuning notebooks specifically, you’ll want a GPU, either Colab Pro or a local CUDA setup. The retrieval and embedding notebooks run on CPU. Plan accordingly.
The book adds value where the notebooks can’t: narrative explanation, “why this pattern and not the other one,” and the connective tissue between topics. If you find yourself wanting the connective layer after working through a few notebooks, the book is worth buying. If the notebooks are sufficient, you saved yourself forty dollars.
How it compares to alternatives
The closest comparison is mlabonne’s LLM Course, which is also a structured applied LLM curriculum. The difference is that LLM Course is a meta-curation: it points to external resources, papers, and notebooks, while Hands-On LLMs is self-contained: every notebook in this repo was written for it. Curated versus authored. Both have value; they’re complements, not substitutes.
The other comparison is the applied section of Microsoft AI Agents for Beginners, which is more agent-focused and less model-focused. If your goal is “I want to build an agent,” Microsoft’s curriculum is the better starting point; if your goal is “I want to understand the model layer underneath my agent,” Hands-On LLMs is.
Honest limitations
The book was written by authors with a specific perspective (Jay Alammar and Maarten Grootendorst, both well-regarded in the LLM visualization and explanation space). The perspective is a strength when you’re learning, but it means some topics get a particular framing that isn’t the only valid one. The fine-tuning section, for example, leans toward parameter-efficient methods; that’s the current industry default but not the only choice.
The notebooks are demonstrations, not production code. Error handling is light, secrets management is assumed (use environment variables or Colab’s secret store), and the patterns favor readability over robustness. That’s the right trade for teaching material, but anything you ship needs hardening.
Get started
Clone or open in Colab:
git clone https://github.com/HandsOnLLM/Hands-On-Large-Language-Models.git
cd Hands-On-Large-Language-Models
pip install -r requirements.txt
jupyter notebookOr hit “Open in Colab” on any notebook in the README. Start with the introduction notebook, then jump to whichever section matches what you’re currently building.
Hands-On Large Language Models is the rare book companion repo that holds up on its own. If you want a structured, applied LLM curriculum written by people who explain well, this is one of the strongest free options on GitHub. Pair it with mlabonne’s LLM Course for the meta-curation view and the Repos roundup for the broader landscape.