
Buy New
Learn more
Return this item for free
We offer easy, convenient returns with at least one free return option: no shipping charges. All returns must comply with our returns policy.
Learn more about free returns.- Go to your orders and start the return
- Select your preferred free shipping option
- Drop off and leave!
Save with Used - Good
Book details
- ISBN-101098150961
- ISBN-13978-1098150969
- Edition1st
- PublisherO'Reilly Media
- Publication dateOctober 15, 2024
- LanguageEnglish
- Dimensions7 x 0.87 x 9.19 inches
- Print length425 pages
AI has acquired startling new language capabilities in just the past few years. Driven by rapid advances in deep learning, language AI systems are able to write and understand text better than ever before. This trend is enabling new features, products, and entire industries. Through this book's visually educational nature, readers will learn practical tools and concepts they need to use these capabilities today.
You'll understand how to use pretrained large language models for use cases like copywriting and summarization; create semantic search systems that go beyond keyword matching; and use existing libraries and pretrained models for text classification, search, and clusterings.
This book also helps you:
- Understand the architecture of Transformer language models that excel at text generation and representation
- Build advanced LLM pipelines to cluster text documents and explore the topics they cover
- Build semantic search engines that go beyond keyword search, using methods like dense retrieval and rerankers
- Explore how generative models can be used, from prompt engineering all the way to retrieval-augmented generation
- Gain a deeper understanding of how to train LLMs and optimize them for specific applications using generative model fine-tuning, contrastive fine-tuning, and in-context learning
Review
- Andrew Ng, Founder of DeepLearning AI
"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."
-Josh Starmer, StatQuest
"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!"
-Nils Reimers, Director of Machine Learning at Cohere | creator sentence-transformers
"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 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!"
- Luis Serrano, PhD, Founder and CEO - Serrano Academy
"This book is a must-read for anyone interested in the rapidly-evolving field of generative AI. With a focus on both text and visual embeddings, it's a great blend of algorithmic evolution, theoretical rigor, and practical guidance. Whether you are a student, researcher, or industry professional, this book will equip you with the use cases and solutions needed to level-up your knowledge of generative AI. Well done!"
- Chris Fregly, Principal Solution Architect, Generative AI at AWS
About the Author
Maarten Grootendorst is a Senior Clinical Data Scientist at IKNL (Netherlands Comprehensive Cancer Organization). He holds master's degrees in organizational psychology, clinical psychology, and data science which he leverages to communicate complex Machine Learning concepts to a wide audience. With his popular blogs, he has reached millions of readers by explaining the fundamentals of Artificial Intelligence--often from a psychological point of view. He is the author and maintainer of several open-source packages that rely on the strength of Large Language Models, such as BERTopic, PolyFuzz, and KeyBERT. His packages are downloaded millions of times and used by data professionals and organizations worldwide.
About the authors
Follow authors to get new release updates, plus improved recommendations.Maarten Grootendorst is a Senior Clinical Data Scientist at IKNL (Netherlands Comprehensive Cancer Organization).
He holds three master’s degrees in organizational psychology, clinical psychology, and data science, which he leverages to communicate complex machine learning concepts to a wide audience. With his popular blogs, he has reached millions of readers by explaining the fundamentals of artificial intelligence—often from a psychological point of view.
He is the author of several open-source packages that rely on the strength of large language models, such as BERTopic, PolyFuzz, and KeyBERT. His packages are downloaded millions of times and used by data professionals and organizations worldwide.
Through his popular AI/ML blog, Jay has helped millions of researchers and engineers visually understand machine learning tools and concepts from the basic (ending up in the documentation of packages like NumPy and pandas) to the cutting-edge (Transformers, BERT, GPT-3, Stable Diffusion).
Jay Alammar is Director and Engineering Fellow at Cohere (a pioneering provider of large language models as an API) and co-author of Hands-On Large Language Models, published by O'Reilly Media.
Frequently bought together
Frequently bought together

