<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dpo on lo0 — Tech Blog</title><link>https://blog.lo0.es/en/tags/dpo/</link><description>Recent content in Dpo on lo0 — Tech Blog</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 27 May 2026 08:00:00 +0200</lastBuildDate><atom:link href="https://blog.lo0.es/en/tags/dpo/index.xml" rel="self" type="application/rss+xml"/><item><title>Modern alignment: DPO, KTO, ORPO and SimPO — the sommelier who learns without a reward model</title><link>https://blog.lo0.es/en/posts/modern-alignment-dpo-kto-orpo-simpo/</link><pubDate>Wed, 27 May 2026 08:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/modern-alignment-dpo-kto-orpo-simpo/</guid><description>&lt;blockquote>
&lt;p>This post is the natural continuation of &lt;a href="https://blog.lo0.es/en/posts/continuous-fine-tuning-production-real-traffic-deployed-adapter/">continuous fine-tuning in production&lt;/a>, which covers the operational cycle (Postgres + SQL queries + hot-swap) that feeds these methods with real data. Here we go inside each one: what each loss optimises, what hypothesis it makes, and why they choose one or the other.&lt;/p>
&lt;/blockquote>
&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>Classic RLHF, the kind in the InstructGPT papers, is practically extinct in production. The reason is not ideological: it is that in 2023 Rafailov and others showed that the reward model &lt;strong>does not need to exist&lt;/strong> as a separate object. With an elegant change of variable, the optimal policy can be trained directly from preference pairs, without going through a reward and without RL. That is &lt;strong>DPO&lt;/strong>. From there the family has branched into four methods that coexist in 2026: &lt;strong>DPO&lt;/strong> when you have &lt;code>(chosen, rejected)&lt;/code> pairs, &lt;strong>KTO&lt;/strong> when you only have a binary 👍/👎 signal, &lt;strong>ORPO&lt;/strong> when you want SFT and preferences in the same pass to save memory, and &lt;strong>SimPO&lt;/strong> when you also want to get rid of the reference model and normalise by length. This post explains exactly what each loss does, proves it with an end-to-end numerical example, gives the real decision table between the four and takes apart the three biases that kill the method in production when nobody watches them.&lt;/p>
&lt;h2 id="you-are-here-tune">You are here: TUNE&lt;/h2>
&lt;div class="diagram" style="max-width:780px;margin:1rem auto;">
&lt;svg viewBox="0 0 780 90" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="you are here: Tune">
&lt;style>.box{stroke:#444;stroke-width:1.4;rx:6}.active{fill:#ff8a4c;stroke-width:3}.idle{fill:#f4f4f4}.lbl{font:600 12px sans-serif;fill:#222}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#alm)}.cyc{stroke:#888;stroke-width:1.2;fill:none;stroke-dasharray:4 2;marker-end:url(#alm)}&lt;/style>
&lt;defs>&lt;marker id="alm" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="390" y="20" text-anchor="middle" class="lbl">You are here: TUNE · preference optimization without a reward model&lt;/text>
&lt;rect x="30" y="35" width="110" height="35" class="box idle"/>&lt;text x="85" y="58" text-anchor="middle" class="lbl">1 · Data&lt;/text>
&lt;rect x="155" y="35" width="110" height="35" class="box active"/>&lt;text x="210" y="58" text-anchor="middle" class="lbl">2 · Tune&lt;/text>
&lt;rect x="280" y="35" width="110" height="35" class="box idle"/>&lt;text x="335" y="58" text-anchor="middle" class="lbl">3 · Eval&lt;/text>
&lt;rect x="405" y="35" width="110" height="35" class="box idle"/>&lt;text x="460" y="58" text-anchor="middle" class="lbl">4 · Deploy&lt;/text>
&lt;rect x="530" y="35" width="110" height="35" class="box idle"/>&lt;text x="585" y="58" text-anchor="middle" class="lbl">5 · Observe&lt;/text>
&lt;rect x="655" y="35" width="110" height="35" class="box idle"/>&lt;text x="710" y="58" text-anchor="middle" class="lbl">6 · Retrain&lt;/text>
&lt;path class="arr" d="M140,52 L155,52"/>&lt;path class="arr" d="M265,52 L280,52"/>&lt;path class="arr" d="M390,52 L405,52"/>&lt;path class="arr" d="M515,52 L530,52"/>&lt;path class="arr" d="M640,52 L655,52"/>
&lt;path class="cyc" d="M710,72 L710,82 L85,82 L85,72"/>
&lt;/svg>
&lt;/div>
&lt;p>The &lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">six-stage LLMOps pipeline&lt;/a> places Tune between Data and Eval. Inside Tune three modalities coexist: SFT (supervised fine-tuning), preference optimization (what this post covers) and agent training / RFT. What follows is the &lt;strong>inside&lt;/strong> of the second modality.&lt;/p>
&lt;h2 id="the-analogy-the-sommelier-who-trains-the-palate-without-a-theory-book">The analogy: the sommelier who trains the palate without a theory book&lt;/h2>
&lt;p>Imagine you want to train a sommelier. You have two routes. The first is teaching them oenological theory: grape varieties, terroirs, vinification methods, barrel types. You give them cards with canonical wine descriptions and ask them to memorise them. That is &lt;strong>SFT&lt;/strong>: &lt;code>(prompt, ideal answer)&lt;/code> pairs. It works as general education, but the sommelier who comes out of it cannot tell two excellent Riojas apart.&lt;/p>
&lt;p>The second route is the blind comparator. You put two identical opaque glasses in front of them. You say &amp;ldquo;this one is better than this one&amp;rdquo;. You do not explain why. You repeat the exercise a thousand times, with a thousand different pairs. After a while, the sommelier does not need you to say it: they have &lt;strong>a trained palate&lt;/strong>. They have not learned oenological theory, they have learned to &lt;strong>discriminate&lt;/strong>.&lt;/p>
&lt;p>DPO, KTO, ORPO and SimPO are four variants of the second route. All four train the model to discriminate, not to memorise. The differences between them are:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>DPO&lt;/strong>: two glasses at each tasting, the sommelier always knows which one is the &amp;ldquo;good&amp;rdquo; one and which is the &amp;ldquo;bad&amp;rdquo; one.&lt;/li>
&lt;li>&lt;strong>KTO&lt;/strong>: a single glass each time, they are only told &amp;ldquo;you would like this&amp;rdquo; or &amp;ldquo;you would not like this&amp;rdquo;. No pairs.&lt;/li>
&lt;li>&lt;strong>ORPO&lt;/strong>: the tasting also includes a small embedded theory class (SFT in parallel) so the catalogue is not forgotten.&lt;/li>
&lt;li>&lt;strong>SimPO&lt;/strong>: like DPO, but the sommelier does not compare against &amp;ldquo;what your master would have said&amp;rdquo; (reference model); they compare the two glasses directly, normalising by the amount of liquid in each.&lt;/li>
&lt;/ul>
&lt;p>The analogy is not decorative: the rest of the post is that same idea expressed mathematically.&lt;/p>
&lt;h2 id="why-dpo-exists-rafailovs-trick">Why DPO exists: Rafailov&amp;rsquo;s trick&lt;/h2>
&lt;p>To understand DPO it helps to walk through in thirty seconds what it replaces. Classic RLHF, the InstructGPT kind, has three phases:&lt;/p>
&lt;div class="diagram" style="max-width:760px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 760 280" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="classic RLHF vs DPO">
&lt;style>
.bx{fill:#f8f8f8;stroke:#444;stroke-width:1.4;rx:8}
.bxa{fill:#ffe6d6;stroke:#444;stroke-width:1.4;rx:8}
.bxb{fill:#d6eaff;stroke:#444;stroke-width:1.4;rx:8}
.bxc{fill:#d9f5d6;stroke:#444;stroke-width:1.4;rx:8}
.bxx{fill:#fff5b0;stroke:#444;stroke-width:1.4;rx:8}
.lt{font:600 13px sans-serif;fill:#222}
.ls{font:400 11px sans-serif;fill:#555}
.h{font:700 13px sans-serif;fill:#222}
.ar{stroke:#666;stroke-width:1.5;fill:none;marker-end:url(#mrl)}
.aw{stroke:#c0392b;stroke-width:1.8;fill:none;marker-end:url(#mrlx)}
&lt;/style>
&lt;defs>
&lt;marker id="mrl" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>
&lt;marker id="mrlx" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#c0392b"/>&lt;/marker>
&lt;/defs>
&lt;text x="200" y="20" text-anchor="middle" class="h">Classic RLHF (3 phases, 3 models)&lt;/text>
&lt;rect x="40" y="35" width="160" height="55" class="bxa"/>
&lt;text x="120" y="56" text-anchor="middle" class="lt">SFT&lt;/text>
&lt;text x="120" y="74" text-anchor="middle" class="ls">π_ref ← (prompt, answer)&lt;/text>
&lt;rect x="40" y="110" width="160" height="55" class="bxb"/>
&lt;text x="120" y="131" text-anchor="middle" class="lt">Reward Model&lt;/text>
&lt;text x="120" y="149" text-anchor="middle" class="ls">r_φ ← (prompt, chosen, rejected)&lt;/text>
&lt;rect x="40" y="185" width="160" height="55" class="bxc"/>
&lt;text x="120" y="206" text-anchor="middle" class="lt">PPO (RL)&lt;/text>
&lt;text x="120" y="224" text-anchor="middle" class="ls">π_θ maximises r_φ with KL to π_ref&lt;/text>
&lt;path class="ar" d="M120,90 L120,110"/>
&lt;path class="ar" d="M120,165 L120,185"/>
&lt;text x="220" y="135" class="ls">3 models in memory&lt;/text>
&lt;text x="220" y="150" class="ls">+ on-policy rollouts&lt;/text>
&lt;text x="220" y="165" class="ls">+ unstable, hard to debug&lt;/text>
&lt;text x="560" y="20" text-anchor="middle" class="h">DPO (1 phase, 2 models)&lt;/text>
&lt;rect x="400" y="35" width="160" height="55" class="bxa"/>
&lt;text x="480" y="56" text-anchor="middle" class="lt">SFT (same)&lt;/text>
&lt;text x="480" y="74" text-anchor="middle" class="ls">π_ref ← (prompt, answer)&lt;/text>
&lt;rect x="400" y="125" width="160" height="80" class="bxx"/>
&lt;text x="480" y="146" text-anchor="middle" class="lt">DPO&lt;/text>
&lt;text x="480" y="164" text-anchor="middle" class="ls">π_θ ← (chosen, rejected)&lt;/text>
&lt;text x="480" y="180" text-anchor="middle" class="ls">closed-form loss on log-probs&lt;/text>
&lt;text x="480" y="196" text-anchor="middle" class="ls">no RL, no explicit reward&lt;/text>
&lt;path class="ar" d="M480,90 L480,125"/>
&lt;text x="580" y="220" class="ls" font-style="italic">"the reward is implicit&lt;/text>
&lt;text x="580" y="236" class="ls" font-style="italic">in log π_θ - log π_ref"&lt;/text>
&lt;path class="aw" d="M260,140 L390,140"/>
&lt;text x="325" y="130" text-anchor="middle" class="ls" fill="#c0392b">Rafailov 2023:&lt;/text>
&lt;text x="325" y="158" text-anchor="middle" class="ls" fill="#c0392b">"you only need π_θ and π_ref"&lt;/text>
&lt;/svg>
&lt;/div>
&lt;p>&lt;strong>Phase 1 – SFT.&lt;/strong> You train the model on &lt;code>(prompt, ideal answer)&lt;/code>. Out comes &lt;code>π_ref&lt;/code>: the reference policy. It is the &amp;ldquo;educated&amp;rdquo; model.&lt;/p>
&lt;p>&lt;strong>Phase 2 – Reward model.&lt;/strong> On the same model (a different head), you train a regressor: given &lt;code>(prompt, chosen, rejected)&lt;/code>, it learns to give a higher score to the &lt;code>chosen&lt;/code>. Out comes &lt;code>r_φ(x, y)&lt;/code>.&lt;/p>
&lt;p>&lt;strong>Phase 3 – PPO.&lt;/strong> You take &lt;code>π_ref&lt;/code> as the starting point and train another copy &lt;code>π_θ&lt;/code> so that it &lt;strong>maximises &lt;code>r_φ(x, π_θ(x))&lt;/code>&lt;/strong> with a KL penalty to keep it from drifting too far from &lt;code>π_ref&lt;/code>. That requires generating rollouts (on-policy decode at every step), keeping the three models in memory (&lt;code>π_θ&lt;/code>, &lt;code>π_ref&lt;/code>, &lt;code>r_φ&lt;/code>), and a classic RL setup: unstable, sensitive to hyperparameters and famous for its reproducibility problems.&lt;/p>
&lt;p>Rafailov&amp;rsquo;s observation was: &lt;strong>phase 3 has a closed-form solution&lt;/strong>. If you write out the exact optimisation problem PPO solves&lt;/p>
$$\max_{\pi_\theta} \; \mathbb{E}_{x \sim D, \, y \sim \pi_\theta(\cdot|x)} \big[ r_\phi(x,y) \big] - \beta \, \mathrm{KL}\big(\pi_\theta(\cdot|x) \,\|\, \pi_\mathrm{ref}(\cdot|x)\big)$$
&lt;p>it turns out the optimal policy has the form&lt;/p>
$$\pi^{*}(y|x) = \frac{1}{Z(x)} \, \pi_\mathrm{ref}(y|x) \, \exp\!\left( \tfrac{1}{\beta} r_\phi(x,y) \right)$$
&lt;p>and from there you can solve for the implicit reward:&lt;/p>
$$r_\phi(x,y) = \beta \log \frac{\pi^{*}(y|x)}{\pi_\mathrm{ref}(y|x)} + \beta \log Z(x).$$
&lt;p>The second term is a function of &lt;code>x&lt;/code> only and cancels out when you compare two answers to the same prompt. &lt;strong>The reward does not need to be learned&lt;/strong>: it is implicit in the log-prob ratio between the trained model and the reference one. If you plug that into the Bradley-Terry model for preferences (the formula that says &amp;ldquo;the probability that &lt;code>yw&lt;/code> is preferred to &lt;code>yl&lt;/code> is &lt;code>σ(r(x,yw) - r(x,yl))&lt;/code>&amp;rdquo;), out comes the &lt;strong>DPO loss&lt;/strong>:&lt;/p>
$$\mathcal{L}_\mathrm{DPO}(\pi_\theta;\pi_\mathrm{ref}) = -\,\mathbb{E}_{(x, y_w, y_l) \sim D} \log \sigma\!\Big( \beta \big[ \log \tfrac{\pi_\theta(y_w|x)}{\pi_\mathrm{ref}(y_w|x)} - \log \tfrac{\pi_\theta(y_l|x)}{\pi_\mathrm{ref}(y_l|x)} \big] \Big).$$
&lt;p>That is the whole of DPO. &lt;strong>There is no reward model, no RL, no rollouts.&lt;/strong> Only log-probs over static data.&lt;/p>
&lt;h2 id="dpo-with-real-numbers">DPO with real numbers&lt;/h2>
&lt;p>The formula is less intimidating when you evaluate it with an example. Imagine a pair from the dataset:&lt;/p>
&lt;ul>
&lt;li>&lt;code>x&lt;/code> = &amp;ldquo;Explain what a KVM switch is&amp;rdquo;.&lt;/li>
&lt;li>&lt;code>y_w&lt;/code> = correct answer (chosen).&lt;/li>
&lt;li>&lt;code>y_l&lt;/code> = confusing answer (rejected).&lt;/li>
&lt;/ul>
&lt;p>After a forward pass we have four numbers (sums of per-token log-probs, negative sign because each &lt;code>log p_token ≤ 0&lt;/code>):&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Quantity&lt;/th>
&lt;th>Value&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>log π_θ(y_w | x)&lt;/code>&lt;/td>
&lt;td>−45.2&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>log π_θ(y_l | x)&lt;/code>&lt;/td>
&lt;td>−52.1&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>log π_ref(y_w | x)&lt;/code>&lt;/td>
&lt;td>−47.3&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>log π_ref(y_l | x)&lt;/code>&lt;/td>
&lt;td>−50.8&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The &amp;ldquo;ratios&amp;rdquo; are the improvement of the trained model over the reference one for each answer:&lt;/p>
&lt;ul>
&lt;li>For &lt;code>y_w&lt;/code>: &lt;code>−45.2 − (−47.3) = +2.1&lt;/code> → the trained model gives it more probability than the reference one. Good.&lt;/li>
&lt;li>For &lt;code>y_l&lt;/code>: &lt;code>−52.1 − (−50.8) = −1.3&lt;/code> → the trained model gives it less probability. Also good.&lt;/li>
&lt;/ul>
&lt;p>With &lt;code>β = 0.1&lt;/code> (a typical value) the &amp;ldquo;margin&amp;rdquo; inside the logarithm is:&lt;/p>
$$m = \beta \cdot (2.1 - (-1.3)) = 0.1 \cdot 3.4 = 0.34$$
&lt;p>And the loss:&lt;/p>
$$\mathcal{L}_\mathrm{DPO} = -\log \sigma(0.34) = -\log(0.584) \approx 0.538.$$
&lt;p>The intuition is visible straight away: the more the chosen log-prob rises and the more the rejected one falls (relative to &lt;code>π_ref&lt;/code>), the more positive &lt;code>m&lt;/code> becomes, the higher the sigmoid and the lower the loss. If the margin is negative (the model gets it wrong), &lt;code>σ(m) &amp;lt; 0.5&lt;/code> and the loss blows up. The gradient pushes the model to increase &lt;code>π_θ(y_w|x)&lt;/code> and lower &lt;code>π_θ(y_l|x)&lt;/code>.&lt;/p>
&lt;p>The role of &lt;code>β&lt;/code>: it is the &lt;strong>temperature of the alignment&lt;/strong>. If &lt;code>β&lt;/code> is small, the model is allowed to drift a long way from &lt;code>π_ref&lt;/code>; if it is large, the KL weighs heavily and the model barely moves. Typical value in 2026: &lt;strong>0.05–0.3&lt;/strong>, with &lt;code>0.1&lt;/code> as a starting point.&lt;/p>
&lt;h2 id="kto-when-you-only-have-">KTO: when you only have 👍/👎&lt;/h2>
&lt;p>DPO needs &lt;strong>pairs&lt;/strong>. In practice, that is almost never what the product gives you: what the product gives you is binary feedback (a thumbs up or a thumbs down, a conversion or an abandonment). KTO — Kahneman-Tversky Optimization, Ethayarajh et al. 2024 — solves exactly that case.&lt;/p>
&lt;p>The intuition comes from Kahneman and Tversky&amp;rsquo;s &lt;strong>prospect theory&lt;/strong>: humans are &lt;strong>more sensitive to losses than to gains&lt;/strong> of the same magnitude (loss aversion: losing 100 € hurts more than gaining 100 €). KTO carries that over into the loss:&lt;/p>
$$\mathcal{L}_\mathrm{KTO}(x, y) =
\begin{cases}
\lambda_d \big[ 1 - \sigma\!\big(\beta \cdot ( h_\theta(x,y) - z_0 ) \big) \big] &amp; \text{if } y \text{ is desirable},\\
\lambda_u \big[ 1 - \sigma\!\big(\beta \cdot ( z_0 - h_\theta(x,y) ) \big) \big] &amp; \text{if } y \text{ is undesirable},
\end{cases}$$
&lt;p>where &lt;code>h_θ(x,y) = log(π_θ(y|x) / π_ref(y|x))&lt;/code> is exactly the same ratio that appeared in DPO, &lt;code>z_0&lt;/code> is an estimate of the batch KL divergence (it acts as a &amp;ldquo;neutral point&amp;rdquo;) and &lt;code>λ_d&lt;/code>, &lt;code>λ_u&lt;/code> are the desirable / undesirable weights.&lt;/p>
&lt;p>The critical point: &lt;strong>KTO does not need pairs&lt;/strong>. Each example is &lt;code>(prompt, answer, binary label)&lt;/code>. This fits real product telemetry. The usual practical rule is &lt;code>λ_u &amp;gt; λ_d&lt;/code> (e.g. 1.0 vs 0.33) when the database has more 👍 than 👎, so that the negative signal is not diluted.&lt;/p>
&lt;p>KTO works particularly well in two scenarios:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Products with explicit feedback UX&lt;/strong> (chatbots with 👍/👎): each thumbs is a direct KTO example, no need to synthesise pairs.&lt;/li>
&lt;li>&lt;strong>Imbalanced datasets&lt;/strong> (far more 👍 than 👎, or the other way round): the weights &lt;code>λ_d&lt;/code>, &lt;code>λ_u&lt;/code> handle it explicitly.&lt;/li>
&lt;/ol>
&lt;h2 id="orpo-sft-and-preferences-in-a-single-pass">ORPO: SFT and preferences in a single pass&lt;/h2>
&lt;p>DPO assumes you have already done SFT. You train two phases: first SFT to get &lt;code>π_ref&lt;/code>, then DPO on top of &lt;code>π_ref&lt;/code>. Two passes over the data, two optimisations, two models in memory.&lt;/p>
&lt;p>ORPO — Odds Ratio Preference Optimization, Hong et al. 2024 — &lt;strong>merges both phases&lt;/strong>. The loss combines two terms:&lt;/p>
$$\mathcal{L}_\mathrm{ORPO} = \mathcal{L}_\mathrm{SFT}(y_w) + \lambda \cdot \mathcal{L}_\mathrm{OR}(y_w, y_l)$$
&lt;p>The first term is classic SFT on the chosen answer (negative cross-entropy). The second is the &lt;strong>odds ratio&lt;/strong> between chosen and rejected:&lt;/p>
$$\mathcal{L}_\mathrm{OR} = -\log \sigma\!\Big( \log \tfrac{\mathrm{odds}_\theta(y_w|x)}{\mathrm{odds}_\theta(y_l|x)} \Big), \quad \text{with } \mathrm{odds}_\theta(y|x) = \tfrac{P_\theta(y|x)}{1 - P_\theta(y|x)}.$$
&lt;p>What matters: &lt;strong>there is no &lt;code>π_ref&lt;/code>&lt;/strong>. ORPO trains a single model, in a single pass, without loading the reference policy into memory. On paper it sounds good and in practice it works: a Llama 3 8B aligned with ORPO over 5k pairs takes about 3 hours on 4×H100 and fits in VRAM with aggressive QLoRA on a single RTX 4090.&lt;/p>
&lt;p>The &lt;code>λ&lt;/code> parameter is the weight of the preference term. Typical: &lt;code>0.1–0.3&lt;/code>. If &lt;code>λ&lt;/code> is too high, the model learns to discriminate but forgets the SFT (catastrophic forgetting); if it is too low, the alignment barely shows.&lt;/p>
&lt;h2 id="simpo-do-you-really-need-a-reference-model">SimPO: do you really need a reference model?&lt;/h2>
&lt;p>SimPO — Simple Preference Optimization, Meng et al. 2024 — takes ORPO&amp;rsquo;s question one step further: if ORPO frees itself from &lt;code>π_ref&lt;/code> for the combined SFT+preference case, &lt;strong>why not free yourself from &lt;code>π_ref&lt;/code> in the pure DPO case too?&lt;/strong>&lt;/p>
&lt;p>The SimPO loss:&lt;/p>
$$\mathcal{L}_\mathrm{SimPO} = -\log \sigma\!\Big( \tfrac{\beta}{|y_w|} \log \pi_\theta(y_w|x) - \tfrac{\beta}{|y_l|} \log \pi_\theta(y_l|x) - \gamma \Big).$$
&lt;p>Two changes with respect to DPO:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>There is no &lt;code>π_ref&lt;/code>&lt;/strong>: absolute log-probs of the trained model are compared directly.&lt;/li>
&lt;li>&lt;strong>Length-normalization&lt;/strong>: each log-prob is divided by the length of its answer &lt;code>|y|&lt;/code>. This is key because without normalising, long answers tend to have a lower total log-prob (each token contributes its &lt;code>log p &amp;lt; 0&lt;/code>), creating an artificial bias.&lt;/li>
&lt;li>&lt;strong>Explicit margin &lt;code>γ&lt;/code>&lt;/strong>: the loss is low if the difference of normalised log-probs exceeds &lt;code>γ&lt;/code>. Typical: &lt;code>γ = 0.5–1.5&lt;/code>.&lt;/li>
&lt;/ol>
&lt;p>With &lt;code>β = 2.0&lt;/code>, &lt;code>γ = 1.0&lt;/code>, &lt;code>|y_w| = 120&lt;/code> tokens, &lt;code>|y_l| = 100&lt;/code> tokens and the earlier log-probs:&lt;/p>
$$m = \tfrac{2.0}{120} \cdot (-45.2) - \tfrac{2.0}{100} \cdot (-52.1) - 1.0 = -0.753 + 1.042 - 1.0 = -0.711.$$
$$\mathcal{L}_\mathrm{SimPO} = -\log \sigma(-0.711) \approx 1.11.$$
&lt;p>A higher loss than DPO at the same point: SimPO takes longer to converge, but uses half the memory (a single model in VRAM) and removes the dependency on &lt;code>π_ref&lt;/code>. It is the dominant option when memory is the bottleneck.&lt;/p>
&lt;h2 id="decision-table-which-one-to-use-and-when">Decision table: which one to use and when&lt;/h2>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Signal available&lt;/th>
&lt;th>Memory available&lt;/th>
&lt;th>Prior SFT&lt;/th>
&lt;th>Recommended method&lt;/th>
&lt;th>Rationale&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>&lt;code>(chosen, rejected)&lt;/code> pairs&lt;/td>
&lt;td>High (≥ 80 GB GPU)&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>&lt;strong>DPO&lt;/strong>&lt;/td>
&lt;td>Most established baseline, better reproducibility&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>(chosen, rejected)&lt;/code> pairs&lt;/td>
&lt;td>Low (24–48 GB GPU)&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>&lt;strong>SimPO&lt;/strong>&lt;/td>
&lt;td>Removes &lt;code>π_ref&lt;/code> → ~50 % less VRAM&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>&lt;code>(chosen, rejected)&lt;/code> pairs&lt;/td>
&lt;td>Any&lt;/td>
&lt;td>No&lt;/td>
&lt;td>&lt;strong>ORPO&lt;/strong>&lt;/td>
&lt;td>SFT and preferences in one pass&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Binary 👍/👎 signal without pairs&lt;/td>
&lt;td>High&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>&lt;strong>KTO&lt;/strong>&lt;/td>
&lt;td>The only method native to unpaired data&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Binary signal + few pairs&lt;/td>
&lt;td>High&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>&lt;strong>KTO&lt;/strong> with a DPO sub-batch&lt;/td>
&lt;td>Combination documented in TRL 0.13&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Multistep trajectories (tool use)&lt;/td>
&lt;td>Very high&lt;/td>
&lt;td>Yes&lt;/td>
&lt;td>&lt;strong>Pure RLHF/RFT&lt;/strong>&lt;/td>
&lt;td>Preference-pair methods do not capture the dynamics&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>&lt;strong>Typical dataset magnitudes:&lt;/strong>&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Method&lt;/th>
&lt;th>Minimum viable&lt;/th>
&lt;th>Sweet spot&lt;/th>
&lt;th>Plateau&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>DPO&lt;/td>
&lt;td>1,000 pairs&lt;/td>
&lt;td>5,000–20,000&lt;/td>
&lt;td>&amp;gt; 50,000&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SimPO&lt;/td>
&lt;td>2,000 pairs&lt;/td>
&lt;td>5,000–20,000&lt;/td>
&lt;td>&amp;gt; 50,000&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ORPO&lt;/td>
&lt;td>3,000 pairs (includes SFT)&lt;/td>
&lt;td>10,000–30,000&lt;/td>
&lt;td>&amp;gt; 80,000&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>KTO&lt;/td>
&lt;td>5,000 binary examples&lt;/td>
&lt;td>20,000–80,000&lt;/td>
&lt;td>&amp;gt; 200,000&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>KTO typically needs &lt;strong>3-4× more volume&lt;/strong> than DPO because the binary signal is weaker than the comparative one. The trade-off is that the binary signal is the one a production product naturally produces.&lt;/p>
&lt;h2 id="the-three-biases-that-break-the-method">The three biases that break the method&lt;/h2>
&lt;p>All four methods share one problem: they are training on &lt;strong>proxies&lt;/strong> for quality, not on quality. Those proxies have systematic biases the model can exploit trivially.&lt;/p>
&lt;h3 id="length-bias">Length bias&lt;/h3>
&lt;p>Documented in the original DPO paper and in the literature that followed. Long answers tend to be preferred by humans, probably because they look &amp;ldquo;more complete&amp;rdquo;. If the pair dataset inherits that bias, the model learns that &lt;strong>lengthening the answer is what gets rewarded&lt;/strong>, not that better content is what gets rewarded. Result: after 2–3 epochs the model spews waffle.&lt;/p>
&lt;p>Mitigations:&lt;/p>
&lt;ul>
&lt;li>&lt;strong>DPO&lt;/strong>: filter the dataset, removing pairs where &lt;code>|y_w| &amp;gt; 1.3 · |y_l|&lt;/code> (the 30 % rule).&lt;/li>
&lt;li>&lt;strong>SimPO&lt;/strong>: the length-normalization in the loss fixes it by construction.&lt;/li>
&lt;li>&lt;strong>ORPO / KTO&lt;/strong>: dataset filtering or an auxiliary length regularisation (DPOP, R-DPO).&lt;/li>
&lt;/ul>
&lt;div class="diagram" style="max-width:740px;margin:1.5rem auto;">
&lt;svg viewBox="0 0 740 230" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Length bias during training">
&lt;style>
.ax{stroke:#444;stroke-width:1.4;fill:none}
.gr{stroke:#888;stroke-width:0.5;fill:none;stroke-dasharray:2 2}
.cv1{stroke:#c0392b;stroke-width:2.5;fill:none}
.cv2{stroke:#2980b9;stroke-width:2.5;fill:none}
.lb{font:600 11px sans-serif;fill:#222}
.sm{font:400 10px sans-serif;fill:#555}
.h{font:700 13px sans-serif;fill:#222}
&lt;/style>
&lt;text x="370" y="20" text-anchor="middle" class="h">Length bias: mean answer length during training&lt;/text>
&lt;line x1="60" y1="180" x2="700" y2="180" class="ax"/>
&lt;line x1="60" y1="180" x2="60" y2="50" class="ax"/>
&lt;line x1="60" y1="150" x2="700" y2="150" class="gr"/>
&lt;line x1="60" y1="120" x2="700" y2="120" class="gr"/>
&lt;line x1="60" y1="90" x2="700" y2="90" class="gr"/>
&lt;line x1="60" y1="60" x2="700" y2="60" class="gr"/>
&lt;text x="55" y="184" text-anchor="end" class="sm">100&lt;/text>
&lt;text x="55" y="154" text-anchor="end" class="sm">150&lt;/text>
&lt;text x="55" y="124" text-anchor="end" class="sm">200&lt;/text>
&lt;text x="55" y="94" text-anchor="end" class="sm">250&lt;/text>
&lt;text x="55" y="64" text-anchor="end" class="sm">300&lt;/text>
&lt;text x="20" y="115" class="sm" transform="rotate(-90,20,115)">tokens / answer&lt;/text>
&lt;text x="370" y="210" text-anchor="middle" class="sm">epoch&lt;/text>
&lt;text x="100" y="200" text-anchor="middle" class="sm">0&lt;/text>
&lt;text x="220" y="200" text-anchor="middle" class="sm">1&lt;/text>
&lt;text x="340" y="200" text-anchor="middle" class="sm">2&lt;/text>
&lt;text x="460" y="200" text-anchor="middle" class="sm">3&lt;/text>
&lt;text x="580" y="200" text-anchor="middle" class="sm">4&lt;/text>
&lt;text x="680" y="200" text-anchor="middle" class="sm">5&lt;/text>
&lt;path class="cv1" d="M100,150 C160,140 200,120 220,110 C280,80 340,65 460,55 C540,52 620,51 680,50"/>
&lt;path class="cv2" d="M100,150 C160,148 220,146 340,144 C460,143 580,142 680,142"/>
&lt;rect x="430" y="60" width="170" height="40" fill="white" stroke="#bbb"/>
&lt;line x1="438" y1="72" x2="468" y2="72" class="cv1"/>
&lt;text x="475" y="76" class="lb">DPO without filter&lt;/text>
&lt;line x1="438" y1="90" x2="468" y2="90" class="cv2"/>
&lt;text x="475" y="94" class="lb">SimPO (length-norm)&lt;/text>
&lt;/svg>
&lt;/div>
&lt;p>The chart shows the usual pattern: with no mitigation, in 3 epochs a Llama 3 8B with DPO can go from answers of about 150 tokens to answers of about 280 tokens, &lt;strong>without any improvement in human-evaluated quality&lt;/strong>. SimPO keeps the length roughly stable.&lt;/p>
&lt;h3 id="position-bias-in-dataset-curation">Position bias (in dataset curation)&lt;/h3>
&lt;p>If the pairs are generated automatically with an LLM judge (covered in detail in the next post of this series), there is a known bias: &lt;strong>judges prefer the first answer&lt;/strong> they see when the two are comparable. If every pair in the dataset always has the chosen in position A and the rejected in position B, the model does not learn preference: it learns an artefact of the curation process.&lt;/p>
&lt;p>Mitigation: random shuffling of the order in the query to the judge &lt;strong>and averaging two passes with the order reversed&lt;/strong> (seen in tools such as Promptfoo and Inspect AI by default).&lt;/p>
&lt;h3 id="distribution-shift-between-the-data-and-π_ref">Distribution shift between the data and &lt;code>π_ref&lt;/code>&lt;/h3>
&lt;p>DPO, KTO and SimPO implicitly compare the trained model against a distribution. If the preference data comes from a model (another LLM generating candidates) very different from &lt;code>π_ref&lt;/code>, the trained model can explore regions where &lt;code>π_ref&lt;/code> has almost zero probability, giving numerically unstable ratios (the log of very small quantities). In practice this shows up as loss explosions, NaN gradients or silent regression.&lt;/p>
&lt;p>Mitigation: &lt;strong>generate the dataset candidates with &lt;code>π_ref&lt;/code> itself&lt;/strong> whenever possible (rejection sampling over &lt;code>π_ref&lt;/code>, with an external judge picking the chosen). That is the canonical on-policy RLHF prescription applied to the offline setting.&lt;/p>
&lt;h2 id="implications-on-on-premise-hardware">Implications on on-premise hardware&lt;/h2>
&lt;p>The figures below are indicative for a typical May 2026 scenario: Llama 3.1 8B Instruct as &lt;code>π_ref&lt;/code>, a dataset of 5,000–20,000 pairs, QLoRA (NF4) with LoRA rank 16 over all the transformer block projectors (&lt;code>q,k,v,o,gate,up,down&lt;/code>), effective batch size 16, 1–3 epochs.&lt;/p>
&lt;h3 id="on-an-rtx-4090-24-gb">On an RTX 4090 (24 GB)&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Method&lt;/th>
&lt;th>Peak VRAM&lt;/th>
&lt;th>Time / epoch (5k pairs)&lt;/th>
&lt;th>Notes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>DPO&lt;/td>
&lt;td>~22 GB&lt;/td>
&lt;td>50–80 min&lt;/td>
&lt;td>Needs &lt;code>π_ref&lt;/code> in VRAM even if quantised FP8/INT8&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SimPO&lt;/td>
&lt;td>~14 GB&lt;/td>
&lt;td>45–70 min&lt;/td>
&lt;td>No &lt;code>π_ref&lt;/code>, the natural option on a 4090&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ORPO&lt;/td>
&lt;td>~16 GB&lt;/td>
&lt;td>60–90 min&lt;/td>
&lt;td>No &lt;code>π_ref&lt;/code>, comfortably viable&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>KTO&lt;/td>
&lt;td>~22 GB&lt;/td>
&lt;td>90–150 min (10k binary)&lt;/td>
&lt;td>Same VRAM as DPO, more data per epoch&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The 4090 (24 GB, Ada Lovelace, no NVLink) is &lt;strong>perfectly viable&lt;/strong> for Llama 8B with QLoRA if you pick the method sensibly. For 13B the choice between SimPO/ORPO is no longer a preference, it is a requirement.&lt;/p>
&lt;h3 id="on-a-generic-4h100-sxm-cluster-320-gb-nvlink">On a generic 4×H100 SXM cluster (320 GB, NVLink)&lt;/h3>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Method&lt;/th>
&lt;th>Viable model&lt;/th>
&lt;th>Time / epoch (10k pairs)&lt;/th>
&lt;th>Notes&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>DPO&lt;/td>
&lt;td>Llama 3 70B (4-bit)&lt;/td>
&lt;td>60–90 min&lt;/td>
&lt;td>Tensor parallel = 4, still comfortable&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SimPO&lt;/td>
&lt;td>Llama 3 70B (BF16)&lt;/td>
&lt;td>50–75 min&lt;/td>
&lt;td>Full BF16 fits thanks to having no &lt;code>π_ref&lt;/code>&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>ORPO&lt;/td>
&lt;td>Llama 3 70B (BF16)&lt;/td>
&lt;td>70–100 min&lt;/td>
&lt;td>Similar to SimPO in consumption&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>KTO&lt;/td>
&lt;td>Llama 3 70B (4-bit)&lt;/td>
&lt;td>100–140 min&lt;/td>
&lt;td>Larger datasets offset by parallelism&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>On an NVLink cluster the operational difference between methods blurs: they all fit. The choice goes back to &lt;strong>what kind of signal you have&lt;/strong>, not to budget.&lt;/p>
&lt;h2 id="what-we-have-not-covered-upcoming-articles">What we have not covered (upcoming articles)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>LoRA and QLoRA fundamentals&lt;/strong>: the maths of the low-rank adapter that underpins everything above, and why a 70B fits in 24 GB.&lt;/li>
&lt;li>&lt;strong>LLM-as-judge fundamentals&lt;/strong>: how to build the judge that generates the chosen/rejected pairs without position or verbosity bias. The next post in this batch covers it.&lt;/li>
&lt;li>&lt;strong>Online DPO and iterative on-policy&lt;/strong>: the 2026 research state of the art (Fast-Slow Chasing, RLOO, iterative preference learning) and why it is not production yet.&lt;/li>
&lt;li>&lt;strong>Distillation and synthetic preference data&lt;/strong>: when it is worth generating pairs with a large model to train a small one.&lt;/li>
&lt;/ul>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/continuous-fine-tuning-production-real-traffic-deployed-adapter/">Continuous fine-tuning in production&lt;/a> — the operational cycle (Postgres, SQL queries, multi-LoRA hot-swap) that feeds pairs to the methods in this post.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/retrain-closing-the-loop-feedback-dataset-adapter/">Retrain: closing the loop&lt;/a> — how production signals become the preference dataset.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/evals-llm-layer-after-tracing/">Evals for LLMs: the layer after tracing&lt;/a> — the battery of evaluators that decides whether the aligned adapter is promoted to production.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/llm-as-judge-exam-marker-not-oracle/">LLM-as-judge: the exam marker&lt;/a> — the mechanism that generates the &lt;code>(chosen, rejected)&lt;/code> pairs consumed here. Judge calibration with Cohen&amp;rsquo;s kappa and the four biases that invalidate the pairs if nobody watches them.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/multi-lora-serving-shared-base-concurrent-adapters-sgmv-kernel/">Multi-LoRA serving: the single translator with a thousand glossaries&lt;/a> — each alignment policy (DPO with dataset A, KTO with dataset B, ORPO with dataset C) can live as a separate adapter and be served in parallel: real production A/B without deploying three copies of the base.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Rafailov, R., Sharma, A., Mitchell, E., Ermon, S., Manning, C. D., Finn, C. &lt;em>Direct Preference Optimization: Your Language Model is Secretly a Reward Model&lt;/em> (NeurIPS 2023).&lt;/li>
&lt;li>Ethayarajh, K., Xu, W., Muennighoff, N., Jurafsky, D., Kiela, D. &lt;em>KTO: Model Alignment as Prospect Theoretic Optimization&lt;/em> (ICML 2024).&lt;/li>
&lt;li>Hong, J., Lee, N., Thorne, J. &lt;em>ORPO: Monolithic Preference Optimization without Reference Model&lt;/em> (EMNLP 2024).&lt;/li>
&lt;li>Meng, Y., Xia, M., Chen, D. &lt;em>SimPO: Simple Preference Optimization with a Reference-Free Reward&lt;/em> (NeurIPS 2024).&lt;/li>
&lt;li>HuggingFace TRL 0.13 — reference implementations: &lt;a href="https://huggingface.co/docs/trl">https://huggingface.co/docs/trl&lt;/a>.&lt;/li>
&lt;li>Tunstall, L. et al. &lt;em>The Alignment Handbook&lt;/em> — reproducible recipes: &lt;a href="https://github.com/huggingface/alignment-handbook">https://github.com/huggingface/alignment-handbook&lt;/a>.&lt;/li>
&lt;li>Park, R. et al. &lt;em>Disentangling Length from Quality in Direct Preference Optimization&lt;/em> (R-DPO, ACL 2024).&lt;/li>
&lt;/ul></description></item><item><title>Continuous fine-tuning in production: from real traffic to the deployed adapter</title><link>https://blog.lo0.es/en/posts/continuous-fine-tuning-production-real-traffic-deployed-adapter/</link><pubDate>Thu, 21 May 2026 10:00:00 +0200</pubDate><guid>https://blog.lo0.es/en/posts/continuous-fine-tuning-production-real-traffic-deployed-adapter/</guid><description>&lt;h2 id="tldr">TL;DR&lt;/h2>
&lt;p>Continuous fine-tuning is not &amp;ldquo;training the model every so often&amp;rdquo;. It is a &lt;strong>closed loop&lt;/strong> where real production traffic generates the datasets, a short pipeline trains a LoRA adapter, a battery of evaluations decides whether it is promoted, and vLLM loads it &lt;strong>without restarting&lt;/strong>. The state of the art in May 2026 has fragmented the stack: it is no longer DPO against everything, but a choice between SFT, DPO, KTO, ORPO and SimPO according to the type of signal your product captures. What has consolidated the pattern is the combination of PostgreSQL 18 + pgvector 0.8 as the &lt;strong>nervous system of the pipeline&lt;/strong>, traffic capture, dataset versioning, eval results, adapter registry, together with vLLM multi-LoRA hot-swap, which turns deployment into an HTTP call. This article takes the cycle apart with concrete schemas, real queries, and the numbers it costs on an RTX 4090 against a 4×H100 cluster.&lt;/p>
&lt;h2 id="you-are-here-tune--retrain">You are here: Tune + Retrain&lt;/h2>
&lt;p>This post crosses two stages of the &lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">six-stage LLMOps pipeline&lt;/a>: the decision to &lt;strong>train a new adapter&lt;/strong> (the &lt;strong>Tune&lt;/strong> stage) is triggered by the signals from &lt;strong>Observe&lt;/strong> that travel through the &lt;strong>Retrain&lt;/strong> stage until the loop closes. The post takes apart the complete circuit between the two boxes.&lt;/p>
&lt;div class="diagram" style="max-width:780px;margin:1rem auto;">
&lt;svg viewBox="0 0 780 90" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="you are here: Tune + Retrain">
&lt;style>.box{stroke:#444;stroke-width:1.4;rx:6}.active{fill:#ff8a4c;stroke-width:3}.active2{fill:#fff5b0;stroke-width:3}.idle{fill:#f4f4f4}.lbl{font:600 12px sans-serif;fill:#222}.arr{stroke:#666;stroke-width:1.4;fill:none;marker-end:url(#ftm)}.cyc{stroke:#888;stroke-width:1.2;fill:none;stroke-dasharray:4 2;marker-end:url(#ftm)}&lt;/style>
&lt;defs>&lt;marker id="ftm" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">&lt;path d="M0,0 L10,5 L0,10 z" fill="#666"/>&lt;/marker>&lt;/defs>
&lt;text x="390" y="20" text-anchor="middle" class="lbl">You are here: TUNE + RETRAIN · continuous adapter cycle driven by real traffic&lt;/text>
&lt;rect x="30" y="35" width="110" height="35" class="box idle"/>&lt;text x="85" y="58" text-anchor="middle" class="lbl">1 · Data&lt;/text>
&lt;rect x="155" y="35" width="110" height="35" class="box active"/>&lt;text x="210" y="58" text-anchor="middle" class="lbl">2 · Tune&lt;/text>
&lt;rect x="280" y="35" width="110" height="35" class="box idle"/>&lt;text x="335" y="58" text-anchor="middle" class="lbl">3 · Eval&lt;/text>
&lt;rect x="405" y="35" width="110" height="35" class="box idle"/>&lt;text x="460" y="58" text-anchor="middle" class="lbl">4 · Deploy&lt;/text>
&lt;rect x="530" y="35" width="110" height="35" class="box idle"/>&lt;text x="585" y="58" text-anchor="middle" class="lbl">5 · Observe&lt;/text>
&lt;rect x="655" y="35" width="110" height="35" class="box active2"/>&lt;text x="710" y="58" text-anchor="middle" class="lbl">6 · Retrain&lt;/text>
&lt;path class="arr" d="M140,52 L155,52"/>&lt;path class="arr" d="M265,52 L280,52"/>&lt;path class="arr" d="M390,52 L405,52"/>&lt;path class="arr" d="M515,52 L530,52"/>&lt;path class="arr" d="M640,52 L655,52"/>
&lt;path class="cyc" d="M710,72 L710,82 L85,82 L85,72"/>
&lt;/svg>
&lt;/div>
&lt;h2 id="the-analogy-the-restaurant-that-tunes-its-menu">The analogy: the restaurant that tunes its menu&lt;/h2>
&lt;p>Picture a neighbourhood restaurant with a signature dish that works, but the chef knows it can be tuned. Every night things happen:&lt;/p>
&lt;ul>
&lt;li>Some diners &lt;strong>leave part of the dish&lt;/strong>: a weak signal that something did not quite land.&lt;/li>
&lt;li>Others ask for &lt;strong>another version&lt;/strong> (&amp;ldquo;could you put less salt in it?&amp;rdquo;): an explicit, directional signal.&lt;/li>
&lt;li>Others &lt;strong>finish the dish and come back the following week&lt;/strong>: the only signal that really matters, but it arrives late.&lt;/li>
&lt;li>And a select group offers an opinion without being asked, usually a negative one.&lt;/li>
&lt;/ul>
&lt;p>The chef does not redo the menu every night. He does something more interesting: he writes down in a notebook the dishes served, the returns, the changes requested, the tips. Every so often, he &lt;strong>reads the whole notebook&lt;/strong>, decides on minimal adjustments to a recipe, tries the new version at a private table with his staff, and only if they take to it does he add it to the next day&amp;rsquo;s menu. Sometimes he even serves two different versions of the dish to different tables for a week, measures what happens, and picks one.&lt;/p>
&lt;p>That is &lt;strong>continuous fine-tuning&lt;/strong>. The notebook is Postgres. The dish is the base model. The notes are feedback signals, explicit and implicit. The &amp;ldquo;minimal adjustment&amp;rdquo; is a 30 MB LoRA adapter. The private table is the battery of automated evaluations. The next day&amp;rsquo;s menu is vLLM with multi-LoRA hot-swap, which loads the new adapter without restarting the service. Serving two versions to different tables is A/B testing with real traffic.&lt;/p>
&lt;p>The analogy is exact on one critical point: &lt;strong>the chef does not throw away the original recipe&lt;/strong>. He keeps the base recipe and holds a separate notebook with the &amp;ldquo;modifications that work well for the neighbourhood regulars&amp;rdquo;. That notebook is the LoRA adapter: on top of the base model, not in its place.&lt;/p>
&lt;h2 id="the-cycle-taken-apart">The cycle, taken apart&lt;/h2>
&lt;p>Before going into components, it helps to fix the complete flow. These seven steps are what any serious team replicates with variations:&lt;/p>
&lt;div class="diagram" style="max-width: 720px; margin: 1.5rem auto;">
&lt;svg viewBox="0 0 720 420" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Closed loop of continuous fine-tuning">
&lt;style>
.node { fill: #f4f4f4; stroke: #333; stroke-width: 1.5; }
.n-serve { fill: #d6eaff; }
.n-data { fill: #ffe9d6; }
.n-train { fill: #d9f5d6; }
.n-eval { fill: #f4e1ff; }
.lbl { font: 600 12px sans-serif; fill: #222; }
.lbl-sm { font: 10.5px sans-serif; fill: #444; }
.arr { stroke: #444; stroke-width: 1.4; fill: none; marker-end: url(#ah2); }
.arr-dim { stroke: #888; stroke-width: 1.2; fill: none; stroke-dasharray: 4,3; marker-end: url(#ah2); }
&lt;/style>
&lt;defs>
&lt;marker id="ah2" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">
&lt;path d="M0,0 L10,5 L0,10 z" fill="#444"/>
&lt;/marker>
&lt;/defs>
&lt;text x="360" y="22" text-anchor="middle" class="lbl">The closed loop of continuous fine-tuning&lt;/text>
&lt;rect x="280" y="40" width="160" height="50" rx="8" class="node n-serve"/>
&lt;text x="360" y="62" text-anchor="middle" class="lbl">1 · vLLM serving&lt;/text>
&lt;text x="360" y="78" text-anchor="middle" class="lbl-sm">base + active adapters&lt;/text>
&lt;rect x="500" y="120" width="170" height="50" rx="8" class="node n-data"/>
&lt;text x="585" y="142" text-anchor="middle" class="lbl">2 · Traffic capture&lt;/text>
&lt;text x="585" y="158" text-anchor="middle" class="lbl-sm">prompts, responses, feedback&lt;/text>
&lt;rect x="500" y="210" width="170" height="50" rx="8" class="node n-data"/>
&lt;text x="585" y="232" text-anchor="middle" class="lbl">3 · Curation&lt;/text>
&lt;text x="585" y="248" text-anchor="middle" class="lbl-sm">dedup, PII, balancing, snapshot&lt;/text>
&lt;rect x="280" y="290" width="160" height="50" rx="8" class="node n-train"/>
&lt;text x="360" y="312" text-anchor="middle" class="lbl">4 · LoRA training&lt;/text>
&lt;text x="360" y="328" text-anchor="middle" class="lbl-sm">SFT / DPO / KTO / ORPO / SimPO&lt;/text>
&lt;rect x="50" y="210" width="170" height="50" rx="8" class="node n-eval"/>
&lt;text x="135" y="232" text-anchor="middle" class="lbl">5 · Eval gates&lt;/text>
&lt;text x="135" y="248" text-anchor="middle" class="lbl-sm">3 stages: PR, full, canary&lt;/text>
&lt;rect x="50" y="120" width="170" height="50" rx="8" class="node n-train"/>
&lt;text x="135" y="142" text-anchor="middle" class="lbl">6 · Adapter registry&lt;/text>
&lt;text x="135" y="158" text-anchor="middle" class="lbl-sm">status: canary | prod | retired&lt;/text>
&lt;rect x="50" y="40" width="170" height="50" rx="8" class="node n-serve"/>
&lt;text x="135" y="62" text-anchor="middle" class="lbl">7 · Hot-swap&lt;/text>
&lt;text x="135" y="78" text-anchor="middle" class="lbl-sm">POST /v1/load_lora_adapter&lt;/text>
&lt;path class="arr" d="M440,75 C480,80 495,100 510,120"/>
&lt;path class="arr" d="M585,170 L585,210"/>
&lt;path class="arr" d="M500,250 C460,270 440,280 440,300"/>
&lt;path class="arr" d="M280,315 C240,290 230,275 220,260"/>
&lt;path class="arr" d="M135,210 L135,170"/>
&lt;path class="arr" d="M135,120 L135,90"/>
&lt;path class="arr" d="M220,65 L280,65"/>
&lt;rect x="280" y="170" width="160" height="80" rx="10" fill="#fffae6" stroke="#d4a52a" stroke-width="2"/>
&lt;text x="360" y="200" text-anchor="middle" class="lbl">PostgreSQL 18&lt;/text>
&lt;text x="360" y="218" text-anchor="middle" class="lbl-sm">+ pgvector 0.8&lt;/text>
&lt;text x="360" y="234" text-anchor="middle" class="lbl-sm">single source of truth&lt;/text>
&lt;path class="arr-dim" d="M500,145 L440,180"/>
&lt;path class="arr-dim" d="M500,235 L440,225"/>
&lt;path class="arr-dim" d="M280,225 L220,235"/>
&lt;path class="arr-dim" d="M280,200 L220,160"/>
&lt;path class="arr-dim" d="M360,290 L360,250"/>
&lt;/svg>
&lt;/div>
&lt;p>The cycle lasts between 1 and 4 weeks in real production. What changes between teams is the tempo (faster in assistant chat, slower in regulated banking) and the details of each step. The structure is the same.&lt;/p>
&lt;h2 id="why-continuous-fine-tuning-and-why-it-is-not-rag">Why continuous fine-tuning (and why it is not RAG)&lt;/h2>
&lt;p>Before going deeper, a distinction that people still confuse. &lt;strong>Fine-tuning is for form, not for facts.&lt;/strong> If your problem is that the model does not know the customer&amp;rsquo;s rates or the updated catalogue, do not fine-tune: use RAG. If your problem is that the model responds in a tone that does not fit, does not respect your JSON format, refuses legitimate cases or invents structure, then fine-tuning is the answer.&lt;/p>
&lt;p>In 2026 the boundary is well established by community practice:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Observed problem&lt;/th>
&lt;th>Solution&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>The model does not know X (X changes weekly)&lt;/td>
&lt;td>RAG&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The model knows X but responds badly in tone or format&lt;/td>
&lt;td>SFT fine-tuning&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>There are two ways of responding and I prefer one over the other&lt;/td>
&lt;td>Fine-tuning with preferences (DPO/KTO/ORPO/SimPO)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The model reasons badly in a verifiable domain (code, maths)&lt;/td>
&lt;td>RL with verifiable reward (GRPO/DAPO)&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>The model is competent, it just needs a memory of facts&lt;/td>
&lt;td>RAG, not fine-tuning&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>Continuous fine-tuning is the disciplined version of the second and third cases. The key word is &lt;strong>continuous&lt;/strong>: it is not a one-off &amp;ldquo;we aligned the model&amp;rdquo; event, it is a process that runs every time the traffic distribution drifts far enough, or new use cases appear.&lt;/p>
&lt;h2 id="the-four-techniques-according-to-the-signal-you-capture">The four techniques according to the signal you capture&lt;/h2>
&lt;p>The most important change of the last 12 months has been the end of DPO&amp;rsquo;s monopoly. In 2024 every team doing alignment used DPO with &lt;code>(chosen, rejected)&lt;/code> pairs. In 2026 the choice is finer and depends on &lt;strong>what the signal you collect in your product looks like&lt;/strong>:&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Real signal in the product&lt;/th>
&lt;th>Recommended technique&lt;/th>
&lt;th>Why&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>Labelled correct examples (input → expected output)&lt;/td>
&lt;td>&lt;strong>SFT + LoRA&lt;/strong>&lt;/td>
&lt;td>Still the baseline. 500-5,000 examples are enough for style.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Explicit &lt;code>(chosen, rejected)&lt;/code> pairs&lt;/td>
&lt;td>&lt;strong>DPO&lt;/strong> or &lt;strong>SimPO&lt;/strong>&lt;/td>
&lt;td>SimPO removes the reference model → 50 % less VRAM in training.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Loose 👍 / 👎 on responses&lt;/td>
&lt;td>&lt;strong>KTO&lt;/strong>&lt;/td>
&lt;td>The method that fits real telemetry most naturally.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>SFT and preferences in a single pass&lt;/td>
&lt;td>&lt;strong>ORPO&lt;/strong>&lt;/td>
&lt;td>A single model in memory, avoids drift between phases.&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>Verifiable reward (tests, solutions)&lt;/td>
&lt;td>&lt;strong>GRPO&lt;/strong> / &lt;strong>DAPO&lt;/strong>&lt;/td>
&lt;td>Reasoning, not chat. A different world.&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>The practical rule: &lt;strong>design the feedback capture in the product thinking about which method you will be able to use afterwards&lt;/strong>. If your UI only has 👍/👎, you force the path to KTO. If you add a &amp;ldquo;regenerate response&amp;rdquo; button, you unlock DPO from regenerate-as-rejected (we will see it below). If you add an &amp;ldquo;edit response&amp;rdquo; button, the edited response becomes high-quality direct SFT.&lt;/p>
&lt;p>There is a cost detail that gets little publicity. DPO needs to keep &lt;strong>two models&lt;/strong> in memory: the one you are training and the reference one. SimPO removes that second model. ORPO does too. For a Llama 3 8B in BF16 this is the difference between needing ~32 GB of active VRAM during training (DPO) or ~16 GB (SimPO/ORPO). It is the difference between the training fitting on an RTX 4090 with aggressive QLoRA, or not fitting without offload.&lt;/p>
&lt;h2 id="postgres-as-the-nervous-system-of-the-pipeline">Postgres as the nervous system of the pipeline&lt;/h2>
&lt;p>Here is the strong technical opinion of this article, and it is one worth defending with data: &lt;strong>Postgres 18 + pgvector 0.8 + an S3/MinIO bucket for the weights is enough for the whole pipeline&lt;/strong>. You do not need MLflow, you do not need lakeFS, you do not need DVC.&lt;/p>
&lt;p>This is not ideological minimalism. It is about three concrete advantages that no alternative stack matches in the on-premise scenario with compliance:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>A single source of truth, a single authorisation model.&lt;/strong> The ACLs you already have for Postgres cover the training data, the eval results, the adapter registry and the audit log. You do not multiply control planes.&lt;/li>
&lt;li>&lt;strong>SQL as the pipeline&amp;rsquo;s universal language.&lt;/strong> The query that generates the dataset, the eval gate predicate, the A/B traffic assignment, the promotion decision: it is all SQL. Your team already knows SQL.&lt;/li>
&lt;li>&lt;strong>Audit and cryptographic reproducibility for free.&lt;/strong> The &lt;code>pg_audit&lt;/code> and &lt;code>pgcrypto&lt;/code> extensions, combined with &lt;code>set_hash&lt;/code> over the dataset, give you cryptographic traceability with no additional code. It is a subject that would fill an article of its own.&lt;/li>
&lt;/ol>
&lt;h3 id="a-concrete-schema">A concrete schema&lt;/h3>
&lt;p>We start with the traffic table, partitioned by week so that &lt;code>DROP PARTITION&lt;/code> is cheap:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">BIGSERIAL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">request_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UUID&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">tenant_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">user_hash&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">BYTEA&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- GDPR pseudonymisation
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- e.g. &amp;#34;support-es-v4.1&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">experiment&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- e.g. &amp;#34;rerank-v2-canary&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">variant&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">CHAR&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- &amp;#39;A&amp;#39; | &amp;#39;B&amp;#39; | NULL
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">messages&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">JSONB&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">completion&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_ms&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">tokens_in&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">tokens_out&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c1">-- feedback signals
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">SMALLINT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- -1/0/+1 (KTO-ready)
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_regen&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">BOOLEAN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">false&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- user regenerated -&amp;gt; DPO-rejected
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_edited&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">BOOLEAN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">false&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- user edited -&amp;gt; SFT golden
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">parent_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">BIGINT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- self-reference for regenerate
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- vector and meta
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">HALFVEC&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">1024&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- pgvector 0.8, half the RAM
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pii_flags&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">SMALLINT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- bitmask
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMPTZ&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">PARTITION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">RANGE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log_2026w21&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">PARTITION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">OF&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">FOR&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">VALUES&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;2026-05-18&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TO&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;2026-05-25&amp;#39;&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INDEX&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log_2026w21&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">USING&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hnsw&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">halfvec_cosine_ops&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">INDEX&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log_2026w21&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">tenant_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Three decisions deserve a note:&lt;/p>
&lt;p>&lt;strong>&lt;code>HALFVEC(1024)&lt;/code>.&lt;/strong> Native FP16 vectors in pgvector 0.8. Half the RAM and disk, with a loss of precision that is irrelevant for semantic deduplication. This alone, at a scale of millions of rows, saves between 4 and 8 GB.&lt;/p>
&lt;p>&lt;strong>Weekly partitioning by time range.&lt;/strong> At 90 days, &lt;code>DROP TABLE obs.inference_log_2026wXX&lt;/code> frees space in milliseconds without a prolonged lock. Autovacuum never touches frozen partitions again.&lt;/p>
&lt;p>&lt;strong>Self-referencing &lt;code>parent_id&lt;/code>.&lt;/strong> The user regenerates the response → a new row is inserted with &lt;code>parent_id&lt;/code> pointing at the previous one. That will give us a DPO dataset without touching the UX.&lt;/p>
&lt;h3 id="the-adapter-registry">The adapter registry&lt;/h3>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">serve&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">PRIMARY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">base_model&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">rank&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">alpha&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">INT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">target_modules&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">JSONB&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">method&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- &amp;#39;sft&amp;#39;|&amp;#39;dpo&amp;#39;|&amp;#39;kto&amp;#39;|&amp;#39;orpo&amp;#39;|&amp;#39;simpo&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">training_run_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UUID&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">dataset_snapshot_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">UUID&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">weights_uri&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- s3://.../v4.2.safetensors
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">eval_summary&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">JSONB&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">status&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NULL&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- &amp;#39;training&amp;#39;|&amp;#39;canary&amp;#39;|&amp;#39;prod&amp;#39;|&amp;#39;retired&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">traffic_pct&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">NUMERIC&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">promoted_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMPTZ&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The vLLM router reads this table with a TTL of a few seconds. An &lt;code>UPDATE serve.adapter SET status='prod', traffic_pct=100 WHERE id='v4.2'&lt;/code> is a promotion. An &lt;code>UPDATE ... SET status='retired'&lt;/code> is a rollback. The audit of who did what and when comes from &lt;code>pg_audit&lt;/code> without writing a single additional line of code.&lt;/p>
&lt;h2 id="generating-dpo-and-kto-datasets-from-real-traffic">Generating DPO and KTO datasets from real traffic&lt;/h2>
&lt;p>This is where the elegance of the schema pays off. The dataset is not a static file: it is a &lt;strong>materialised view&lt;/strong> built with SQL over &lt;code>obs.inference_log&lt;/code>.&lt;/p>
&lt;h3 id="kto-dataset-from-">KTO dataset from 👍/👎&lt;/h3>
&lt;p>KTO is the method that best fits the signal any decent chat product captures. The query:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">MATERIALIZED&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">VIEW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">kto_v3_candidate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">messages&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">prompt&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">completion&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">response&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">CASE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">THEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">true&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ELSE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">false&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">END&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">label&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">!=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">interval&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;60 days&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">pii_flags&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">tenant_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">IN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">tenant&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">consent_training&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Simple. Every row with explicit feedback becomes an example &lt;code>(prompt, response, desirable_yes_no)&lt;/code>. KTO trains directly on this signal, with no need to build pairs.&lt;/p>
&lt;h3 id="dpo-dataset-from-regenerate">DPO dataset from &amp;ldquo;regenerate&amp;rdquo;&lt;/h3>
&lt;p>The trick that is worth this article on its own. When the user presses &amp;ldquo;regenerate response&amp;rdquo;, they are giving an extraordinarily strong signal: the first response was no good to them. If the second is neither regenerated nor rated negatively, we assume it was. That is a DPO pair without a single extra click in the UI:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">MATERIALIZED&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">VIEW&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">dpo_v3_candidate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">messages&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">prompt&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">cho&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="k">completion&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">chosen&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="k">completion&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rejected&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">JOIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">cho&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ON&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">cho&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">parent_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">fb_regen&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">true&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">cho&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="c1">-- length bias mitigation in classic DPO
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">cho&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">tokens_out&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BETWEEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">tokens_out&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rej&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">tokens_out&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">2&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The clause on lengths is the cheap cure for the &lt;strong>length bias&lt;/strong> documented in DPO. Without it, the model learns that &amp;ldquo;longer = better&amp;rdquo; because the responses the user accepts tend to be slightly longer. With SimPO or ORPO this filter is optional; with classic DPO it is necessary.&lt;/p>
&lt;h3 id="semantic-deduplication-with-pgvector">Semantic deduplication with pgvector&lt;/h3>
&lt;p>Before training, dedup. Two almost identical prompts in the dataset are noise that biases the model:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">WITH&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ranked&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">row_number&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">OVER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">PARTITION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hashtext&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">messages&lt;/span>&lt;span class="p">::&lt;/span>&lt;span class="nb">text&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DESC&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DESC&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">rn&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">interval&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;60 days&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">DELETE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">kto_v3_candidate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">kto&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">USING&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ranked&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">rn&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">kto&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">r&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>And for the semantic duplicates (paraphrases) we use pgvector 0.8 directly with an &lt;code>iterative index scan&lt;/code>:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- Find near-duplicates of any given example
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">messages&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;=&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">dist&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">interval&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;60 days&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;=&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">05&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">embedding&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;=&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">LIMIT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">50&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>iterative scan&lt;/code> is a key improvement in pgvector 0.8: before, the HNSW index could return fewer results than requested when there were additional filters (&lt;code>WHERE&lt;/code>); now it iterates until it meets the limit. Without that improvement, curation queries over datasets of millions of rows were unworkable without a brutal pre-filter.&lt;/p>
&lt;h2 id="eval-gates-three-stages-all-sql">Eval gates: three stages, all SQL&lt;/h2>
&lt;p>The most common mistake when implementing continuous fine-tuning is skipping or watering down the eval gates. That turns the cycle into a roulette wheel. The pattern that works in 2026 is &lt;strong>three stages&lt;/strong>, each with a different latency/coverage trade-off:&lt;/p>
&lt;div class="diagram" style="max-width: 720px; margin: 1.5rem auto;">
&lt;svg viewBox="0 0 720 200" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Three stages of eval gates">
&lt;style>
.stage { stroke: #333; stroke-width: 1.5; }
.s1 { fill: #d6eaff; }
.s2 { fill: #d9f5d6; }
.s3 { fill: #ffe9d6; }
.lbl { font: 600 13px sans-serif; fill: #222; }
.lbl-sm { font: 11px sans-serif; fill: #444; }
.arr { stroke: #444; stroke-width: 1.6; fill: none; marker-end: url(#ah3); }
&lt;/style>
&lt;defs>
&lt;marker id="ah3" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">
&lt;path d="M0,0 L10,5 L0,10 z" fill="#444"/>
&lt;/marker>
&lt;/defs>
&lt;text x="360" y="22" text-anchor="middle" class="lbl">Three stages of eval gates&lt;/text>
&lt;rect x="30" y="50" width="200" height="110" rx="10" class="stage s1"/>
&lt;text x="130" y="78" text-anchor="middle" class="lbl">Stage 1 · PR&lt;/text>
&lt;text x="130" y="98" text-anchor="middle" class="lbl-sm">&amp;lt; 90 seconds&lt;/text>
&lt;text x="130" y="118" text-anchor="middle" class="lbl-sm">schema-lint + prompt-lint&lt;/text>
&lt;text x="130" y="135" text-anchor="middle" class="lbl-sm">+ 50 mini-eval cases&lt;/text>
&lt;rect x="260" y="50" width="200" height="110" rx="10" class="stage s2"/>
&lt;text x="360" y="78" text-anchor="middle" class="lbl">Stage 2 · pre-merge&lt;/text>
&lt;text x="360" y="98" text-anchor="middle" class="lbl-sm">&amp;lt; 20 minutes&lt;/text>
&lt;text x="360" y="118" text-anchor="middle" class="lbl-sm">200-500 golden cases&lt;/text>
&lt;text x="360" y="135" text-anchor="middle" class="lbl-sm">+ LLM-as-judge&lt;/text>
&lt;rect x="490" y="50" width="200" height="110" rx="10" class="stage s3"/>
&lt;text x="590" y="78" text-anchor="middle" class="lbl">Stage 3 · canary&lt;/text>
&lt;text x="590" y="98" text-anchor="middle" class="lbl-sm">24-72 hours&lt;/text>
&lt;text x="590" y="118" text-anchor="middle" class="lbl-sm">1-5 % real traffic&lt;/text>
&lt;text x="590" y="135" text-anchor="middle" class="lbl-sm">online metrics + feedback&lt;/text>
&lt;path class="arr" d="M230,105 L260,105"/>
&lt;path class="arr" d="M460,105 L490,105"/>
&lt;/svg>
&lt;/div>
&lt;p>And this is where Postgres shines again: the promotion gate is expressed as an SQL predicate. Nothing more:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">TABLE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">eval_result&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">REFERENCES&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">serve&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="p">),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">suite_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- &amp;#39;safety-es&amp;#39;, &amp;#39;support-helpfulness&amp;#39;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">metric&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">score&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">NUMERIC&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">judge_model&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">judged_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">TIMESTAMPTZ&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">DEFAULT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">(),&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">PRIMARY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">KEY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">suite_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">metric&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">CREATE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">OR&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">REPLACE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FUNCTION&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">serve&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">can_promote&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">candidate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">current&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">TEXT&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">RETURNS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">BOOLEAN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$$&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">NOT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">EXISTS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">eval_result&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">c&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">JOIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">train&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">eval_result&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">p&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">USING&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">suite_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">metric&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">candidate&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">p&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">current&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">suite_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">IN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="s1">&amp;#39;safety-es&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s1">&amp;#39;support-helpfulness&amp;#39;&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="s1">&amp;#39;refusal-rate&amp;#39;&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">c&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">score&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">p&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">score&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">98&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="c1">-- 2 % tolerance
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">);&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="err">$$&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">LANGUAGE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">sql&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">STABLE&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>An SQL function as the gate. Usable from CI with &lt;code>psql -c &amp;quot;SELECT serve.can_promote('v4.2','v4.1')&amp;quot;&lt;/code> and an exit code of 0/1. No orchestrator needed, no specific UI needed. The audit stays in the Postgres log.&lt;/p>
&lt;h2 id="vllm-multi-lora-the-deploy-is-an-http-post">vLLM multi-LoRA: the deploy is an HTTP POST&lt;/h2>
&lt;p>Two years ago, deploying a new fine-tune meant rotating inference pods. Today it is an HTTP call. vLLM 0.7+ supports loading and unloading LoRA adapters &lt;strong>hot&lt;/strong>, keeping several resident in VRAM and choosing the right one per request.&lt;/p>
&lt;p>Server configuration:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">vllm serve meta-llama/Llama-3.1-8B-Instruct &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --enable-lora &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --max-loras &lt;span class="m">4&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --max-lora-rank &lt;span class="m">64&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> --env &lt;span class="nv">VLLM_ALLOW_RUNTIME_LORA_UPDATING&lt;/span>&lt;span class="o">=&lt;/span>True
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>Deploying a new adapter:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">curl -X POST http://localhost:8000/v1/load_lora_adapter &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -H &lt;span class="s2">&amp;#34;Content-Type: application/json&amp;#34;&lt;/span> &lt;span class="se">\
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="se">&lt;/span> -d &lt;span class="s1">&amp;#39;{
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;#34;lora_name&amp;#34;: &amp;#34;support-es-v4.2&amp;#34;,
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> &amp;#34;lora_path&amp;#34;: &amp;#34;/mnt/adapters/support-es-v4.2&amp;#34;
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="s1"> }&amp;#39;&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>From that moment on, requests including &lt;code>&amp;quot;model&amp;quot;: &amp;quot;support-es-v4.2&amp;quot;&lt;/code> are served with that adapter applied on top of the base model. Switching between adapters has negligible latency (the most recent research on Activated LoRA takes this to levels where the switching cost is invisible).&lt;/p>
&lt;p>This changes operations substantially. &lt;strong>Deploying a new fine-tune stops being an infrastructure event and becomes a state change in Postgres&lt;/strong>. The router queries the &lt;code>serve.adapter&lt;/code> table, sees that &lt;code>v4.2&lt;/code> is in &lt;code>canary&lt;/code> with &lt;code>traffic_pct=5&lt;/code>, and directs 5 % of requests to the new adapter. The exact route of that 5 % is decided with deterministic hashing of the &lt;code>user_id&lt;/code> so that the same user always sees the same variant (sticky):&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- No assignment table, no additional state
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">-- the variant is computed in-place in SQL or in the router:
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="c1">&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">CASE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">hashtext&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="n">user_id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">||&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="n">experiment&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">%&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">100&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;lt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">SELECT&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">traffic_pct&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">serve&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">adapter&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">id&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="n">candidate&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">THEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="n">candidate&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ELSE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="k">current&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">END&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;h2 id="ab-with-real-traffic-measure-or-live-deceived">A/B with real traffic: measure or live deceived&lt;/h2>
&lt;p>The eval gates measure against fixed benchmarks. That is necessary but insufficient. Reality is only measured with real traffic. Once the adapter is in canary, what matters are the &lt;strong>online metrics&lt;/strong> measured over &lt;code>obs.inference_log&lt;/code> for each variant:&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-sql" data-lang="sql">&lt;span class="line">&lt;span class="cl">&lt;span class="k">SELECT&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">COUNT&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">n&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AVG&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">mean_score&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">STDDEV&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">fb_explicit&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">/&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">SQRT&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">COUNT&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="o">*&lt;/span>&lt;span class="p">))&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">sem&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AVG&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="n">ttft_ms&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_avg&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">percentile_cont&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">5&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">WITHIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">GROUP&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_ms&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_p50&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="n">percentile_cont&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="mi">95&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">WITHIN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">GROUP&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">ORDER&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_ms&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">ttft_p95&lt;/span>&lt;span class="p">,&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AVG&lt;/span>&lt;span class="p">(&lt;/span>&lt;span class="k">CASE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">WHEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">fb_regen&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">THEN&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">ELSE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="mi">0&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">END&lt;/span>&lt;span class="p">)&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">AS&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">regen_rate&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">FROM&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">obs&lt;/span>&lt;span class="p">.&lt;/span>&lt;span class="n">inference_log&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">WHERE&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">experiment&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">=&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="err">$&lt;/span>&lt;span class="mi">1&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w"> &lt;/span>&lt;span class="k">AND&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">created_at&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">&amp;gt;&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">now&lt;/span>&lt;span class="p">()&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="o">-&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="nb">interval&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="s1">&amp;#39;7 days&amp;#39;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;span class="line">&lt;span class="cl">&lt;span class="w">&lt;/span>&lt;span class="k">GROUP&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="k">BY&lt;/span>&lt;span class="w"> &lt;/span>&lt;span class="n">adapter_id&lt;/span>&lt;span class="p">;&lt;/span>&lt;span class="w">
&lt;/span>&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>What to look at: explicit feedback, latency (TTFT, p50, p95), regeneration rate. An adapter that raises the mean feedback but also raises the regeneration rate is suspicious, probably it is responding in a flashier but less useful way. An adapter that lowers latency but lowers feedback may be worth studying: it may be being more concise than it should.&lt;/p>
&lt;p>Promotion to &lt;code>prod&lt;/code> happens when, after 24-72 hours in canary, the candidate adapter beats the current one on at least one key metric without degrading the others. Again: it is an &lt;code>UPDATE&lt;/code> in Postgres.&lt;/p>
&lt;h2 id="applied-to-typical-on-premise-hardware">Applied to typical on-premise hardware&lt;/h2>
&lt;p>Let us come down to two representative configurations, one for iteration and one for production.&lt;/p>
&lt;h3 id="case-1--rtx-4090-24-gb-for-development-iteration">Case 1 — RTX 4090 (24 GB) for development iteration&lt;/h3>
&lt;p>An RTX 4090 with 4-bit QLoRA can train adapters on an 8B model without trouble. The VRAM budget combines four components; the &lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache&lt;/a> during the intermediate evaluations is not negligible and deserves an explicit margin:&lt;/p>
&lt;pre tabindex="0">&lt;code>8B base model in 4-bit: ~5 GB
Activations + gradients: ~8 GB (depends on batch and context)
Optimizer state (LoRA r=16): ~0.5 GB
KV cache during eval: ~2 GB
Safety margin: ~8 GB
&lt;/code>&lt;/pre>&lt;p>Typical times (an estimate based on community benchmarks; measure in the lab before promising anything):&lt;/p>
&lt;table>
&lt;thead>
&lt;tr>
&lt;th>Dataset&lt;/th>
&lt;th>Technique&lt;/th>
&lt;th style="text-align:right">Adapter rank&lt;/th>
&lt;th style="text-align:right">Approximate time&lt;/th>
&lt;/tr>
&lt;/thead>
&lt;tbody>
&lt;tr>
&lt;td>1,000 SFT examples&lt;/td>
&lt;td>LoRA r=16&lt;/td>
&lt;td style="text-align:right">16&lt;/td>
&lt;td style="text-align:right">20-40 min&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5,000 SFT examples&lt;/td>
&lt;td>LoRA r=32&lt;/td>
&lt;td style="text-align:right">32&lt;/td>
&lt;td style="text-align:right">2-4 h&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>2,000 DPO pairs&lt;/td>
&lt;td>LoRA r=16&lt;/td>
&lt;td style="text-align:right">16&lt;/td>
&lt;td style="text-align:right">1-2 h&lt;/td>
&lt;/tr>
&lt;tr>
&lt;td>5,000 KTO examples&lt;/td>
&lt;td>LoRA r=32&lt;/td>
&lt;td style="text-align:right">32&lt;/td>
&lt;td style="text-align:right">3-5 h&lt;/td>
&lt;/tr>
&lt;/tbody>
&lt;/table>
&lt;p>This puts the iteration cycle, a change in the dataset, retrain, eval, look at the number, in the range of a &lt;strong>working day&lt;/strong>. Enough to validate a hypothesis before moving anything to the production cluster.&lt;/p>
&lt;h3 id="case-2--4h100-sxm-cluster-320-gb-nvlink-for-production">Case 2 — 4×H100 SXM cluster (320 GB, NVLink) for production&lt;/h3>
&lt;p>With a cluster of this order the whole picture changes. You can:&lt;/p>
&lt;ul>
&lt;li>Train &lt;strong>LoRA on a 70B in BF16 with no quantisation&lt;/strong> with tensor parallel = 4.&lt;/li>
&lt;li>Do &lt;strong>full DPO with a resident reference model&lt;/strong> when the reference is quantised to FP8, or move to &lt;strong>SimPO / ORPO&lt;/strong>, which remove that intermediate model and simplify VRAM planning (see the table of techniques above).&lt;/li>
&lt;li>Support &lt;strong>multi-tenant fine-tuning&lt;/strong>: several customer adapters training in parallel in separate logical pipelines, each isolated in a different Postgres partition with its own ACLs.&lt;/li>
&lt;li>Serve &lt;strong>multi-LoRA with &lt;code>--max-loras 8&lt;/code>&lt;/strong> on top of the base model without concurrency lowering throughput perceptibly.&lt;/li>
&lt;/ul>
&lt;p>The practical budgeting rule: over a 12-month horizon, a team with this cluster can run &lt;strong>~150-200 continuous fine-tuning cycles&lt;/strong> (training + eval + canary + promotion or discard) if the discipline around the dataset and the eval gates is strict. If it is not, it will run twice as many but with half the usefulness.&lt;/p>
&lt;h2 id="position-within-the-architecture-what-this-article-covers-and-what-it-does-not">Position within the architecture: what this article covers and what it does not&lt;/h2>
&lt;p>To place the scope: the cycle drawn at the start has seven boxes, all of them covered here in their mechanics. Three cross-cutting layers are &lt;strong>deliberately left out&lt;/strong>, and they are the ones that end up separating a pipeline that works technically from one that survives an audit:&lt;/p>
&lt;ol>
&lt;li>&lt;strong>Cryptographic provenance and traceability.&lt;/strong> We have mentioned &lt;code>dataset_snapshot&lt;/code> and &lt;code>pg_audit&lt;/code>, but the complete mechanics, the &lt;code>set_hash&lt;/code> over the examples, the integration with the EU AI Act, the frozen &lt;code>query_sql&lt;/code> as proof of what trained the model, is enough for a whole analysis.&lt;/li>
&lt;li>&lt;strong>Judge calibration.&lt;/strong> We have assumed LLM-as-judge works. It needs calibrating against a human rubric on at least 100 cases per critical suite before trusting it. Without that calibration, the eval gates are theatre.&lt;/li>
&lt;li>&lt;strong>The forgetting problem.&lt;/strong> What happens if a user exercises their GDPR right to be forgotten and their interactions were part of the dataset of an adapter already in production? There is no clean solution. There are options, incremental retrain, sample-level machine unlearning, negative LoRA, and it is worth knowing them before a customer asks.&lt;/li>
&lt;/ol>
&lt;h2 id="what-we-have-not-covered-upcoming-articles">What we have not covered (upcoming articles)&lt;/h2>
&lt;ul>
&lt;li>&lt;strong>Cryptographic provenance on Postgres&lt;/strong>: how &lt;code>set_hash&lt;/code> and a frozen &lt;code>query_sql&lt;/code> compose an auditable chain of custody under the EU AI Act.&lt;/li>
&lt;li>&lt;strong>Honest judge calibration&lt;/strong>: why &lt;code>score &amp;gt; 0.85&lt;/code> means nothing without a human baseline, and how to build that baseline without it costing a month of work.&lt;/li>
&lt;li>&lt;strong>The forgetting problem in adapters&lt;/strong>: sample-level machine unlearning, incremental retrain and other techniques for answering GDPR without throwing the adapter away.&lt;/li>
&lt;li>&lt;strong>Online DPO and on-policy continual learning&lt;/strong>: the state of 2026 research (Fast-Slow Chasing, RLOO, iterative on-policy) and why it is not production yet.&lt;/li>
&lt;/ul>
&lt;h2 id="see-also">See also&lt;/h2>
&lt;ul>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/six-stage-llmops-pipeline-architecture-and-deep-dive/">The six-stage LLMOps pipeline&lt;/a> — the master map the Tune and Retrain stages belong to. This post is the operational deep-dive of that cycle.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/mlops-for-llms-landscape-2026/">LLM-specific MLOps in 2026: the landscape&lt;/a> — the opening of the series. It places continuous fine-tuning within the framework of three modalities (fine-tuning, RAG, agents) and seven structural differences from classic MLOps.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/postgresql-qdrant-rag-ingestion-postman-syncing-two-worlds/">PostgreSQL + Qdrant in the ingestion stage&lt;/a> — the Data stage that feeds this cycle: how events enter Postgres and embeddings enter Qdrant, which this post would then curate as a dataset.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/evals-llm-layer-after-tracing/">Evals: the layer after tracing&lt;/a> — the Eval stage of the pipeline. The eval gates described here as SQL predicates are the materialisation of that post&amp;rsquo;s generic framework.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/gpu-cluster-as-multi-tenant-platform/">The GPU cluster as a multi-tenant platform&lt;/a> — the Deploy stage where the multi-LoRA hot-swap described here coexists with quotas, gateway and isolation.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/kv-cache-working-memory-llm-inference/">KV cache: the working memory that holds up LLM inference&lt;/a> — the fundamentals of the cache that comes into play in every intermediate eval of the training and in every deployment of the resulting adapter.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/pagedattention-vllm-block-manager/">PagedAttention from the inside&lt;/a> — the mechanics of the KV cache and the landscape of optimisations (vAttention, EvicPress, RadixAttention) that hold up the throughput of the intermediate evals in the fine-tuning pipeline.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/disaggregated-serving-prefill-decode-specialised-pods/">Disaggregated serving: prefill and decode in specialised pods&lt;/a> — the serving pattern the multi-LoRA hot-swap described here connects to: each specialised pod loads its adapters separately.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/data-versioning-llmops-dvc-lakefs-reproducible-golden-dataset/">Data versioning for LLMOps: DVC, lakeFS and a reproducible golden dataset&lt;/a> — the opposite position. This post defends a minimalist stack (Postgres + pgvector + S3) with no DVC/lakeFS; the other explains when the line is crossed and why.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/modern-alignment-dpo-kto-orpo-simpo/">Modern alignment: DPO, KTO, ORPO and SimPO&lt;/a> — the mathematical foundations behind each of the preference optimisation methods this post uses operationally. Derivation of DPO from RLHF, a numerical example, biases.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/llm-as-judge-exam-marker-not-oracle/">LLM-as-judge: the exam marker that evaluates other models&lt;/a> — the mechanism that generates the &lt;code>(chosen, rejected)&lt;/code> pairs that then feed DPO/SimPO/ORPO in this cycle.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/quantization-llm-inference-fp8-int4-gguf/">Quantisation for LLM inference: FP8, INT4 and GGUF&lt;/a> — the QLoRA with NF4 that holds up the training on an RTX 4090 is the quantisation family seen in detail there. And the DPO reference model is quantised with the same formats to free VRAM.&lt;/li>
&lt;li>&lt;a href="https://blog.lo0.es/en/posts/multi-lora-serving-shared-base-concurrent-adapters-sgmv-kernel/">Multi-LoRA serving: the single translator with a thousand glossaries&lt;/a> — the other side of the loop. This post trains the adapters; multi-LoRA serving (SGMV, S-LoRA, vLLM/LoRAX) is what puts hundreds of them to work concurrently against a single base without replicating the base.&lt;/li>
&lt;/ul>
&lt;h2 id="references">References&lt;/h2>
&lt;ul>
&lt;li>Hu et al., &lt;em>LoRA: Low-Rank Adaptation of Large Language Models&lt;/em> (ICLR 2022).&lt;/li>
&lt;li>Dettmers et al., &lt;em>QLoRA: Efficient Finetuning of Quantized LLMs&lt;/em> (NeurIPS 2023).&lt;/li>
&lt;li>Rafailov et al., &lt;em>Direct Preference Optimization: Your Language Model is Secretly a Reward Model&lt;/em> (NeurIPS 2023).&lt;/li>
&lt;li>Meng, Xia, Chen, &lt;em>SimPO: Simple Preference Optimization with a Reference-Free Reward&lt;/em> (NeurIPS 2024).&lt;/li>
&lt;li>Hong et al., &lt;em>ORPO: Monolithic Preference Optimization without Reference Model&lt;/em> (2024).&lt;/li>
&lt;li>Ethayarajh et al., &lt;em>KTO: Model Alignment as Prospect Theoretic Optimization&lt;/em> (2024).&lt;/li>
&lt;li>Kwon et al., &lt;em>Efficient Memory Management for Large Language Model Serving with PagedAttention&lt;/em> (SOSP 2023) — original vLLM.&lt;/li>
&lt;li>Official vLLM Multi-LoRA documentation: &lt;a href="https://docs.vllm.ai/en/stable/features/lora/">https://docs.vllm.ai/en/stable/features/lora/&lt;/a>.&lt;/li>
&lt;li>Official pgvector 0.8 documentation: &lt;a href="https://github.com/pgvector/pgvector">https://github.com/pgvector/pgvector&lt;/a>.&lt;/li>
&lt;li>TRL (HuggingFace) docs: &lt;a href="https://huggingface.co/docs/trl">https://huggingface.co/docs/trl&lt;/a>.&lt;/li>
&lt;li>EU AI Act, consolidated text and application timeline: &lt;a href="https://artificialintelligenceact.eu/">https://artificialintelligenceact.eu/&lt;/a>.&lt;/li>
&lt;/ul></description></item></channel></rss>