Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Suhas Pai

Large language models (LLMs) have proven themselves to be powerful tools for solving a wide range of tasks, and enterprises have taken note. But transitioning from demos and prototypes to full-fledged applications can be difficult. This book helps close that gap, providing the tools, techniques, and playbooks that practitioners need to build useful products that incorporate the power of language models. Experienced ML researcher Suhas Pai offers practical advice on harnessing LLMs for your use cases and dealing with commonly observed failure modes. You’ll take a comprehensive deep dive into the ingredients that make up a language model, explore various techniques for customizing them such as fine-tuning, learn about application paradigms like RAG (retrieval-augmented generation) and agents, and more. Understand how to prepare datasets for training and fine-tuning Develop an intuition about the Transformer architecture and its variants Adapt pretrained language models to your own domain and use cases Learn effective techniques for fine-tuning, domain adaptation, and inference optimization Interface language models with external tools and data and integrate them into an existing software ecosystem

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 A practical, end-to-end guide for engineers and ML practitioners who want to move beyond LLM demos and build production-grade applications—covering data preparation, model customization, RAG, agents, and system architecture with real-world failure modes. 【Book Arc】 - **Opening (~0%–9%)**: Defines what LLMs are, traces the evolution from GPT-1 to GPT-3 (pre-training → fine-tuning → prompting), and sets up the book's core promise: bridging the gap between prototypes and deployable products. - **Early (~9%–28%)**: Introduces prompting fundamentals, API access patterns (e.g., OpenAI Chat Completion with system/user/assistant/tool roles), and walks through building a first chatbot prototype using LangChain, embeddings, and vector databases (Chroma). - **Early–Middle (~28%–44%)**: Dives into pre-training data—popular datasets (The Pile, FineWeb), cleaning techniques (boilerplate removal with jusText), perplexity-based filtering, and the growing problem of training data disappearing from the internet due to copyright restrictions. - **Middle (~44%–47%)**: Covers data validation and ethical concerns, including PII detection (regex for SIN, credit cards, emails), bias amplification in models, and the debate over whether and how to "fix" biased training data. - **Late (~47%+ per TOC)**: Moves to advanced application paradigms—fine-tuning, domain adaptation, inference optimization, tool integration, and design patterns like multi-LLM architectures, cascades, routers, and task-specialized models, plus programming frameworks (DSPy, LMQL). 【Key Takeaways】 - **LLMs are next-token predictors at heart** (Early): Understanding that training teaches a model to predict the next token over vast text corpora is the foundation for everything else—prompting, fine-tuning, and RAG all build on this core mechanism. - **The GPT lineage shows a clear progression** (Early): GPT-1 introduced pre-training + fine-tuning; GPT-2 popularized zero-shot prompting; GPT-3 scaled up and made few-shot/in-context learning mainstream. This history explains why prompting works and when it fails. - **Prompting is a skill, not a magic trick** (Early): Effective prompting requires understanding roles (system, user, assistant, tool) and being aware of adversarial vulnerabilities—non-experts sometimes outperform LLM experts at subverting models with clever prompts. - **RAG is about retrieval, not guaranteed answers** (Early): Embedding-based similarity search retrieves text that is *similar* to a query, but it may not contain the answer. The LLM must be relied upon to distinguish relevant from irrelevant context—a key failure mode to design around. - **Pre-training data quality is a disappearing resource** (Middle): Major datasets like The Pile and BooksCorpus are being restricted or pulled due to copyright; an estimated 5% of C4 tokens and 28% of its important sources are now off-limits for AI training. This affects what future models can learn. - **Data cleaning is an active design choice** (Middle): Techniques like jusText for boilerplate removal and perplexity sampling (oversampling mid-range perplexity) show that "clean" data is a judgment call, not an objective standard—and it shapes model behavior. - **Bias is baked in and amplified** (Middle): LLMs don't just reflect training data biases—they amplify them (e.g., "radical" co-occurs with "Muslim" more than other religions in The Pile). The debate over fixing data is moot because curation already encodes values, whether acknowledged or not. - **Production LLM systems are multi-component architectures** (Late): Real applications use design patterns like LLM cascades, routers, and task-specialized models, plus programming frameworks (DSPy, LMQL) to orchestrate complex workflows—not just a single model call. 【Reading Tips】 - **Skim the early history chapters** (~0–9%) if you already know what a Transformer is; the GPT-1/2/3 progression is useful context but not actionable. Focus instead on the prompting and API sections (~9–25%) where hands-on examples begin. - **Deep-read the pre-training data chapters** (~28–47%): This is where the book offers unique value—practical data cleaning code (jusText, regex for PII), dataset comparisons, and the ethical debates are rarely covered this concretely elsewhere. - **Pay attention to the RAG prototype walkthrough** (~25–28%): The LangChain + Chroma example is a minimal but complete pattern you can reuse; note the explicit warning that similarity ≠ relevance, which is a common pitfall. - **Treat the bias/fairness section** (~44–47%) as required reading for anyone shipping LLM products: the "no-ship condition" warning and bias amplification discussion are directly relevant to real-world deployment decisions. - **The final chapters on architecture** (per TOC, ~late) are best skimmed for pattern names (cascades, routers, DSPy) rather than memorized—you'll want to revisit them when you actually need to scale a system. 【Coverage Limits】 Excerpts cover roughly the first half of the book (through pre-training data and ethics); the later chapters on fine-tuning, inference optimization, and system architecture are only visible via the table of contents, so detailed takeaways for those sections are not included here.
Excerpt 1
4 A Brief History of LLMs 8 Early Years 8 The Modern LLM Era 10 The Impact of LLMs 11 LLM Usage in the Enterprise 14 Prompting 16 Zero-Shot Prompting 18 Few-...
View in text
Excerpt 2
e data, fol‐ lowed by task-specific supervised fine-tuning. GPT-2 This version was one of the first models to be trained on large-scale web data. This versio...
View in text
Excerpt 3
Lately, model providers have been augmenting the base model by fine-tuning it on much smaller datasets to steer them toward being more aligned with human nee...
View in text
Excerpt 4
for a large number of use cases. In this section we will go through some bias and fairness issues specifically related to the collection and filter‐ ing of p...
View in text
Excerpt 5
to the same sentence in English, as shown by Petrov et al. If you are using a model on domain-specific data like healthcare, finance, law, bio‐ medical, etc....
View in text
Excerpt 6
the concepts (chess) using a domain-specific language (PGN). How will we fare if the concepts were taught in natural language? Let’s explore this in another...
View in text
Excerpt 7
LM to solve this task. Model Debugging and Interpretability Now that we are comfortable with loading LLMs and generating text using them, we would like to be...
View in text
Excerpt 8
s a necessary step after pre-training a model, why don’t we just pre-train the model using an instruction-tuning dataset? It is indeed possible, but these da...
View in text
Tags
AI categories
Artificial IntelligenceAIBackend
Publisher: O'Reilly Media
Publish Year: 2025
Language: English
Pages: 367
File Format: PDF
File Size: 4.3 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…