12/02/26: Lect-12 (cont.)
Overview
Joseph Zambreno explains how supervised fine-tuning and human or programmatic feedback turn a pretrained next-token model such as GPT-3 into an assistant, while comparatively small post-training choices shape response quality and style. He connects assistant behavior to serving costs and hardware: prompt prefill is compute-intensive, token decoding is memory-bandwidth-intensive, and batching, KV-cache size, model sparsity, and quantization affect performance, pricing, and what can be inferred from model releases.
Key takeaways
- SFT and preference-based post-training can make a smaller GPT-3-family model more useful than a larger base model by teaching instruction-following behavior and response preferences.
- A reward model can scale human feedback, but it can reward proxies such as confidence or verbosity rather than correctness, making reward hacking a central risk.
- Chat history is commonly resent as the model's context rather than stored as persistent personal memory, so long conversations increase both context demands and cumulative token costs.
- LLM serving has two distinct bottlenecks: prompt prefill is compute-intensive, while sequential decoding is often memory-bandwidth-intensive and must repeatedly access model weights and KV data.
- Grouped-query attention reduces KV-cache size, but the Llama 3 8B example still requires about 120 KB per token, or roughly 15 GB at a 128K-token context.
- Sparse mixture-of-experts models can have many total parameters but use fewer active parameters per token; quantization and cache compression further reduce memory at a potential accuracy cost.
Chapters
- Pretraining teaches a language model to predict the next token, so a base model may continue a question with more questions instead of answering it.
- An assistant adds instruction-following behavior through post-training and the surrounding software harness, without requiring an entirely different underlying architecture.
- GPT-3's 175 billion parameters illustrate how model scale alone does not make a system easy or useful to interact with.
- OpenAI's 2022 InstructGPT work compared human preferences for post-trained outputs with outputs from models that had not received the same treatment.
- Human raters preferred a smaller, more aggressively post-trained model over a larger model that was less likely to follow instructions.
- ChatGPT's early success was associated with a GPT-3-family model, often described as GPT-3.5, that received substantial post-training.
- Supervised fine-tuning (SFT) uses human-written prompt and ideal-answer pairs, such as answering “What is the capital of France?” with “Paris is the capital of France.”
- The model continues training with the familiar next-token objective, focusing the answer loss on the desired response tokens.
- A relatively small set of curated examples can teach response styles and behaviors that were not reliably learned from broad pretraining data.
- Instead of writing an ideal answer for every prompt, human raters can rank several candidate responses, for example preferring B over A and C.
- Those preference labels can train a separate reward model that scores responses rather than generating them.
- Reward models can scale feedback beyond manually authored answers, but may learn superficial preferences such as longer or more confident-sounding responses.
- In reinforcement learning from human feedback (RLHF), the language model acts as a policy, while a reward model scores its generated responses.
- Proximal Policy Optimization (PPO) updates the policy using reward signals, with a constraint intended to prevent it from straying too far from human-demonstrated behavior.
- Direct Preference Optimization (DPO), discussed in connection with Llama, trains on preference pairs with a classification-style loss and can avoid the more compute-intensive RL loop.
- For coding and mathematics, programmatic tests or verifiable answers can provide feedback without relying exclusively on human ratings.
- A chat interface ultimately supplies a sequence of tokens, with special markers identifying roles, turns, and message boundaries.
- The model input can include a system prompt, user-specific context, and the user's message, not just the text visibly typed into the chat box.
- Llama 3 is one example of a model with a specific chat-token format, while other models use comparable formats with different special tokens.
- The assistant can answer that Joseph Zambreno's stated favorite color is mauve because the conversation history is included again as input.
- A typical chat system does not give the model persistent personal memory by default; it resends the conversation as context for each request.
- Longer histories increase context use and can raise API costs, while attention and KV-cache demands grow as the context expands.
- Temperature changes the sharpness of the next-token probability distribution: lower values favor likely tokens, while higher values encourage more varied choices.
- Top-K sampling limits choices to the K most likely tokens, while top-P sampling selects the smallest token set whose probabilities reach a chosen cumulative threshold.
- After filtering, probabilities are renormalized for a weighted random draw; translation may benefit from low temperature, while poetry may benefit from greater variation.
- Prefill processes the full prompt and builds its attention information, including key and value (KV) data, before the response begins.
- Decode generates tokens sequentially, using the KV cache and reading model parameters repeatedly.
- Prefill is primarily compute-intensive, while decode is often limited by memory bandwidth, producing distinct first-token latency and tokens-per-second measures.
- A decode step must access model parameters from accelerator memory, making memory bandwidth a limit even when substantial compute capacity remains unused.
- For an 8-billion-parameter model stored in 16-bit values, the weights occupy about 16 GB; on an H100-class device with 3.35 TB/s bandwidth, the lecture estimates an idealized upper bound near 209 tokens per second before other costs.
- Serving multiple users in batches can use more of the GPU's compute capacity, but concurrent requests share physical hardware and resources.
- Shared GPU workloads raise research questions about timing and resource side channels, analogous to concerns studied for co-resident CPU processes.
- For the Llama 3 8B example with grouped-query attention, 32 layers, 8 KV heads, and 16-bit values, the lecture estimates about 120 KB of KV-cache data per token.
- That estimate grows with context length, reaching roughly 1 GB at 8K tokens and about 15 GB at 128K tokens for one request.
- Grouped-query attention reduces cache storage by sharing KV values across query heads; without it, the cache requirement would be much larger.
- When many users are batched together, their separate KV caches add substantial memory pressure beyond the shared model weights.
- Input tokens are generally billed separately from output tokens, and the lecture's illustrative example shows output pricing about five times higher than input pricing.
- The difference is consistent with prefill's compute-heavy work and decode's repeated memory access, though market competition also affects actual rates.
- Cached prompts can be cheaper to reuse because stored KV values avoid recomputing the full prefill; some API offerings charge for reserving cache capacity.
- Batch processing may offer lower prices in exchange for less predictable latency.
- A short prompt that requests a very long answer can cost more than a long prompt that requests a brief summary, because generated output tokens are comparatively expensive.
- For API workloads, users can request concise answers, choose the smallest model that meets the task, or accept batch-job delays for lower rates.
- Sending the complete conversation history with every request can make cumulative input grow roughly quadratically across turns, so pruning context can reduce token use.
- Prompt length, answer length, model choice, and cache reuse are practical cost controls for applications billed by token.
- Post-training can reduce confident-sounding errors, but preference scoring does not necessarily verify an answer against ground truth.
- A model's knowledge depends on its pretraining data and any information supplied through its context or external tools; pretraining creates a knowledge cutoff.
- A plausible explanation for why a chip overheated is still a likely text continuation, not proof that the model has a grounded world model of that specific event.
- Longer contexts and outputs can increase both latency and API costs.
- A mixture-of-experts model keeps the usual attention mechanism but routes tokens through selected feed-forward experts, distinguishing total parameters from active parameters.
- Sparse routing can reduce computation per token relative to a dense model, although serving still requires access to the experts' weights.
- Compressed KV caches and low-bit weight quantization, including four-bit representations, reduce memory needs at the cost of some information or accuracy.
- Gemma's model card exposes details such as parameter counts and context length, while Gemini's card describes training data broadly without revealing comparable architectural specifics.
Transcript excerpt
0:00 Let's go ahead and get started. So, where we left off on Monday is starting to understand that transition between basically just a model and an assistant, right? Between a large language model and then maybe a useful product. And some of that is technical, some of that is less technical. Uh where we left off was really talking about sort of the balance between size of model and the amount of compute that was dedicated to training the model and starting to understand some of the scale of the training that was happening with those models and how there is something of a trade-off that for a fixed compute budget. You get to decide how much of that is really dedicated to the particular parameters and how much is really just for the tokens being used for what what we're now referring to as that pre-training process. Well, today's really all about then the post-training side of things. So, a term we hadn't
0:48 really used before. We thought of training as this entirely offline pre model deployment kind of thing. But now when we start to talk about how we go from language models to more useful assistance. Uh it is really about how one kind of tweaks the results of that very large pre-training run to generate a piece of software that is more useful than just what a raw model itself would be able to generate from you. And that this is the discovery that made GPT3 uh you know fairly famous right the understanding that if you train a big enough model just to predict the next token as we're doing it can actually learn new tasks from just the prompt alone and the distinction between zero one and fshot itself isn't that important but other you know it can
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Joseph Zambreno.