<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by tangbasky on Medium]]></title>
        <description><![CDATA[Stories by tangbasky on Medium]]></description>
        <link>https://medium.com/@tangbasky?source=rss-6c796089b234------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*oLk352YC_lLUE70YHTts-g.png</url>
            <title>Stories by tangbasky on Medium</title>
            <link>https://medium.com/@tangbasky?source=rss-6c796089b234------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 19:21:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tangbasky/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[M-RoPE: One Coordinate Tensor, Three Geometries]]></title>
            <link>https://medium.com/@tangbasky/m-rope-one-coordinate-tensor-three-geometries-4a69d4a4b48c?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/4a69d4a4b48c</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 08:52:14 GMT</pubDate>
            <atom:updated>2026-10-05T08:52:14.677Z</atom:updated>
            <content:encoded><![CDATA[<p>Text, images, and video can share a position-ID tensor without sharing the same notion of position.</p><p>That is the useful way to understand Multimodal Rotary Position Embedding, or M-RoPE: it is a common three-field address format with modality-specific rules.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g3aFIOkRtGemz6ihrCxSUQ.png" /></figure><h3>Start with what RoPE changes</h3><p>Standard one-dimensional RoPE rotates paired query and key channels according to token position. Its key identity makes their dot product depend on a relative offset:</p><p>(Rm q)ᵀ(Rn k) = qᵀR(n−m)k.</p><p>RoPE is therefore not an additive position vector attached to a token embedding. The position controls frequency-dependent rotations inside attention.</p><p>For an image grid, 2D RoPE assigns separate height and width coordinates to channel groups. Attention can then depend on relative vertical and horizontal offsets. This does not make the model invariant to rotating the image; it encodes offsets along the chosen axes.</p><h3>Every modality fills (t,h,w) differently</h3><p>Qwen2-VL’s M-RoPE supplies three position-ID streams:</p><ul><li><strong>Text:</strong> a one-dimensional position is repeated, so a text token at index i receives (i,i,i).</li><li><strong>Image:</strong> time is constant while height and width vary across the patch grid.</li><li><strong>Video:</strong> temporal, height, and width coordinates all vary.</li></ul><p>The common tensor format makes one attention implementation possible. The values preserve modality geometry. Shared shape is not shared meaning.</p><p>The address-form analogy helps: every token fills the same three boxes, but text writes the same street number in all three, an image fills a floor plan, and video adds time. The analogy breaks because these numbers actively rotate query and key channels; they are not passive lookup labels.</p><h3>Interleaving needs continuation</h3><p>In an image-plus-text-plus-video sequence, a new segment begins after the largest coordinate used by the preceding segment. If a visual segment reaches max(t,h,w)=3, subsequent text can begin at (4,4,4). A later image receives an offset beyond the preceding text.</p><p>Without a documented continuation rule, later segments can reuse position ranges unintentionally even though their token indices increase.</p><h3>Video time is sampled time</h3><p>Raw video frame index is not a reliable clock after preprocessing. Frames may be sampled at a chosen FPS and grouped by a temporal patch size. Qwen2.5-VL uses processor metadata to relate a temporal grid step to elapsed time:</p><p>Δpt = Δseconds × tokens_per_second.</p><p>Two clips sampled differently can therefore represent comparable wall-clock intervals. The exact increments are configuration and sampling dependent; do not infer them from the source video’s raw frame numbers.</p><h3>Audit the generator before the rotation</h3><p>When multimodal position behavior looks wrong, inspect the position-ID generator first:</p><ul><li>Do text tokens repeat the same scalar across all axes?</li><li>Is image time constant within the image segment?</li><li>Do spatial coordinates match post-merge ordering?</li><li>Does video time reflect sampled timestamps and temporal grouping?</li><li>Does each new segment continue beyond the previous maximum?</li><li>Does the configured temporal/height/width channel split sum to the rotary dimension?</li></ul><p>Rotation code can be mathematically correct while receiving semantically incorrect coordinates. M-RoPE works because the coordinate contract is maintained from processor metadata to attention.</p><p>For the full 1D, 2D, and 3D derivation plus interleaved implementation, see <em>LLM Engineering in Practice</em>:</p><ul><li><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">Amazon</a></li></ul><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><ul><li><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">Leanpub</a></li></ul><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4a69d4a4b48c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your Reward Curve May Be Celebrating the Bug]]></title>
            <link>https://medium.com/@tangbasky/your-reward-curve-may-be-celebrating-the-bug-be3999da7711?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/be3999da7711</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 05 Oct 2026 08:51:53 GMT</pubDate>
            <atom:updated>2026-10-05T08:51:53.806Z</atom:updated>
            <content:encoded><![CDATA[<p>A steadily rising reward curve is psychologically powerful. It is also evidence of only one thing: the optimizer is getting better at the measured objective.</p><p>If the reward is incomplete, biased, or exploitable, training can improve the dashboard while degrading the product.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jgDM56IFkp9u2llN6DpvrA.png" /></figure><h3>The evaluator defines the shortcut</h3><p>Imagine a sentiment reward model trained on heavily unbalanced data. It learns that negative or refusing answers are usually “safe.” A policy optimized against that evaluator can raise reward by producing the same conservative pattern everywhere.</p><p>The run is not malfunctioning. It is solving the objective supplied to it.</p><p>This is reward overoptimization: an imperfect proxy improves while a more trustworthy or held-out signal eventually stalls or declines. KL regularization can discourage large drift, but proximity to a reference does not prove that the remaining movement is beneficial.</p><h3>Put three lanes on one timeline</h3><p>A useful post-training dashboard synchronizes three kinds of evidence.</p><p><strong>Reward lane.</strong> Plot total reward and every component separately. Include outcome-verifier scores, style or safety terms, penalties, and the fraction of outputs hitting exact reward boundaries. A stable total can hide one component overpowering another.</p><p><strong>Optimization lane.</strong> Track reference KL, entropy, response length, clip fraction, current-to-old ratio distributions, gradient norms, and — when PPO uses a critic — value error. These metrics tell you how the policy is moving and whether the estimator is under stress.</p><p><strong>Behavior lane.</strong> Evaluate frozen held-out prompts with independent checks: correctness, refusal rate, verbosity, diversity, formatting, safety, and task-specific human judgments. These metrics decide whether the checkpoint is useful.</p><p>Align all three by update or token count. Then suspicious transitions become visible: reward rises as entropy collapses; a length bonus produces verbosity; KL stays moderate while one held-out category falls; clip fraction spikes before quality regresses.</p><h3>Use support diagnostics carefully</h3><p>Repeated sampling can reveal whether the base policy already places some probability on successful responses. pass@k asks whether at least one of k samples succeeds. Best-of-N asks how well a selector can exploit a candidate set.</p><p>High pass@N with low pass@1 suggests that useful outputs exist but probability mass is poorly allocated — a promising setting for post-training or selection. Yet zero observed success does not prove success has zero probability, and no universal percentage says RL will work. The answer depends on sample count, evaluator quality, task diversity, and whether the training signal generalizes.</p><h3>Define a stop rule before the run</h3><p>Choose held-out gates before optimization: minimum correctness, maximum refusal increase, length band, safety constraints, and category-level floors. Treat training reward as a steering signal, not the release criterion.</p><p>When reward rises but held-out quality falls, do not immediately tune the learning rate. First localize the divergence:</p><ul><li>Which reward component changed?</li><li>Which behavior slice regressed?</li><li>Did entropy, length, KL, or ratio tails move at the same time?</li><li>Can the suspected shortcut be reproduced with targeted prompts?</li><li>Does an ablation of the reward term remove it?</li></ul><p>The safest checkpoint is not the one that maximizes the proxy. It is the one that satisfies the behavioral contract while using reward as one imperfect instrument among several.</p><p>For the complete engineering workflow for reward design, PPO/GRPO monitoring, and capability diagnostics, see <em>LLM Engineering in Practice</em>:</p><ul><li><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">Amazon</a></li></ul><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><ul><li><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">Leanpub</a></li></ul><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be3999da7711" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[PPO Has Three Policies, Not One Model with Aliases]]></title>
            <link>https://medium.com/@tangbasky/ppo-has-three-policies-not-one-model-with-aliases-3875bbba66e5?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/3875bbba66e5</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 14:55:02 GMT</pubDate>
            <atom:updated>2026-09-21T14:55:02.567Z</atom:updated>
            <content:encoded><![CDATA[<p>A language-model PPO diagram often contains three nearly identical networks. That visual similarity hides a crucial fact: the <strong>current policy</strong>, <strong>old policy</strong>, and <strong>reference policy</strong> answer different questions.</p><p>Confuse them, and a run may still execute. Your interpretation of its ratios, KL curve, and stability will be wrong.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n7_kybaQXTqBQX6LE3Z8Hw.png" /></figure><h3>The current policy is the learner</h3><p>The current policy, πθ, is the network receiving policy-gradient updates. For a sampled token, PPO forms</p><p>r_t(θ) = πθ(a_t|s_t) / πold(a_t|s_t).</p><p>That denominator is not a philosophical ideal. It is the frozen snapshot associated with the rollout data. It lets the optimizer ask: <em>How much more or less likely is the current model to produce this sampled action than the behavior model that produced it?</em></p><p>PPO clips this ratio inside its surrogate objective. When the advantage is positive, the objective stops rewarding arbitrarily large increases beyond the clipping region; with a negative advantage, it analogously limits the sampled contribution.</p><p>But this is not a hard probability fence. Clipping saturates a term in the objective for sampled actions. Shared parameters, multiple minibatches, and later optimizer steps can still move probabilities. “Clip range = 0.2” does not mean every token probability changes by at most 20 percent.</p><h3>The old policy is a receipt</h3><p>Think of πold as the receipt for the data batch: it records the behavior probabilities under which those tokens were sampled. After collecting a rollout batch, it stays fixed while the current policy takes one or more optimization passes. A later rollout phase refreshes it.</p><p>That makes current-versus-old ratios a local training diagnostic. Ratio tails and clip fraction tell you whether the optimizer is trying to move far from the rollout distribution represented by this batch.</p><h3>The reference policy is an anchor</h3><p>The reference policy, πref, usually remains frozen for much longer. In language-model RLHF, it commonly anchors the policy near a supervised model through a KL penalty such as</p><p>J = Lclip - β DKL(πθ || πref).</p><p>This comparison asks a different question: <em>How far has the trained model drifted from the chosen baseline?</em></p><p>The reference is not refreshed merely because a rollout batch changes. And its KL penalty does not guarantee safety, fluency, or immunity to reward hacking. It assigns a cost to drift under a particular estimator and coefficient.</p><h3>The critic is a fourth object</h3><p>PPO also trains a value model, Vφ, to predict expected return from a state. Generalized advantage estimation combines temporal-difference residuals across steps, trading bias against variance through its decay parameters. The critic is neither a policy nor the reward source; it supplies a learned baseline for deciding whether sampled outcomes were better or worse than expected.</p><p>So an operational PPO inventory is:</p><ul><li>πθ: updated by the policy objective;</li><li>πold: rollout snapshot in the importance ratio;</li><li>πref: long-lived anchor in the KL term;</li><li>Vφ: learned return baseline;</li><li>reward source: the evaluator of completed behavior.</li></ul><p>Log them under those roles. Record when the old snapshot refreshes, which checkpoint defines the reference, how KL is estimated, and which model produced reward. Then read clip fraction and KL together: one describes pressure against a local surrogate boundary; the other describes drift from a chosen anchor.</p><p>The distinction sounds like bookkeeping. In practice, it is the difference between seeing what the optimizer is doing and merely seeing numbers move.</p><p>For the complete post-training treatment — including reward models, GAE, rollout scheduling, PPO, DPO, GRPO, DAPO, and GSPO — see <em>LLM Engineering in Practice</em>:</p><ul><li><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">Amazon</a></li></ul><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><ul><li><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">Leanpub</a></li></ul><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3875bbba66e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[GRPO Fires the Critic — but Hires More Rollouts]]></title>
            <link>https://medium.com/@tangbasky/grpo-fires-the-critic-but-hires-more-rollouts-66871c745247?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/66871c745247</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 21 Sep 2026 14:54:36 GMT</pubDate>
            <atom:updated>2026-09-21T14:54:36.679Z</atom:updated>
            <content:encoded><![CDATA[<p>Calling GRPO “PPO without a critic” is accurate in the way that calling a bicycle “a car without an engine” is accurate: it identifies an absent component but misses the replacement mechanism.</p><p>GRPO is not baseline-free. It builds a baseline from <strong>peer responses sampled for the same prompt</strong>.</p><h3>Grade each response against its heat</h3><p>For one prompt, GRPO samples a group of G responses, evaluates each response with reward ri, and standardizes within the group:</p><p>Ai = (ri - mean(r)) / (std(r) + ε).</p><p>A response above its peer-group mean receives a positive relative advantage; one below receives a negative advantage. The mean is an empirical baseline, not the reference policy. GRPO still commonly retains a separate frozen reference for KL regularization and an old rollout policy for current-to-old ratios.</p><p>The trade is immediate. PPO spends memory and training effort on a value model. GRPO spends generation compute on multiple responses per prompt. Removing the critic can be attractive for large language models, but the saving is not free throughput.</p><p>There is also a sharp failure mode: if every response in a group receives the same reward, the standardized advantages contain no useful relative signal. This can happen when a binary verifier sees an all-correct or all-incorrect group. Increasing group size may help expose variation, but it also increases rollout cost.</p><h3>DAPO changes four different levers</h3><p>DAPO should not be read as one monolithic improvement. Its reported system changes four distinct parts of the path:</p><ol><li><strong>Asymmetric clipping</strong> gives upward probability changes more room than downward changes. The clip still saturates a surrogate contribution; it is not a hard cap on final probabilities.</li><li><strong>Dynamic sampling</strong> filters groups with no reward variation and replenishes the batch. That buys more informative updates with extra generation and depends on the reward structure.</li><li><strong>Token-level aggregation</strong> gives each valid token equal weight across the batch. Compared with per-response averaging, longer responses receive more total weight. This is aggregation, not token-level credit assignment.</li><li><strong>Overlength shaping</strong> replaces an abrupt length failure with a softer penalty. It improves the optimization surface while also encoding a preference about length.</li></ol><p>These interventions target exploration, estimator weighting, and reward shape separately. An ablation should preserve that separation.</p><h3>GSPO moves the ratio to the sequence</h3><p>Standard GRPO uses token-specific current-to-old ratios. GSPO instead defines a length-normalized sequence ratio, expressible as the exponential of the mean token log-ratio:</p><p>si = exp[(1/|oi|) Σt log(πθ(oit|...)/πold(oit|...))].</p><p>One sequence-level ratio is then used across the response. This aligns clipping and weighting at sequence granularity. The GSPO paper reports improved stability and efficiency in its evaluated workloads, including mixture-of-experts training, but that evidence does not establish universal dominance.</p><p>The sequence ratio is also a designed surrogate, not the unnormalized product commonly used as an exact sequence importance weight. Length normalization changes the quantity deliberately.</p><h3>Compare algorithms by four questions</h3><p>Before choosing among these methods, ask:</p><ul><li>Where does the baseline come from: a critic or a response group?</li><li>Which samples enter a batch, including how zero-variance groups are handled?</li><li>What receives equal statistical weight: responses, tokens, or sequences?</li><li>At what granularity is the current-to-old ratio clipped?</li></ul><p>Those questions reveal the real resource and estimator choices. The acronym alone does not.</p><p>For full objectives, failure cases, and implementation guidance across preference-based post-training, see <em>LLM Engineering in Practice</em>:</p><ul><li><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">Amazon</a></li></ul><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><ul><li><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">Leanpub</a></li></ul><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66871c745247" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Cancellation That Makes DPO Direct]]></title>
            <link>https://medium.com/@tangbasky/the-cancellation-that-makes-dpo-direct-4c99a5bc361d?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/4c99a5bc361d</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Sat, 19 Sep 2026 14:38:28 GMT</pubDate>
            <atom:updated>2026-09-19T14:38:28.383Z</atom:updated>
            <content:encoded><![CDATA[<p>Direct Preference Optimization is often summarized as “RLHF without a reward model.” That is operationally useful and conceptually incomplete.</p><p>DPO removes the need to train an explicit reward model and run online policy rollouts. It does so by rewriting a KL-regularized reward objective until the learnable quantity becomes a <strong>chosen-versus-rejected margin relative to a reference policy</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wrIOjqAo0INgO-v2j-iBrg.png" /></figure><h3>Start from a regularized optimum</h3><p>For prompt x and response y, the optimal policy under a reward with KL regularization has the form</p><p>π*(y|x) = πref(y|x) exp(r(x,y)/β) / Z(x).</p><p>Here, πref is the reference policy, β controls regularization, and Z(x) is a partition function that normalizes probabilities over all possible responses. Solving for reward gives</p><p>r(x,y) = β log[π*(y|x)/πref(y|x)] + β log Z(x).</p><p>The nuisance term is log Z(x). Computing it would require accounting for the response space. DPO&#39;s key move is not to estimate it.</p><h3>Same prompt, same nuisance term</h3><p>Suppose the dataset says response yw is preferred to response yl for the same prompt x. Subtract their rewards. Because both responses share x, both contain the same β log Z(x), which cancels:</p><p>r(x,yw) - r(x,yl) = β[(log πθ(yw|x) - log πref(yw|x)) - (log πθ(yl|x) - log πref(yl|x))].</p><p>A logistic pairwise loss can now increase this reference-relative margin directly. The model learns to make the winner more favored than the loser, after accounting for how much the reference already favored each response.</p><p>This gives DPO a strict data contract: the winner and loser must be compared under the same conditioning prompt. Pairing an attractive answer from one prompt with a bad answer from another does not preserve the cancellation.</p><h3>What DPO removes — and what remains</h3><p>DPO removes several moving parts from the standard online pipeline: no separately trained scalar reward model, no critic, and no reward-guided rollout loop during optimization. That can simplify infrastructure.</p><p>It does not remove preference assumptions. The pair still compresses a judgment into winner and loser. Graded confidence, ties, and competing dimensions such as correctness, style, and safety require richer labels or modified objectives.</p><p>It also does not create coverage. Offline training can only learn from the contrasts represented in its dataset. If a desirable response family never appears, DPO does not explore it during training. Dataset bias becomes policy bias with a mathematically tidy loss.</p><p>Finally, β is not a portable “strength” dial in isolation. Its effect interacts with learning rate, data separability, sequence-length treatment, and the exact loss convention. Compare runs only after documenting those choices.</p><p>The best way to debug DPO is therefore to inspect margins, not just aggregate loss. Ask whether the chosen-reference margin rises, whether rejected likelihood collapses indiscriminately, whether results hold on prompt families outside the training pairs, and whether calibration changes across preference categories.</p><p>DPO is direct because one prompt-specific term cancels. Respect that derivation, and it becomes a powerful engineering simplification. Ignore the pairing and coverage assumptions, and the simplicity becomes camouflage.</p><p>For the full derivation and comparison with reward-model PPO and grouped policy optimization, see <em>LLM Engineering in Practice</em>:</p><ul><li><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">Amazon</a></li></ul><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><ul><li><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">Leanpub</a></li></ul><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4c99a5bc361d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Response-Only Loss Masks Credit, Not Context]]></title>
            <link>https://medium.com/@tangbasky/response-only-loss-masks-credit-not-context-db1c541a32b0?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/db1c541a32b0</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Sat, 19 Sep 2026 14:38:02 GMT</pubDate>
            <atom:updated>2026-09-19T14:38:02.265Z</atom:updated>
            <content:encoded><![CDATA[<p>A prompt token can receive zero loss and still influence every response token that follows it.</p><p>That is the key to response-only supervised fine-tuning. The mask changes which token predictions are graded. It does not hide the prompt from attention, and it does not freeze the pretrained model’s knowledge.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGEVU29-GXrLuskdQQ9d-Q.png" /></figure><p><em>Three separate questions matter: which tokens are visible, which predictions are scored, and which parameters are updated.</em></p><h3>The open-book exam model</h3><p>Imagine an open-book exam. The prompt is the reference material; the response is the answer sheet. The grader scores only the answer lines, but the student can read the reference while writing them.</p><p>Response-only SFT works similarly. The model receives a combined sequence containing system message, user prompt, separators, and assistant response. Causal attention lets each response position attend to earlier prompt positions. The labels for prompt positions are then assigned zero weight — often represented by the ignore index -100—while response positions retain next-token targets.</p><p>The analogy breaks at learning. A student’s answer does not rewrite every page of the textbook. Gradient descent does: loss on response tokens backpropagates through shared transformer parameters used for prompts, responses, and unrelated capabilities.</p><h3>Three mechanisms that should not be collapsed</h3><p><strong>Visibility:</strong> Prompt tokens are input context. If the answer depends on a customer record, instruction, or schema in the prompt, response tokens must attend to it.</p><p><strong>Direct supervision:</strong> A prompt position with an ignored label contributes no direct cross-entropy term. The trainer is not rewarded for reproducing the user’s words at those positions.</p><p><strong>Parameter updates:</strong> The response loss differentiates through the computation that used prompt context. Unless the base parameters are frozen, those gradients update the same weights that support general language and knowledge behavior.</p><p>This is why “we masked the prompt” cannot justify “the base model will retain everything.” Retention is an empirical outcome. Measure it on held-out general, domain, safety, format, and language slices, or preserve important behavior through replay data and other regularization.</p><h3>The one-token shift can quietly break the objective</h3><p>Causal language models predict the next token. A correct collator must align input positions, shifted labels, message boundaries, and special tokens. Common mistakes include supervising an assistant delimiter but not the first answer token, masking part of the answer, or treating a template token as belonging to the wrong speaker.</p><p>Run a tiny inspection batch before training:</p><ul><li>decode input_ids and labels side by side;</li><li>replace ignored labels with a visible placeholder;</li><li>confirm the first intended response token has a prediction target at the preceding position;</li><li>verify padding is ignored;</li><li>verify every assistant turn intended for training is included;</li><li>check truncation does not leave a response mask without its prompt or vice versa.</li></ul><p>A small batch should also be able to overfit. Failure there points toward masks, sampling, optimizer updates, or template construction before it points toward model capacity.</p><h3>Packing adds another boundary</h3><p>Packing concatenates several records to reduce padding waste. It creates separate choices:</p><ul><li>where position identifiers restart or continue;</li><li>whether attention is blocked across record boundaries;</li><li>where each record’s prompt and response masks begin and end;</li><li>whether loss is averaged per supervised token, per record, or per task.</li></ul><p>Block-diagonal attention prevents one record from reading another. It does not automatically give short and long responses equal weight. Under token averaging, a 500-token response contributes more supervised positions than a 20-token response.</p><p>The clean mental model is: <strong>the attention mask controls information flow; the loss mask controls direct credit; the reduction controls statistical weight.</strong> None of those alone controls knowledge retention.</p><p>Chapter 8 of <em>LLM Engineering in Practice</em> connects this objective to packing, checkpoint selection, LoRA, and behavioral regression testing.</p><p>Amazon:</p><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><p>Leanpub:</p><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db1c541a32b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Your SFT Loss Curve Is an Alert, Not a Diagnosis]]></title>
            <link>https://medium.com/@tangbasky/your-sft-loss-curve-is-an-alert-not-a-diagnosis-007847f45524?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/007847f45524</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 15:11:20 GMT</pubDate>
            <atom:updated>2026-09-10T15:11:20.561Z</atom:updated>
            <content:encoded><![CDATA[<p>An upward loss curve can mean the learning rate is too high. It can also mean sequences got longer, the data mixture changed, the loss denominator changed, a curriculum advanced, numeric precision failed, or the logger is wrong.</p><p>The line is evidence. The pathology name is an inference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Sb1BjNkvHmTjoHSZPEdNZw.png" /></figure><p><em>A useful diagnosis pairs each observed symptom with the next test that could rule causes in or out.</em></p><h3>First define what the curve measures</h3><p>Loss is like a dashboard warning light: it tells you something in a defined system has changed, but it does not identify the broken component. The analogy breaks because loss is not merely a sensor. It is the exact objective being optimized, aggregated according to a reduction rule.</p><p>Before comparing two curves, document:</p><ul><li>which token positions are supervised;</li><li>whether labels use response-only or full-sequence loss;</li><li>whether the numerator sums token losses globally;</li><li>whether the denominator is supervised tokens, examples, tasks, or local worker counts;</li><li>tokenizer, label smoothing, chat template, sequence packing, and truncation;</li><li>how distributed workers combine totals.</li></ul><p>Absolute values are not portable across different contracts. A response-only run with short answers and a full-sequence run with long prompts are not measuring the same prediction set.</p><h3>Near-zero loss does not prove collapse</h3><p>A very low training loss usually says the model predicts its supervised training tokens with high confidence. That can indicate memorization. It does not by itself prove that generation has collapsed to one token or one answer.</p><p>Collapse is behavioral. Test output diversity, prompt sensitivity, termination, task accuracy, format compliance, and held-out generation. Conversely, a model can generate repetitive or bad answers while aggregate training loss looks ordinary if the affected slice is small.</p><p>Do not give a curve a semantic story — “the staircase is the model learning JSON” — without an unseen JSON-format evaluation. Staircases can come from evaluation cadence, scheduler boundaries, data ordering, or mixture changes.</p><h3>Split fit from generalization</h3><p>When a task fails, begin with one exact training record using the same chat template and decoding constraints as evaluation.</p><p>If the model fails on that record, confirm it was sampled and that its answer tokens were supervised. Try to overfit a tiny batch. Inspect labels, masks, gradient norms, optimizer updates, checkpoint loading, and numerical stability. Only after the path works should you increase the update budget or blame model capacity.</p><p>If the model succeeds on training records but fails on held-out prompts, you have a generalization gap. Possible causes include narrow coverage, label artifacts, distribution shift, capacity limits, conflicting examples, or decoding differences. Compare with the base model and test multiple prompt variations before calling the task “unlearnable.”</p><p>This two-axis view is more useful than “underfit versus overfit” from aggregate curves alone:</p><ul><li>training-record fit asks whether the optimization and data path worked;</li><li>held-out behavior asks whether the learned pattern transfers.</li></ul><h3>Packing can change the objective without changing the picture</h3><p>Packing concatenates records to reduce padding. Four controls remain independent:</p><ol><li>record-boundary position handling;</li><li>block-diagonal attention when cross-record reading is forbidden;</li><li>response-loss masks for every record;</li><li>reduction per supervised token, record, or task.</li></ol><p>Blocking attention leakage does not equalize examples. With token averaging, a long response contributes more labeled positions than a short response. A packing implementation can therefore preserve attention boundaries while silently changing task weighting through truncation or sampling.</p><p>Compare packing with a padding baseline at the same supervised-token and optimizer-update budget. Speed is beneficial only if the statistical objective stays intentional.</p><h3>Put changes on the same timeline</h3><p>Overlay learning-rate schedule, gradient norm, sequence-length buckets, curriculum stages, mixture versions, checkpoint restores, and software changes on the loss chart. Also log loss by task, source, length, language, and format.</p><p>Then ask the diagnostic question that a curve alone cannot answer: <strong>what observation would distinguish the competing explanations?</strong></p><p>Chapter 8 of <em>LLM Engineering in Practice</em> supplies the complete SFT path — from collated labels to training-record probes, held-out slices, and remediation.</p><p>Amazon:</p><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><p>Leanpub:</p><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=007847f45524" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LoRA Saves Parameter State — Not Every Part of Training]]></title>
            <link>https://medium.com/@tangbasky/lora-saves-parameter-state-not-every-part-of-training-8582919b732b?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/8582919b732b</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Thu, 10 Sep 2026 15:10:56 GMT</pubDate>
            <atom:updated>2026-09-10T15:10:56.034Z</atom:updated>
            <content:encoded><![CDATA[<p>A LoRA adapter can contain a tiny fraction of a model’s parameters while the training job still performs a large-model forward and backward pass.</p><p>Both statements are true because “cost” is not one number.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/730/1*9f22cFxTKubiIo2x7rZeBQ.png" /></figure><p><em>LoRA changes the trainable update path; it does not remove the frozen base computation.</em></p><h3>The correction-sheet model</h3><p>Imagine a frozen architectural blueprint with a transparent correction sheet laid on top. The original drawing stays untouched; the sheet contains only the changes required for one project.</p><p>For a linear layer with weight W ∈ R^(d×k), full tuning learns a dense update with dk values. LoRA freezes W and writes the correction as two factors:</p><p>h = Wx + (α/r) BAx</p><p>where A ∈ R^(r×k) and B ∈ R^(d×r). The adapter has r(k+d) trainable values. When r is far smaller than d and k, that can be dramatically smaller than dk.</p><p>The analogy breaks because the correction sheet is not free to use. The system still computes the base path, stores activations needed for backpropagation, and executes the additional low-rank operations.</p><h3>Why zero initialization matters</h3><p>A common convention initializes A randomly and B to zero. Then BA=0, so the adapter contributes nothing at step zero and the initial function matches the base model. Other conventions may swap which factor begins at zero.</p><p>Both factors become trainable. After the first update, the low-rank path starts to change the output. The frozen W does not receive an optimizer update, but gradients must still flow through the layer to train adapters elsewhere.</p><p>The scale α/r controls the adapter contribution. It makes rank experiments easier to organize; it does not make rank or learning rate invariant. Changing rank changes both capacity and optimization behavior.</p><h3>Keep four resource ledgers</h3><p><strong>Trainable state.</strong> LoRA reduces adapter parameters, their gradients, and optimizer states. This is usually the clearest memory saving.</p><p><strong>Checkpoint and task storage.</strong> A small adapter can be stored separately from one shared base model. Multiple tasks can reuse that base instead of duplicating a fully tuned checkpoint.</p><p><strong>Activation memory.</strong> Activations depend heavily on batch size, sequence length, hidden width, checkpointing, attention implementation, and which layers require backward information. They do not shrink according to r(d+k)/dk.</p><p><strong>Runtime and communication.</strong> Frozen weights still participate in matrix multiplication. Adapter kernels add work, and distributed communication depends on sharding and implementation. A large parameter reduction can yield a much smaller wall-clock improvement — or occasionally lose efficiency through poor kernel utilization.</p><p>This is why “LoRA trains 0.1% of parameters” is not a complete hardware forecast.</p><h3>Rank is not the only capacity knob</h3><p>The original LoRA experiments often targeted query and value projections. Modern recipes may adapt Q, K, V, attention output, and MLP projections.</p><p>A rank of 16 applied to two modules is a different hypothesis from rank 16 applied to every linear layer. Placement determines where adaptation capacity exists; rank determines the maximum correction rank at each selected matrix.</p><p>Record at least:</p><ul><li>base-model revision;</li><li>target module names;</li><li>rank, alpha, dropout, and initialization;</li><li>learning rate and optimizer;</li><li>whether biases or norms are trainable;</li><li>quantization and compute dtype;</li><li>adapter merge status.</li></ul><p>Quality relative to full tuning is empirical. A low-rank subspace can be sufficient for one task and restrictive for another. Compare held-out target behavior and retained capabilities, not just training loss.</p><h3>Deployment finishes the decision</h3><p>An adapter can be merged into the base weight for a static deployment or loaded dynamically so several adapters share one base. Merging can simplify the inference graph; dynamic loading supports task switching. Quantized bases and serving kernels introduce compatibility constraints that must be tested.</p><p>The practical rule is: <strong>use LoRA’s algebra to estimate trainable state, then measure activation memory, runtime, quality, and serving behavior separately.</strong></p><p>Chapter 8 of <em>LLM Engineering in Practice</em> connects this resource decision to SFT loss masks, diagnostics, and checkpoint evaluation.</p><p>Amazon:</p><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><p>Leanpub:</p><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8582919b732b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Curriculum Learning Is a Sampling Policy, Not a Universal Lesson Plan]]></title>
            <link>https://medium.com/@tangbasky/curriculum-learning-is-a-sampling-policy-not-a-universal-lesson-plan-246fec01ba8f?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/246fec01ba8f</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:33:41 GMT</pubDate>
            <atom:updated>2026-09-07T13:33:41.149Z</atom:updated>
            <content:encoded><![CDATA[<p>Sort SFT examples by base-model loss and train from low loss to high loss. That sounds like an easy-to-hard curriculum.</p><p>It may also schedule clean clichés first, useful rare styles last, and mislabeled examples as the “hardest” material. Loss does not know which story you intended.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fk_q5Lc_3JJEhvKtQUSVZw.png" /></figure><p><em>A curriculum claim is credible only when ordering is isolated from data, token, and update-budget changes.</em></p><h3>Think in probabilities, not school grades</h3><p>A school syllabus often introduces prerequisites before advanced lessons. Curriculum learning borrows that intuition by changing which examples are likely to appear as training progresses.</p><p>The analogy breaks because example difficulty is not stable. A problem can be easy for one base model and hard for another. It can become easy after a few thousand updates. High loss can reflect difficulty, but also length, ambiguity, rare wording, noisy labels, or a wrong answer.</p><p>Operationally, a curriculum is a time-varying sampling distribution:</p><p>p(example | training step)</p><p>Once stated that way, the engineering questions become clearer: how is the score measured, how do weights change, what coverage is preserved, and which baseline receives the same data and compute?</p><h3>Choose a proxy and audit what it means</h3><p><strong>Loss-based proxy.</strong> Score each response using the base model or an initial checkpoint. Normalize the same way across samples. Inspect high- and low-loss slices by length, task, language, format, source, and label quality. High average token loss is not automatically useful hardness.</p><p><strong>Rollout-based confidence.</strong> Generate multiple answers and calculate the fraction accepted by a verifier. This is meaningful when correctness can be checked reliably — tests for code, exact answers for some math, or a validated rubric. Open-ended writing requires a judge whose bias and variance become part of the proxy.</p><p><strong>Dynamic proxy.</strong> Recompute scores as the learner changes. This reduces staleness but adds inference cost and a feedback loop: the model’s current weaknesses alter future data exposure. Log scorer and learner versions together.</p><p>The proxy is a measurement instrument. Calibrate it before building an elaborate schedule around it.</p><h3>Isolate the curriculum effect</h3><p>At minimum, compare:</p><ul><li><strong>shuffled baseline:</strong> the same examples sampled without difficulty order;</li><li><strong>static mixture:</strong> fixed difficulty-group weights throughout training;</li><li><strong>curriculum:</strong> time-varying weights using the proposed ordering;</li><li>optionally, <strong>random-rank control or anti-curriculum:</strong> the same scheduling machinery with meaningless or reversed ranks.</li></ul><p>Hold constant the total supervised tokens, optimizer updates, batch semantics, checkpoint intervals, and evaluation suite. If the curriculum processes more tokens or repeats a valuable slice more often, the experiment no longer isolates ordering.</p><p>The chapter’s illustrative 70/20/10 early mixture is exactly that — an illustration. It is not a recommendation. Linear and sigmoid transitions are implementation options, not required mathematical forms.</p><h3>Preserve coverage while the weights move</h3><p>An easy-to-hard schedule can forget earlier slices if “easy” examples disappear. Keep enough core data to measure and limit regressions, but tune that fraction locally rather than copying a universal percentage.</p><p>Log every transition on the same timeline as loss, gradient norms, task metrics, and sequence lengths. Otherwise an abrupt mixture change can look like optimizer instability.</p><p>Use a development set to adjust the schedule and keep the final test set untouched. If the schedule reacts directly to final-test performance, the test set becomes part of training policy.</p><h3>Decide whether the complexity earned its place</h3><p>A dynamic curriculum adds scoring passes, manifests, state, monitoring, and replay difficulty. It must beat a shuffled or fixed alternative by enough to justify those costs on target and regression slices.</p><p>A negative result is useful. It may mean the base model already handles the supposed prerequisites, the proxy measures noise, or the data mixture matters more than order.</p><p>The durable rule is: <strong>a curriculum is a hypothesis about sampling over time. Match its data and compute budget, audit its difficulty proxy, and make it earn complexity against a shuffled baseline.</strong></p><p>Chapter 8 of <em>LLM Engineering in Practice</em> connects curriculum experiments to loss diagnostics, checkpoint selection, and SFT configuration semantics.</p><p>Amazon:</p><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><p>Leanpub:</p><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=246fec01ba8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[There Is No Universal SFT Data Ratio]]></title>
            <link>https://medium.com/@tangbasky/there-is-no-universal-sft-data-ratio-480934770de1?source=rss-6c796089b234------2</link>
            <guid isPermaLink="false">https://medium.com/p/480934770de1</guid>
            <category><![CDATA[llm]]></category>
            <dc:creator><![CDATA[tangbasky]]></dc:creator>
            <pubDate>Mon, 07 Sep 2026 13:32:54 GMT</pubDate>
            <atom:updated>2026-09-07T13:32:54.445Z</atom:updated>
            <content:encoded><![CDATA[<p>A mixture with 25% math, 25% code, 25% general conversation, and 25% domain data looks balanced. But balanced for what model, at what starting capability, under which deployment goal?</p><p>Equal dataset slices can be deeply unequal learning interventions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*w07_lINvsOecLl9MUD1jDw.png" /></figure><p><em>The curves are recipe-specific evidence that capabilities scale differently — not a ratio table to copy.</em></p><h3>A mixture is a control surface</h3><p>Think of SFT composition as an audio mixing board. If the vocals are already loud and the bass is missing, setting every channel to the same level does not create balance. You first listen, then adjust the deficient channel, then listen again for distortion elsewhere.</p><p>The analogy breaks because model capabilities are not independent channels. Math examples can affect repetition, code data can change instruction style, and general dialogue can overwrite or reactivate shared representations. The useful part of the analogy is the feedback loop: measure, adjust, and regression-test.</p><p>SFT — supervised fine-tuning — teaches a pretrained model desired prompt-to-response behavior. Its mixture should therefore begin with a behavior map, not a folder count.</p><h3>Define slices before ratios</h3><p>Attach metadata where feasible:</p><ul><li>task family and subtask;</li><li>language and domain;</li><li>prompt format and length;</li><li>response length and structure;</li><li>single-turn versus multi-turn;</li><li>source and license or authorization status;</li><li>synthetic generator, sampling settings, and verifier;</li><li>safety, robustness, or recovery behavior being targeted.</li></ul><p>Then build held-out evaluations on the same axes. Without those slices, “add more reasoning data” cannot be distinguished from “add longer responses,” “add a particular teacher’s style,” or “add one benchmark’s templates.”</p><p>Imported datasets will have incomplete metadata. Mark inferred labels as inferred rather than manufacturing certainty.</p><h3>Data amount and data ratio are different experiments</h3><p>The chapter discusses a study of math, code, and general SFT across several LLaMA-family sizes. In that tested setup, capabilities showed different scaling patterns. General tasks plateaued earlier than math or code in some conditions. Mixed training helped under limited data, while task conflicts appeared when more task-specific data was available. The absolute amount of composition data often mattered more than small ratio changes.</p><p>These findings suggest experiment design, not universal defaults.</p><p>If a team changes math from 20% to 40% while keeping the total number of samples fixed, it removes samples from other tasks. If it doubles math while preserving every other task, it changes total training volume and possibly step count. Those interventions answer different questions.</p><p>Record token exposure, example counts, sequence lengths, sampling with replacement, and total optimization steps. A pie chart alone hides the actual training dose.</p><h3>Use a capability-driven loop</h3><p>A practical workflow is:</p><ol><li><strong>Baseline by slice.</strong> Evaluate the base model on target behaviors, including short-context regressions, writing quality, refusal calibration, and domain tasks.</li><li><strong>Allocate to deficits.</strong> Add high-quality examples where performance is weak or business importance is high. Do not spend equal budget on a capability already saturated.</li><li><strong>Train a controlled candidate.</strong> Version the manifest, weights, seed, and trainer settings.</li><li><strong>Run the full regression matrix.</strong> A gain in one slice can produce forgetting or stylistic drift elsewhere.</li><li><strong>Adjust weights or stages.</strong> If tasks interfere, compare simultaneous mixing with a staged schedule that reintroduces prior capabilities.</li></ol><p>Sequentially fine-tuning code, then math, then conversation can cause catastrophic forgetting: later updates overwrite behavior learned earlier. Pure mixing can also create competition. A staged mixture that first targets deficits and later replays already-strong skills is one testable compromise, not a guaranteed optimum.</p><h3>Diversity has two dimensions</h3><p>Task diversity asks <em>what</em> the model must do. Format diversity asks <em>how the request arrives</em>.</p><p>For the same behavior, vary phrasing, instruction position, prompt length, response length, and dialogue dynamics. Include controlled messy prompts when robustness matters, while keeping target responses accurate. With response-only loss, prompt tokens are not direct prediction targets, but they still condition every response token; clean-prompt and writing-quality evaluations remain necessary.</p><p>Synthetic data can fill sparse slices, but record the teacher and verify outputs. Production logs can reveal real recovery failures, but technical value does not create permission. Authorization, minimization, de-identification, retention, access controls, deletion handling, and contamination checks belong before selection.</p><p>The central rule is: <strong>treat every mixture weight as a versioned hypothesis about a measured capability.</strong> If a slice has no target behavior and no evaluation, its ratio cannot be justified.</p><p>Chapter 7 of <em>LLM Engineering in Practice</em> develops this loop from source selection through prompt diversity, staged mixtures, robustness data, and governed feedback.</p><p>Amazon:</p><p><a href="https://www.amazon.sg/LLM-Engineering-Practice-Practical-Application/dp/B0GQ2XBNML">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><p>Leanpub:</p><p><a href="https://leanpub.com/llmengineeringinpracticebridgingtheoryandpracticalapplication">LLM Engineering in Practice: Bridging Theory and Practical Application</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=480934770de1" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>