[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-9731":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":15,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":33,"readmeContent":34,"aiSummary":35,"trendingCount":16,"starSnapshotCount":16,"syncStatus":36,"lastSyncTime":37,"discoverSource":38},9731,"Hands-On-Large-Language-Models","HandsOnLLM\u002FHands-On-Large-Language-Models","HandsOnLLM","Official code repo for the O'Reilly Book - \"Hands-On Large Language Models\"","https:\u002F\u002Fwww.llm-book.com\u002F",null,"Jupyter Notebook",26922,6253,276,23,0,148,710,120,45,"Apache License 2.0",false,"main",true,[26,27,28,29,30,31,32],"artificial-intelligence","book","large-language-models","llm","llms","oreilly","oreilly-books","2026-06-12 02:02:11","﻿# Hands-On Large Language Models\r\n\r\n\u003Ca href=\"https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjalammar\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FFollow%20Jay-blue.svg?logo=linkedin\">\u003C\u002Fa>\r\n\u003Ca href=\"https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fmgrootendorst\u002F\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FFollow%20Maarten-blue.svg?logo=linkedin\">\u003C\u002Fa>\r\n\u003Ca href=\"https:\u002F\u002Fwww.deeplearning.ai\u002Fshort-courses\u002Fhow-transformer-llms-work\u002F?utm_campaign=handsonllm-launch&utm_medium=partner\">\u003Cimg src=\"https:\u002F\u002Fimg.shields.io\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44ODUtOC4yMjEtOC42MzMtOC4yMjEtNC43NDcgMC04LjYzMiAzLjY3OS04LjYzMiA4LjIyMSAwIDQuNTQzIDMuODg1IDguMjE4IDguNjMyIDguMjE4eiIgZmlsbD0iI0ZENEE2MSIvPgo8L3N2Zz4=\">\u003C\u002Fa>\r\n\r\nWelcome! In this repository you will find the code for all examples throughout the book [Hands-On Large Language Models](https:\u002F\u002Fwww.amazon.com\u002FHands-Large-Language-Models-Understanding\u002Fdp\u002F1098150961) written by [Jay Alammar](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fjalammar\u002F) and [Maarten Grootendorst](https:\u002F\u002Fwww.linkedin.com\u002Fin\u002Fmgrootendorst\u002F) which we playfully dubbed: \u003Cbr> \r\n\r\n\u003Cp align=\"center\">\u003Cb>\u003Ci>\"The Illustrated LLM Book\"\u003C\u002Fi>\u003C\u002Fb>\u003C\u002Fp>\r\n\r\nThrough the visually educational nature of this book and with **almost 300 custom made figures**, learn the practical tools and concepts you need to use Large Language Models today!\r\n\r\n\u003Ca href=\"https:\u002F\u002Fwww.amazon.com\u002FHands-Large-Language-Models-Understanding\u002Fdp\u002F1098150961\">\u003Cimg src=\"images\u002Fbook_cover.png\" width=\"50%\" >\u003C\u002Fa>\r\n\r\n\u003Cbr>\r\n\r\nThe book is available on:\r\n\r\n* [Amazon](https:\u002F\u002Fwww.amazon.com\u002FHands-Large-Language-Models-Understanding\u002Fdp\u002F1098150961)\r\n* [Shroff Publishers (India)](https:\u002F\u002Fwww.shroffpublishers.com\u002Fbooks\u002Fcomputer-science\u002Flarge-language-models\u002F9789355425522\u002F)\r\n* [O'Reilly](https:\u002F\u002Fwww.oreilly.com\u002Flibrary\u002Fview\u002Fhands-on-large-language\u002F9781098150952\u002F)\r\n* [Kindle](https:\u002F\u002Fwww.amazon.com\u002FHands-Large-Language-Models-Alammar-ebook\u002Fdp\u002FB0DGZ46G88\u002Fref=tmm_kin_swatch_0?_encoding=UTF8&qid=&sr=)\r\n* [Barnes and Noble](https:\u002F\u002Fwww.barnesandnoble.com\u002Fw\u002Fhands-on-large-language-models-jay-alammar\u002F1145185960)\r\n* [Goodreads](https:\u002F\u002Fwww.goodreads.com\u002Fbook\u002Fshow\u002F210408850-hands-on-large-language-models)\r\n\r\n## Table of Contents\r\n\r\nWe advise to run all examples through Google Colab for the easiest setup. Google Colab allows you to use a T4 GPU with 16GB of VRAM for free. All examples were mainly built and tested using Google Colab, so it should be the most stable platform. However, any other cloud provider should work. \r\n\r\n| Chapter  | Notebook  |\r\n|---|---|\r\n| Chapter 1: Introduction to Language Models  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter01\u002FChapter%201%20-%20Introduction%20to%20Language%20Models.ipynb)   |\r\n| Chapter 2: Tokens and Embeddings  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter02\u002FChapter%202%20-%20Tokens%20and%20Token%20Embeddings.ipynb)  |\r\n| Chapter 3: Looking Inside Transformer LLMs  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter03\u002FChapter%203%20-%20Looking%20Inside%20LLMs.ipynb)  |\r\n| Chapter 4: Text Classification  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter04\u002FChapter%204%20-%20Text%20Classification.ipynb)  |\r\n| Chapter 5: Text Clustering and Topic Modeling  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter05\u002FChapter%205%20-%20Text%20Clustering%20and%20Topic%20Modeling.ipynb)  |\r\n| Chapter 6: Prompt Engineering  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter06\u002FChapter%206%20-%20Prompt%20Engineering.ipynb)  |\r\n| Chapter 7: Advanced Text Generation Techniques and Tools  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter07\u002FChapter%207%20-%20Advanced%20Text%20Generation%20Techniques%20and%20Tools.ipynb)  |\r\n| Chapter 8: Semantic Search and Retrieval-Augmented Generation  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter08\u002FChapter%208%20-%20Semantic%20Search.ipynb)  |\r\n| Chapter 9: Multimodal Large Language Models  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter09\u002FChapter%209%20-%20Multimodal%20Large%20Language%20Models.ipynb)  |\r\n| Chapter 10: Creating Text Embedding Models  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter10\u002FChapter%2010%20-%20Creating%20Text%20Embedding%20Models.ipynb)  |\r\n| Chapter 11: Fine-tuning Representation Models for Classification  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter11\u002FChapter%2011%20-%20Fine-Tuning%20BERT.ipynb)  |\r\n| Chapter 12: Fine-tuning Generation Models  | [![Open In Colab](https:\u002F\u002Fcolab.research.google.com\u002Fassets\u002Fcolab-badge.svg)](https:\u002F\u002Fcolab.research.google.com\u002Fgithub\u002FHandsOnLLM\u002FHands-On-Large-Language-Models\u002Fblob\u002Fmain\u002Fchapter12\u002FChapter%2012%20-%20Fine-tuning%20Generation%20Models.ipynb)  |\r\n\r\n> [!TIP]\r\n> You can check the [setup](.setup\u002F) folder for a quick-start guide to install all packages locally and you can check the [conda](.setup\u002Fconda\u002F) folder for a complete guide on how to setup your environment, including conda and PyTorch installation.\r\n> Note that the depending on your OS, Python version, and dependencies your results might be slightly differ. However, they\r\n> should this be similar to the examples in the book. \r\n\r\n\r\n## Reviews\r\n\r\n> \"*Jay and Maarten have continued their tradition of providing beautifully illustrated and insightful descriptions of complex topics in their new book. Bolstered with working code, timelines, and references to key papers, their book is a valuable resource for anyone looking to understand the main techniques behind how Large Language Models are built.*\"\r\n>    \r\n> **Andrew Ng** - founder of [DeepLearning.AI](https:\u002F\u002Fwww.deeplearning.ai\u002F)\r\n\r\n---\r\n\r\n> \"*This is an exceptional guide to the world of language models and their practical applications in industry. Its highly-visual coverage of generative, representational, and retrieval applications of language models empowers readers to quickly understand, use, and refine LLMs. Highly recommended!*\"\r\n>\r\n> **Nils Reimers** - Director of Machine Learning at Cohere | creator of [sentence-transformers](https:\u002F\u002Fgithub.com\u002FUKPLab\u002Fsentence-transformers)\r\n\r\n---\r\n\r\n> \"*I can’t think of another book that is more important to read right now. On every single page, I learned something that is critical to success in this era of language models.*\"\r\n> \r\n> **Josh Starmer** - [StatQuest](https:\u002F\u002Fwww.youtube.com\u002Fchannel\u002FUCtYLUTtgS3k1Fg4y5tAhLbw)\r\n\r\n---\r\n\r\n> \"*If you’re looking to get up to speed in everything regarding LLMs, look no further! In this wonderful book, Jay and Maarten will take you from zero to expert in the history and latest advances in large language models. With very intuitive explanations, great real-life examples, clear illustrations, and comprehensive code labs, this book lifts the curtain on the complexities of transformer models, tokenizers, semantic search, RAG, and many other cutting-edge technologies. A must read for anyone interested in the latest AI technology!*\"\r\n> \r\n> **Luis Serrano, PhD** - Founder and CEO of [Serrano Academy](https:\u002F\u002Fwww.youtube.com\u002F@SerranoAcademy)\r\n\r\n---\r\n\r\n> \"*Hands-On Large Language Models brings clarity and practical examples to cut through the hype of AI. It provides a wealth of great diagrams and visual aids to supplement the clear explanations. The worked examples and code make concrete what other books leave abstract. The book starts with simple introductory beginnings, and steadily builds in scope. By the final chapters, you will be fine-tuning and building your own large language models with confidence.*\"\r\n>\r\n> **Leland McInnes** - Researcher at the Tutte Institute for Mathematics and Computing | creator of [UMAP](https:\u002F\u002Fgithub.com\u002Flmcinnes\u002Fumap) and [HDBSCAN](https:\u002F\u002Fgithub.com\u002Fscikit-learn-contrib\u002Fhdbscan)\r\n\r\n---\r\n\r\n## [Bonus content!](bonus\u002F)\r\n\r\nWe attempted to put as much information into the book without it being overwhelming. However, even with a 400-page book there is still much to discover! \r\n\r\nWe continue to create more guides that compliment the book and go more in-depth into new and [exciting topics]((bonus\u002F)):\r\n\r\n| [A Visual Guide to Mamba](https:\u002F\u002Fnewsletter.maartengrootendorst.com\u002Fp\u002Fa-visual-guide-to-mamba-and-state)             |  [A Visual Guide to Quantization](https:\u002F\u002Fnewsletter.maartengrootendorst.com\u002Fp\u002Fa-visual-guide-to-quantization) | [The Illustrated Stable Diffusion](https:\u002F\u002Fjalammar.github.io\u002Fillustrated-stable-diffusion\u002F) |\r\n:-------------------------:|:-------------------------:|:-------------------------:\r\n![](images\u002Fmamba.png)  |  ![](images\u002Fquant.png) |  ![](images\u002Fdiffusion.png)\r\n**[A Visual Guide to Mixture of Experts](https:\u002F\u002Fnewsletter.maartengrootendorst.com\u002Fp\u002Fa-visual-guide-to-mixture-of-experts)**  | **[A Visual Guide to Reasoning LLMs](https:\u002F\u002Fnewsletter.maartengrootendorst.com\u002Fp\u002Fa-visual-guide-to-reasoning-llms)**  |  **[The Illustrated DeepSeek-R1](https:\u002F\u002Fnewsletter.languagemodels.co\u002Fp\u002Fthe-illustrated-deepseek-r1)**\r\n![](images\u002Fmoe.png)  |  ![](images\u002Freasoning.png) |  ![](images\u002Fdeepseek.png)\r\n\r\n## Citation\r\n\r\nPlease consider citing the book if you consider it useful for your research:\r\n\r\n```\r\n@book{hands-on-llms-book,\r\n  author       = {Jay Alammar and Maarten Grootendorst},\r\n  title        = {Hands-On Large Language Models},\r\n  publisher    = {O'Reilly},\r\n  year         = {2024},\r\n  isbn         = {978-1098150969},\r\n  url          = {https:\u002F\u002Fwww.oreilly.com\u002Flibrary\u002Fview\u002Fhands-on-large-language\u002F9781098150952\u002F},\r\n  github       = {https:\u002F\u002Fgithub.com\u002FHandsOnLLM\u002FHands-On-Large-Language-Models}\r\n}\r\n```\r\n","Hands-On Large Language Models 是一本关于大型语言模型的实践指南，其官方代码仓库提供了书中所有示例的代码。该项目通过近300个定制图表，以直观易懂的方式讲解了大语言模型的核心概念和使用方法。它利用Jupyter Notebook作为主要工具，使得学习者能够轻松运行和修改代码，从而加深对LLM的理解。适合任何希望深入了解并上手使用大型语言模型的研究人员、开发者以及学生在实际项目中应用。",2,"2026-06-11 03:24:28","top_topic"]