Hands-On Large Language Models: Language Understanding and Generation (9781098150969) by Jay Alammar and Maarten Grootendosrt is an O’Reilly Media book for Python developers who want to understand how language models work and use them in their own projects. The authors pair illustrated explanations with code examples. The book moves from tokens, embeddings, and transformers to practical tasks such as text classification, semantic search, and text generation, then shows how to adapt models for specific tasks.
The opening chapters follow text as it moves through a model. A tokenizer breaks input into pieces, and embeddings represent those pieces numerically. The illustrations show how attention lets a transformer account for relationships between tokens instead of treating each piece of text in isolation. The authors also distinguish models used to represent text from models used to generate it. That distinction helps explain why a model suited to ranking search results is not necessarily the same one you would use to write an answer.
The middle section works with pretrained language models. It covers assigning labels to text, grouping similar documents, and identifying topics in a collection. The generation chapters look at prompt engineering and ways to control the structure of a model’s output. There is also a chapter on multimodal language models, which examines how models work with images and text together. These examples make the difference between language understanding and generation concrete. Sorting customer messages by topic, for instance, asks the model to do something different from drafting a reply.
The hands-on large language models: language understanding and generation book (9781098150969) treats semantic search and retrieval-augmented generation (RAG) as related but distinct tasks. Semantic search looks for results based on meaning, even when the query and the source use different words. A RAG system retrieves relevant material and passes it to a generative model as context for an answer. The examples show how retrieval and generation fit together, and why the quality of the retrieved material matters to the resulting answer.
The final section turns to creating text embedding models and fine-tuning models for classification and generation. The authors cover supervised fine-tuning, parameter-efficient techniques such as QLoRA, and preference tuning. They also discuss how to evaluate generated outputs, where a single reference answer may not capture every acceptable response. This gives readers a way to compare a pretrained model with an adapted one rather than assuming that more training automatically produces better results.
This hands-on large language models book is aimed at readers comfortable with Python who are new to LLMs or want to move beyond basic prompting. The authors Jay Alammar and Maarten Grootendosrt provide companion notebooks for the examples, so readers can follow the diagrams, run the code, and see how the techniques behave with different inputs. The notebooks are available in the authors’ repository.

There are no reviews yet.