Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Chi Wang, Peiheng Hu

Rating 3.5 AI initial rating

No description

AI Reading Assistant

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

AI guide
【One-Line Pitch】 A practical field guide to running large language models in production: it connects Transformer internals to the engineering decisions—batching, KV cache, serving frameworks, and deployment architecture—that determine whether an LLM service is fast, affordable, and reliable. Best for engineers and architects who already know some ML and now need to operate LLMs at scale. 【Book Arc】 - **Opening (~0%–10%)**: Frames the book’s narrow scope—serving and optimization, not ML fundamentals—and situates serving within the model lifecycle (training → deployment → serving → optimization). It explicitly tells readers new to transformers to pair it with a general LLM introduction. - **Early (~10%–30%)**: Establishes serving fundamentals: what model serving is, on-device vs. on-premises vs. cloud trade-offs, and classic paradigms such as single-model and multi-model services. A first vLLM command previews later optimization topics. - **Early–Middle (~30%–45%)**: Opens the model itself from a serving perspective—tokenization, decoder-only Transformer blocks, attention, and autoregressive generation—then walks through manual inference, KV caching, prefill/decode phases, and the jump to vLLM with measured batching gains. - **Middle (~45%–60%)**: Moves into system design: wrapping inference in a real web service, tracking prompts as sequence objects, batching logic, and token streaming workflows that decouple client requests from backend execution. - **Late (beyond ~60%; excerpts thin)**: The table of contents points to enterprise serving layers, build-vs-buy strategies, latency/throughput measurement, and optimization challenges around customer experience and cost—but the excerpts do not cover this material in depth. - **Ending (not covered in excerpts)**: Later chapters on frameworks, practical guidance, and future directions are referenced in the preface but absent from the sampled text. 【Key Takeaways】 - **Serving is a distinct engineering discipline from training** (Early): training minimizes loss; serving maximizes efficient, reliable inference on new input, with different frameworks, constraints, and goals. - **Deployment location is a trade-off, not a default** (Early): on-device serving wins on latency and privacy but loses on compute, power, update cadence, and hardware consistency; when those constraints dominate, serving shifts to on-premises or cloud. - **Serving frameworks earn their place through systems features** (Middle): KV-cache reuse, request scheduling, concurrency, streaming, and cancellation—not just raw inference—are what vLLM and similar tools abstract away. - **Batching is the first big throughput lever** (Middle): the book’s vLLM experiment shows roughly 2.2× throughput from batching four prompts versus running them one by one, with continuous batching cited as a far larger gain. - **Prefill and decode are different workloads** (Middle): understanding the two phases and KV caching is the conceptual key to reasoning about latency and memory later in the book. - **Decouple user requests from model execution** (Middle): representing each prompt as a sequence object lets the backend reorganize work for dynamic batching and prioritization—an architectural pattern, not just an optimization. - **Measure before optimizing** (Early): the book treats latency and throughput metrics and measurement best practices as prerequisites, tying optimization to customer experience and cost efficiency. - **Build vs. buy is a spectrum** (Early): the contents outline options from fully managed foundation-model serving to bringing your own model, code, or serving image—knowing how to build informs the choice even when you won’t build. 【Reading Tips】 - **Skim Chapter 1’s paradigm survey if you already run services**; deep-read the Transformer-from-a-serving-perspective section, since later optimization chapters depend on KV cache and prefill/decode intuition. - **Run the code**: the manual inference and vLLM batching examples are short and make the throughput claims concrete; the timing comparisons are the book’s most tangible payoff. - **Treat the table of contents as a map**: enterprise layering, build-vs-buy, and measurement chapters are where architecture decisions live—budget real time there rather than rushing the early fundamentals. - **Pair with a general LLM text** if attention or transformers are new; the book deliberately explains only enough to connect to serving decisions. 【Coverage Limits】 This guide is based on stratified excerpts covering roughly the first half of the book; the later optimization, enterprise architecture, and framework chapters are visible only through the table of contents and are not summarized here.
Page 7
odel Deployment 136 Option 3: Bring Your Own Model 138 Option 4: Bring Your Own Code 141 Option 5: Bring Your Own Serving Image 144 Option 6: Build Your Own...
View in text
Excerpt 2
on the training data. (inference) on new input efficiently. Computation Extremely compute-intensive, involving iterative model Focused on efficient forward p...
View in text
Excerpt 3
the LLM token generation is handled by the tokenizer, which takes raw input text (prompt) and does the following: • Breaks it into discrete tokens based on a...
View in text
Excerpt 4
ModelManager().load_model(model_name) class ModelManager: def load_model(self, model_name: str = "facebook/opt-125m"): model = AutoModelForCausalLM.from_pret...
View in text
Excerpt 5
rity: cost and latency. A Cost-Optimized Multi-Model Design Let’s first look at a cost-efficient multi-model architecture (Figure 3-11) that derives from the...
View in text
Excerpt 6
curl -s -X POST "http://127.0.0.1:8000/SentimentService" \ -H 'content-type: application/json' \ -H 'ray_serve_multiplexed_model_id: distilbert-sst2' \ -d '{...
View in text
Excerpt 7
and FP8 (8 bit) are lower-precision numerical formats used in deep learning models. Because FP8 is half the size of FP16, computation can be almost twice as...
View in text
Excerpt 8
complex process. Recall what you learned in Chapter 2: when an LLM processes input and then generates output, it goes through two distinct pha‐ ses: prefill...
View in text
Tags
AI categories
AICloud NativeBackend
Publisher: O'Reilly Media
Publish Year: 2026
Language: English
Pages: 374
File Format: PDF
File Size: 6.4 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…