You might also like
-  
-  
-  
-  
-  
From the brand
-
Browse more NLP & LLM books
-
Machine Learning, AI & more
-
More from O'Reilly
-
Sharing the knowledge of experts
O'Reilly's mission is to change the world by sharing the knowledge of innovators. For over 40 years, we've inspired companies and individuals to do new things (and do them better) by providing the skills and understanding that are necessary for success.
Our customers are hungry to build the innovations that propel the world forward. And we help them do just that.
From the Publisher
From the Preface
Large language models (LLMs) have had a profound and far-reaching impact on the world. By enabling machines to better understand and generate human-like language, LLMs have opened new possibilities in the field of AI and impacted entire industries.
This book provides a comprehensive and highly visual introduction to the world of LLMs, covering both the conceptual foundations and practical applications. From word representations that preceded deep learning to the cutting-edge (at the time of this writing) Transformer architecture, we will explore the history and evolution of LLMs. We delve into the inner workings of LLMs, exploring their architectures, training methods, and fine-tuning techniques. We also examine various applications of LLMs in text classification, clustering, topic modeling, chatbots, search engines, and more.
With its unique blend of intuition-building, applications, and illustrative style, we hope that this book provides the ideal foundation for those looking to explore the exciting world of LLMs. Whether you are a beginner or an expert, we invite you to join us on this journey to start building with LLMs.

