Front Matter
Front Matter

What This Book Covers

"The best way to learn a complex technology is not to study it in isolation, but to build something real with it, then understand why it works."

Sage Sage, Learning by Building AI Agent

Six months from now, you will be building AI systems that did not exist when you started reading. This book is a comprehensive, practitioner-oriented guide to the entire Large Language Model stack. It begins with the mathematical and conceptual foundations of machine learning, moves through the architecture and training of transformers, and culminates in the design, deployment, and governance of production AI agent systems. The journey spans 39 chapters (numbered 0 through 38) organized into eleven parts, plus 22 appendices covering frameworks, tools, and reference material.

Along the way, you will encounter the technologies reshaping the field right now: reasoning models that think step by step before answering (OpenAI o1/o3, DeepSeek-R1), the Model Context Protocol (MCP) that gives agents standardized access to tools, computer use agents that operate browsers and desktops autonomously, RLHF and DPO for aligning models with human preferences, mixture-of-experts architectures that scale to trillions of parameters efficiently, and retrieval-augmented generation pipelines that ground LLM responses in your own data. These are not footnotes; each receives full chapter-length treatment with working code.

What Makes This Book Different

Many books on LLMs focus on either theory or quick-start tutorials. This book bridges the gap. Every chapter follows a consistent structure: concept first, then intuition, then working code, then production considerations. The material is current through early 2026, covering developments like MCP (Model Context Protocol), AG-UI (Agent-User Interaction Protocol), reasoning models (o1, o3, DeepSeek-R1), test-time compute scaling, computer use agents, and automated prompt optimization with DSPy. Throughout, the emphasis is on building systems you can actually ship.

The Eleven Parts

The eleven parts of this book trace a deliberate progression:

  1. Foundations (Chapters 0 through 5, six chapters): Machine learning basics with PyTorch, NLP and text representation, tokenization and subword models, sequence models and attention, the transformer architecture, and decoding strategies. By Chapter 4, you will have built a working transformer block from scratch in PyTorch.
  2. Understanding LLMs (Chapters 6 through 9 and 18, five chapters): Pre-training and scaling laws, the modern model landscape (including mixture-of-experts, reasoning models, and small language models), reasoning and test-time compute, inference optimization (quantization, KV caching, speculative decoding), and interpretability. You will reproduce scaling law predictions and benchmark quantization tradeoffs on real models.
  3. Working with LLMs (Chapters 10 through 12, three chapters): LLM APIs and structured output, prompt engineering (including automated prompt optimization with DSPy), and hybrid ML+LLM systems. You will build a production-ready prompt management system that handles multi-provider failover.
  4. Training and Adapting (Chapters 13 through 17, five chapters): Synthetic data generation, fine-tuning fundamentals, parameter-efficient methods (LoRA, QLoRA), distillation and model merging, and alignment (RLHF, DPO, preference tuning). You will LoRA fine-tune a 7B-parameter model on domain data and train a reward model for preference alignment.
  5. Retrieval and Conversation (Chapters 19 through 21, three chapters): Embeddings and vector databases, retrieval-augmented generation (RAG), and conversational AI systems. You will build a full document QA pipeline that retrieves, re-ranks, and synthesizes answers from your own corpus.
  6. Agentic AI (Chapters 22 through 26, five chapters): AI agent foundations, tool use and protocols (MCP, A2A, AG-UI), multi-agent orchestration, specialized agents (code agents, browser agents, scientific agents), and agent safety and production. By Chapter 24, you will have built a multi-agent system where a supervisor delegates tasks to specialized workers that coordinate through shared state.
  7. AI Applications (Chapters 27 through 28, two chapters): Multimodal models (vision, audio, cross-modal, document AI) and domain-specific LLM applications (healthcare, finance, legal, code generation, robotics and embodied AI).
  8. Evaluation and Production (Chapters 29 through 31, three chapters): Evaluation and observability, monitoring in production, and production engineering with LLMOps.
  9. Safety and Strategy (Chapters 32 through 33, two chapters): Safety, ethics, and regulation (red teaming, EU AI Act, LLM security); organizational strategy for AI adoption, product management, and ROI.
  10. Frontiers (Chapters 34 through 35, two chapters): Emerging architectures and scaling frontiers; AI and society, open research problems, and the road ahead for 2025 and beyond.
  11. From Idea to AI Product (Chapters 36 through 38, three chapters): Turning an idea into a product hypothesis, building and steering AI products through iteration, and shipping and scaling AI products to users.

In addition, 22 appendices (A through V) provide reference material and framework deep-dives: mathematical foundations, ML essentials, Python for LLMs, environment setup, Git collaboration, a comprehensive glossary, hardware and compute guidance, model cards, prompt template libraries, datasets and benchmarks, and hands-on guides to the major LLM frameworks (HuggingFace, LangChain, LangGraph, CrewAI, LlamaIndex, Semantic Kernel, DSPy). Appendices on experiment tracking, inference serving, distributed ML, Docker containers, and the broader tooling ecosystem round out the collection.

How Concepts Build on Each Other

Think of this book as a city with neighborhoods. The early parts (I and II) are the infrastructure: roads, power lines, and plumbing. You need them before anything else can function, because concepts like attention, tokenization, and scaling laws appear everywhere in later chapters. Part III is the city center where everyday work happens: calling APIs, writing prompts, and connecting LLMs with traditional ML systems. From there, three neighborhoods branch out in parallel. Part IV (Training and Adapting) is the factory district, where you customize and manufacture models. Part V (Retrieval and Conversation) is the library district, where you ground models in external knowledge. Part VI (Agentic AI) is the district where models take actions in the world. You can visit these three neighborhoods in any order, because each one connects back to Part III rather than depending on the others. The later parts (VII through X) build on one or more of those branches.

Note that Parts IV, V, and VI can be studied in any order after completing Part III. This branching structure allows readers to follow their interests: an ML engineer might dive straight into training (Part IV), while a product builder might jump to agents and applications (Part VI). The later parts benefit from familiarity with at least one of the three branching parts, but can be read independently if you need production guidance or safety coverage early.

What This Book Does Not Cover

This is not a mathematics textbook. While the book develops mathematical intuition where needed (attention score computations, loss functions, scaling laws), it does not provide rigorous proofs or deep statistical learning theory. Readers who want that level of formalism should pair this book with a dedicated resource such as Bishop's Pattern Recognition and Machine Learning or Goodfellow et al.'s Deep Learning.

This is also not a beginner Python tutorial. The book assumes you can write functions, work with dictionaries and lists, install packages with pip, and navigate a terminal. If you need to learn Python first, complete an introductory course before starting Chapter 0. Finally, this book does not cover classical software engineering topics (databases, networking, web frameworks) except where they directly intersect with LLM system design.

What Comes Next

Now that you know what the book covers, the next section explains who it serves and what background you need. Proceed to FM.2: Who Should Read This Book.