Prerequisites
This book assumes that you have some experience programming in Python and are familiar with the fundamentals of machine learning. The focus will be on building a strong intuition rather than deriving mathematical equations. As such, illustrations combined with hands-on examples will drive the examples and learning through this book. This book assumes no prior knowledge of popular deep learning frameworks such as PyTorch or TensorFlow nor any prior knowledge of generative modeling.
If you are not familiar with Python, a great place to start is Learn Python, where you will find many tutorials on the basics of the language. To further ease the learning process, we made all the code available on Google Colab, a platform where you can run all of the code without the need to install anything locally.
Product information
Publisher | O'Reilly Media |
Publication date | October 15, 2024 |
Edition | 1st |
Language | English |
Print length | 425 pages |
ISBN-10 | 1098150961 |
ISBN-13 | 978-1098150969 |
Item Weight | 1.49 pounds |
Dimensions | 7 x 0.87 x 9.19 inches |
Best Sellers Rank |
|
---|---|
Customer Reviews | 4.7 out of 5 stars 127Reviews |
Customers who bought this item also bought
You might also like
-  
-  
-  
-  
-  
-  
-  
Related books
Customers say
Customers appreciate the book's detailed explanations, with one noting how it makes abstract topics easy to grasp through diagrams. They find the content relevant for production applications, with one customer highlighting its coverage of modern workflows.
AI Generated from the text of customer reviews
Select to learn more
Customers appreciate the book's detailed explanations and diagrams that make complex topics understandable, with one customer noting how it provides a comprehensive view of the field.
AI Generated from the text of customer reviews
"...What stood out for me: • ✅ Hands-on notebooks + code to reinforce each concept • ✅ Explains transformer internals without getting lost..." Read more
"Focused, concise, and to the point. Well-structured with thoughtfully chosen topics...." Read more
"...their explanation of transformer attention mechanisms, paired with intuitive diagrams, made an otherwise abstract topic remarkably easy to grasp...." Read more
"...But that's terrible, as the diagrams make no sense, until you understand the components...." Read more
Customers find the book relevant for production applications, with one customer noting it covers modern workflows.
AI Generated from the text of customer reviews
"...transformer internals without getting lost in math • ✅ Covers modern workflows — from fine-tuning to inference • ✅ Clean visualizations..." Read more
"...The clarity and depth of the content make it an invaluable resource for anyone interested in LLMs...." Read more
"...By connecting the dots on the base rationale, better applications can be built. The graphics are amazing!" Read more
Reviews with images
Submit a report
- Harassment, profanity
- Spam, advertisement, promotions
- Given in exchange for cash, discounts
Sorry, there was an error
Please try again later.Top reviews from the United States
There was a problem filtering reviews. Please reload the page.
- 5.0 out of 5 starsVerified Purchase🧠 Fantastic practical intro for serious ML folks diving into LLMsReviewed in the United States on April 5, 2025Format: PaperbackAs someone who works in machine learning but mostly on CV problems, this book was a perfect bridge into the world of language models. It doesn’t assume you’re a total beginner, but it also doesn’t dump you in the deep end with dense theory and academic papers. The authors...As someone who works in machine learning but mostly on CV problems, this book was a perfect bridge into the world of language models. It doesn’t assume you’re a total beginner, but it also doesn’t dump you in the deep end with dense theory and academic papers. The authors do a great job of grounding concepts in clear explanations and walk-throughs you can actually run.
What stood out for me:
• ✅ Hands-on notebooks + code to reinforce each concept
• ✅ Explains transformer internals without getting lost in math
• ✅ Covers modern workflows — from fine-tuning to inference
• ✅ Clean visualizations (if you know Jay Alammar’s style, you know)
Also, Maarten’s sections on vector databases, embeddings, and RAG workflows were super relevant for production applications. You can tell both authors have experience teaching and shipping real-world stuff.
⚠️ Minor caveat: This isn’t a deep theoretical text — if you’re looking for the type of math found in something like “Deep Learning” by Goodfellow, this isn’t it. It’s much more about doing.
If you’re a data scientist, ML engineer, or just a curious dev looking to go beyond ChatGPT and understand how to work with LLMs at a system level — grab this book. You’ll get a lot out of it.
- 5.0 out of 5 starsVerified Purchasefocused and conciseReviewed in the United States on May 22, 2025Format: KindleFocused, concise, and to the point. Well-structured with thoughtfully chosen topics. I hope the book continues to be updated and expanded to cover more ground as the field evolves.
- 5.0 out of 5 starsVerified PurchaseWell explained and lots of pictures!Reviewed in the United States on March 7, 2025Format: PaperbackThis is an enjoyable and accessible read with many of the concepts behind LLMs covered. The code examples are fun and they've picked models that anyone can run on Colab (be warned - if you have an intel-era mac they won't often won't run locally since PyTorch...This is an enjoyable and accessible read with many of the concepts behind LLMs covered. The code examples are fun and they've picked models that anyone can run on Colab (be warned - if you have an intel-era mac they won't often won't run locally since PyTorch dropped support for non-Apple silicon). At the time of this review (mar 25) the book is pretty up to date too.
Areas for improvement? I'd like to see a bit more attention (ha ha) paid to training.
- 5.0 out of 5 starsVerified PurchaseIt's truly a gemReviewed in the United States on October 19, 2024Format: PaperbackI preordered "Hands-On Large Language Models" by Jay Alammar and Maarten Grootendorst as soon as it was available, and I've just received it. I've been eagerly anticipating this book, especially since Maarten is the author and maintainer of the BERTopic...I preordered "Hands-On Large Language Models" by Jay Alammar and Maarten Grootendorst as soon as it was available, and I've just received it. I've been eagerly anticipating this book, especially since Maarten is the author and maintainer of the BERTopic library, which has been crucial in many of my NLP projects. I'm grateful for his contributions, which have greatly supported my research efforts. This book captures that same spirit—it's truly a gem!
I've dabbled with LLMs before, particularly in areas like fine-tuning models and developing autonomous agents, but this book has significantly deepened my understanding. The way they break down complex concepts with crystal-clear visuals is not just educational, but also inspiring. For instance, their explanation of transformer attention mechanisms, paired with intuitive diagrams, made an otherwise abstract topic remarkably easy to grasp. It's making me rethink how I communicate my own research—striving for a blend of depth, engaging visuals, and clear, relatable examples to make complex ideas accessible.
When the authors say "hands-on," they're not kidding. Real datasets, practical coding projects, and digital resources—you're not just reading; you're doing. Jay and Maarten have managed to demystify the intricacies of large language models, particularly in chapters like the one on fine-tuning techniques, turning an intimidating topic (for those who had limited experience) into an engaging and approachable journey. Whether you're looking to cover the basics or explore the finer points, this one's a keeper.
- 5.0 out of 5 starsVerified PurchaseGem of a book for Language AI and LLMsReviewed in the United States on September 29, 2024Format: KindleAs a resident of Sweden, I was thrilled to discover the Kindle version of this book, allowing me to dive in immediately without waiting for international shipping. From the moment I started reading last week, I've been completely engrossed. The authors' approach is...As a resident of Sweden, I was thrilled to discover the Kindle version of this book, allowing me to dive in immediately without waiting for international shipping. From the moment I started reading last week, I've been completely engrossed. The authors' approach is brilliantly practical, seamlessly blending theoretical explanations of Language AI and LLMs with hands-on .ipynb exercises that bring concepts to life.
The visuals are simply outstanding, offering incredibly detailed insights into the inner workings of LLMs. I particularly appreciate the balanced coverage of both open-source and licensed models, providing a comprehensive view of the field.
I've been so impressed that I've already started sharing the book with a friend, who finds it equally enlightening. The clarity and depth of the content make it an invaluable resource for anyone interested in LLMs.
I'm confident that this book will inspire countless innovations and breakthroughs in the field. Jay and Marteen have created a truly phenomenal work that's both educational and inspiring. Thank you for this exceptional contribution to the AI community!
- 3.0 out of 5 starsVerified PurchaseVery poor organizationReviewed in the United States on April 21, 2025Format: PaperbackI'm still reading, so my opinion may change, but I'm not liking it so far. One of the things I hate in books is use of undefined terms. This book does it constantly. It's a structural decision - they give overviews, then eventually get around to...I'm still reading, so my opinion may change, but I'm not liking it so far.
One of the things I hate in books is use of undefined terms. This book does it constantly. It's a structural decision - they give overviews, then eventually get around to explaining the pieces I the overview.
But that's terrible, as the diagrams make no sense, until you understand the components. So you have to read the book twice to make any sense of it.
I went looking for an example. Figure 3-6, p78. There are three things in the input path: tokenizer, transformer block, and LM head. Of the three, only the tokenizer has been explained. Transformer block are later explained on p87. LM head does not seem to be explained at all. Unless you think "simple neural network layer" is an explanation.
Most books are much better about this, and make an effort to avoid doing what this book does constantly.
From the other reviews, some people seem to like this format. I hate it.
Not recommended.
- 5.0 out of 5 starsVerified PurchaseHands-On Large Language ModelsReviewed in the United States on March 8, 2025Format: PaperbackThis book sheds plenty of light into this abstract subject. By connecting the dots on the base rationale, better applications can be built. The graphics are amazing!
Top reviews from other countries
- Computational Scientist5.0 out of 5 starsVerified PurchaseGreat book that fills a much needed niche!Reviewed in the United Kingdom on April 14, 2025This is a great resource! The strength here is on sentence transformers, RAG, Agentic AI, and prompt engineering. This books covers those topics better than many others out there. Get this book and get started expanding your AI coding!This is a great resource! The strength here is on sentence transformers, RAG, Agentic AI, and prompt engineering. This books covers those topics better than many others out there. Get this book and get started expanding your AI coding!
- José Alberto Santana5.0 out of 5 starsVerified PurchaseExcellent textbook with stunning visualsReviewed in Mexico on June 21, 2025I am blown away at how Jay Alammar and Maarten Grootendorst’s visuals blend in with the theoretical aspects of LLMs. As an 18 year old who is obsessed with the intricacies of LLMs and working with different environments like LangChain and the OpenAI API, this book felt like...I am blown away at how Jay Alammar and Maarten Grootendorst’s visuals blend in with the theoretical aspects of LLMs. As an 18 year old who is obsessed with the intricacies of LLMs and working with different environments like LangChain and the OpenAI API, this book felt like a playground. On another note, if you combine this with Chip Huyen’s AI Engineering textbook as well as the FastAPI framework and containerization using Docker, you’ll have the tools to deploy AI systems into production in the cloud.I am blown away at how Jay Alammar and Maarten Grootendorst’s visuals blend in with the theoretical aspects of LLMs. As an 18 year old who is obsessed with the intricacies of LLMs and working with different environments like LangChain and the OpenAI API, this book felt like a playground. On another note, if you combine this with Chip Huyen’s AI Engineering textbook as well as the FastAPI framework and containerization using Docker, you’ll have the tools to deploy AI systems into production in the cloud.
- Hatim A. Aboalsamh4.0 out of 5 starsVerified PurchaseRecommendedReviewed in Saudi Arabia on March 9, 2025nice booknice book
- Translate all reviews to EnglishJose Javier5.0 out of 5 starsVerified Purchasefacil de entender y completoReviewed in Spain on January 25, 2025completo y facil de entender, sobre el funcionamiento interno de los LLM, y las librerias de hugging face y langchain , heads (transfer knowledge), chat, RAG, prompt engineering, fine tunning etc. Un libro de referencia en este areacompleto y facil de entender, sobre el funcionamiento interno de los LLM, y las librerias de hugging face y langchain , heads (transfer knowledge), chat, RAG, prompt engineering, fine tunning etc. Un libro de referencia en este area
- tb5.0 out of 5 starsVerified PurchaseGood qualityReviewed in the United Kingdom on March 4, 2025Very detailed and very structuredVery detailed and very structured
How customer reviews and ratings work
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.Learn more how customers reviews work on Amazon