Skip to Content
Recodocs

13 · Capstone: a governed release

One 1.5B SQL model went from decision to rollback as a single release. A gate written before training passed both candidates and refused a control, the chosen adapter gained 15.8 points (10.8 to 20.9) on traffic with a different mix, and the rollback reproduced 96 of 96 recorded replies.

23 min read
Part 4
Ship
Model
Qwen/Qwen2.5-1.5B-Instruct
Data
The SQL splits from lesson 3
Hardware
One T4, in Google Colab
Open in ColabSaved with the outputs of a GPU run

A model that scores well on a benchmark is not yet something a company can run. Two published cases show the distance:

CompanyWhat was testedWhat happened
AmazonA fine-tuned Nova 2 Lite for product-attribute generation against Claude Sonnet 4.5Ahead offline on completeness (74.20% against 70.40%), behind in the production A/B test (59.1% against 63.0%); the paper attributes the reversal to the shift between the curated benchmark and live traffic
ShopifyA fine-tuned Qwen3-32B tool-calling model for Flow, its workflow builderParity on a 300-example benchmark; at 1% of traffic, a workflow activation rate 35% lower than the prompt-based model's, and a fix that took two weeks

Neither team was careless. They found the gap cheaply because the exposure was small and the old system was still there. A governed release is the set of records and controls that make such a surprise cheap and reversible: the decision to tune was written down before the baseline was measured, the pass mark before the candidate existed, the artefacts can be rebuilt and checked by hash, and going back is a step someone has run.

This lesson ties the course into one release of the model from lessons 3 to 5 (Qwen2.5-1.5B-Instruct writing SQLite queries). It teaches no new training method. It applies lesson 11's ideas as a gate with thresholds fixed in advance, and adds the records, the staged exposure and the rollback that lesson 11 does not cover.

The result comes first and the exact setup, time and cost are in How it was built at the end.

1. What is a release?

A good lab result is evidence for a release, not the release itself. Define the approval criteria, preserve the previous version and know which tests must pass before replacing it.

Seven questions, each answered by a file:

decide -> describe data -> declare gate -> train -> gate -> record -> shadow, canary -> promote | roll back

Two rules sit under all of it. Write the test before you see the result: the decision rule, the data card and the gate are hashed and saved before the thing they judge exists, and each training run stores the gate's hash. Never trust a record you cannot re-hash: a manifest of SHA-256 hashes covers every file, so a changed byte is found rather than assumed away.

The release is eight files written in a fixed order, and the three that fix the rules come before any result

Release records in the order the notebook wrote them, with the first 16 characters of each SHA-256 as printed; blue marks a rule written before the thing it governs

1
RecordSHA-256, first 16Written before / holdsDecision ruledecision_rule.json18315a34c651395dbefore the baselinesBaselines and the bardecision_record.jsonin the manifestzero-shot 61.6%, bar 66.6%Data carddata_card.jsona087a6afc32605b5before any trainingGategate.jsonda0ac6274ab1a472before any candidateTraining config (v2)runs/v2/config.json148bbee0b1d5f79eholds the gate hashAdapter (v2, 73.9 MB)adapter_model.safetensorsd7ba4d877b444d71passed the gateRelease record, model cardrelease_record.jsonin the manifestapproval fields emptyRegistry and manifestMANIFEST.jsonin the manifest11 hashed entries
Source: lesson notebook, Colab T4. The decision rule, data card and gate are the three records written before baselines or candidates exist; each training run stores the gate's hash. 'Written first' is recorded inside one run; it is evidence of order, not proof against a later edit of the notebook.

Where a step is a decision for people, such as who approves, the notebook leaves a field empty, because a notebook can produce evidence and cannot accept a risk.

2. Should we fine-tune at all?

Fine-tuning is worth doing when its expected value is positive. With NN requests, accuracies afta_{ft} for the tuned model and aba_{b} for the best baseline, and vv the value of a correct answer,

ΔV=N (aft−ab) v  −  Ctrain  −  Crun  −  Cgovern\Delta V = N\,(a_{ft} - a_{b})\,v \;-\; C_{\text{train}} \;-\; C_{\text{run}} \;-\; C_{\text{govern}}

The notebook cannot supply vv or the costs, which come from the business, so it fixes what it can: the rule and the margin, written down before the baselines are measured. Lesson 1's discipline is to measure the baseline first, on the questions the tuned model will face.

# Written, hashed and saved BEFORE any baseline is measured.
DECISION = {
    "success metric": "execution accuracy on populated tables (gold query returns rows), gate set",
    "go rule": "fine-tune only if the best baseline's execution accuracy is below this value",
    "go threshold": 0.90,
    "required margin over the best baseline, points": 5.0,
    "alternatives considered": ["zero-shot prompt", "3-shot prompt", "LoRA fine-tune of the same model"],
}
DECISION_SHA = write_json("release/decision_rule.json", DECISION)   # 18315a34c651395d

The two thresholds are the notebook's declared values, with no business owner behind them. A real team would set them from the cost of a wrong answer. Execution accuracy runs each query on two differently filled copies of the question's tables and counts it only if it returns the gold rows, as lesson 11 argued; it is scored on the 450 of 500 gate questions whose gold query returns rows.

Then the baselines, with no training, on the same 500 gate questions as lessons 4 and 5:

BaselineExecution accuracyExact matchWell-formed repliesms per answer
Zero-shot prompt61.6%58.4%93.8%127
3-shot prompt54.2%59.4%100.0%170

The best baseline is 61.6%, below the 90% go threshold, so the rule says go, and the bar a fine-tune must clear is 61.6 + 5 = 66.6%. The zero-shot prompt becomes the incumbent, the system a candidate has to beat. Three examples of what it gets wrong are worth reading, because they set what "better" means: it guesses the case of text values ('cougars' for "Cougars", '48 Madison' for "48 madison"), and it swaps the output columns of an average query. In money terms, the gain the fine-tune is later measured to deliver, 19.8 points, is about 198 more correct answers per 1,000 requests, and vv turns that into a number the business can compare with CtrainC_{\text{train}}, CrunC_{\text{run}} and CgovernC_{\text{govern}}.

Name the institution with the nickname Cougars (table_24216139_2)

Gold
SELECT institution FROM table_24216139_2 WHERE nickname = "Cougars"
Incumbent
SELECT institution FROM table_24216139_2 WHERE nickname = 'cougars'

Wrong: the incumbent lower-cases the text value, so the query can return no rows.

Average account balance by account type, for credit scores below 50

Gold
SELECT AVG(acc_bal), acc_type FROM customer WHERE credit_score < 50 GROUP BY acc_type
Incumbent
SELECT acc_type, AVG(acc_bal) AS avg_balance FROM customer WHERE credit_score < 50 GROUP BY acc_type;

The same rows with the columns swapped: execution accuracy counts it as a miss when the column order differs.

Amazon's own case shows why the rule has to hold the cost claim to the quality claim. The paper reports about 98% lower inference cost and about 70% lower p90 latency than Sonnet 4.5, the cost figure an estimate from public pricing at the time rather than a billed cost. That is worth having only if quality holds in production, which the A/B test then checked and found it did not.

3. What was it trained on?

A data card answers what a reviewer asks first: where the data came from, what licence allows its use, what was removed, how it was split and whether the test set can be trusted. Its structure comes from datasheets for datasets (Gebru et al.), and the model card in section 6 from model cards (Mitchell et al.). The leakage checks are run, not assumed:

# No named table may appear in two splits; the test must not be worded like the training set.
overlap = {f"{a} & {b}": len(named_groups[a] & named_groups[b])
           for a, b in [("train", "test"), ("train", "validation"), ("validation", "test")]}
assert all(v == 0 for v in overlap.values()), overlap
same_question = sum(normalise(r["question"]) in train_q for r in rows["test"])

The card records sql-create-context at one pinned commit (licence CC BY 4.0, built from WikiSQL and Spider questions). Of 78,577 raw examples, 1,667 were dropped because their gold query fails in SQLite and none were exact duplicates, leaving 76,910, split by table into 69,170 for training, 3,817 for validation and 3,923 for test. No named table appears in two splits, no test question-and-schema pair is also in training, and 19 test questions are worded like a training question, a count the card reports rather than hides. Its known limits are written in: English only, mostly one table per question, one writer's style of gold query, no check for personal data because the source is public benchmarks. The hashes of the three splits are stored, so a changed file shows.

The practice scales. Dialpad's research on phone-call summarisation anonymised 25 million transcripts with Google's data-loss-prevention service before training and mixed in general-domain replay data to limit forgetting. That paper states the models were used for research only, so it is a model of what a data card records for sensitive data, not a deployment record.

4. What would make us say no?

The gate is a file. Every threshold is written and hashed before a candidate exists, and the checks each protect something different. Four ideas carry them.

The paired test. Both systems answer the same questions, so only the disagreements carry information, as lesson 11 derived. With ncn_c questions only the candidate gets right and nbn_b only the incumbent, n=nc+nbn = n_c + n_b and k=min⁡(nc,nb)k = \min(n_c, n_b), the exact sign test (McNemar's exact test) is

p=2∑i=0k(ni) 2−np = 2\sum_{i=0}^{k}\binom{n}{i}\,2^{-n}

The paired interval. With di=1[candidate right]−1[incumbent right]d_i = \mathbb{1}[\text{candidate right}] - \mathbb{1}[\text{incumbent right}] over nn questions, the difference is dˉ±1.96 sd/n\bar d \pm 1.96\, s_d/\sqrt{n}. The same expression, at the stage size, is the smallest gap a stage can detect, which section 7 uses.

The regression share. The share of what the incumbent already gets right that the candidate breaks, nbn_b divided by the number the incumbent gets right. A model can be better on average and still break questions that worked, which users notice more than the questions that improved.

Two metrics, not one. Execution accuracy accepts a query written differently that returns the right rows; exact match catches a query that happens to match on synthetic data. The gate requires a gain on the first and no loss on the second.

GATE = {
    "min_exec_gain_points": 5.0,
    "max_sign_test_p": 0.05,
    "min_exact_gain_points": 0.0,
    "max_regression_share": 0.10,       # of what the incumbent gets right, at most this share may break
    "min_format_ok": 0.99,
    "max_unsafe": 0,
    "max_ms_per_example": 400,          # an assumed service level, not a measurement
    "max_segment_drop_points": 3.0,     # no segment may fall this far below the incumbent
    "canary": {"max_unsafe": 0, "min_format_ok": 0.95, "max_runs_drop_points": 5.0, "min_paired_ci_low_points": -2.0},
}
GATE_SHA = write_json("release/gate.json", GATE)    # da0ac6274ab1a472, before any training

As in lesson 11, the numbers are declared values for the lab. The point is that they exist, in a file with a hash, before anyone has seen a result. Editing a threshold afterwards makes the hash in every run record stale, so the change is visible and has to be recorded as a new gate with a reason.

5. Does a candidate pass?

Two candidates are trained, and the recipe is lesson 4's: LoRA with rank 16 on every linear layer, learning rate 2e-4, one epoch, loss on the answer only. They differ in one thing, the number of examples: a pilot of 1,000 and the full 8,000. Each run first writes a config.json, hashes it, and the trainer is built from the file it just read, so the file is the recipe.

config_sha = write_json(f"runs/{name}/config.json", run_config)     # recipe, seed, base revision, n_train
cfg = json.load(open(f"runs/{name}/config.json"))                   # the trainer is built from the file
args = SFTConfig(output_dir=f"runs/{name}", **cfg["sft"], seed=cfg["seed"], data_seed=cfg["seed"])

The pilot took 2.2 minutes and 6.68 GB at the peak; the full run took 14.9 minutes and 6.78 GB. Both adapters are 73.9 MB. Final validation loss was 0.0368 for the pilot and 0.0196 for the full run.

Both candidates clear the declared bar by more than their intervals, and 8,000 examples did not beat 1,000

Execution accuracy on the 450 checkable gate questions, % (dot, 95% interval), with time per answer, training time and peak training memory

2
50%60%70%80%90%declared bar 66.6%ms / answertrain, minpeak GBZero-shot promptthe incumbent61.6127--3-shot prompt54.2170--v1, 1,000 examples62 steps79.32222.26.68v2, 8,000 examples500 steps81.321414.96.78
Source: lesson notebook, Colab T4, greedy decoding, batches of 16. The bar is the best baseline plus 5 points, declared before measuring. v1 and v2 differ by 2.0 points against intervals of about 3.6; the notebook did not test them against each other, so the gap is within noise.

Both candidates clear the 66.6% bar by more than their intervals. The second reading is less welcome. v2, trained on eight times the data, scored 81.3% against v1's 79.3%, a difference of 2.0 points inside intervals of about ±3.6, and the notebook did not test the two against each other, so this lesson does not show that the extra 12.7 minutes bought accuracy. Exact match did move more (67.6% to 72.2%), and well-formed replies and queries that run improved too (97.8% to 99.4% of queries run), so the larger set is not useless, only unproven on the number that decides the gate. The release rule picks the passing candidate with the highest execution accuracy, which is v2; the table below shows how little it had to spare.

v1 and v2 pass all eight checks; the control, a candidate with no training behind it, fails four

Gate checks against the zero-shot incumbent on 500 held-out questions; blue = pass, orange = fail; thresholds were written and hashed before training

3
CheckThresholdv1 · 1,000v2 · 8,000Control: 3-shotExecution gain, points≥ 5.0+17.8+19.8−7.3Sign test p, candidate better< 0.05< 0.0001< 0.00010.0002, worseExact-match gain, points≥ 0.0+9.2+13.8+1.0Regression share≤ 10%6.9%9.7% (0.3 spare)19.5%Well-formed replies≥ 99%100.0%100.0%100.0%Unsafe replies0000ms per answer≤ 400222214170Worst segment drop, points≤ 3.00.00.011.2VerdictPASS, 8 of 8PASS, 8 of 8FAIL, 4 of 8
Source: lesson notebook, Colab T4. Execution accuracy on populated tables over the 450 questions whose gold query returns rows. The control is the 3-shot prompt submitted as a candidate; it is the worse baseline, so the gate must refuse it, and it did.

The sign test against the incumbent is below 0.0001 for both candidates. v2's regression share is 9.7%, 0.3 points inside the 10% limit; v1 breaks fewer questions that worked (6.9%) while gaining slightly less. A team with a stricter limit would have released v1, which is a reason to set the limit from what a broken answer costs, not after seeing which candidate fits.

The control is the 3-shot prompt submitted as if it were a candidate. It is the worse baseline, so the gate must refuse it, and it fails four checks: a loss of 7.3 points, a sign test that says it is worse (p = 0.0002), 19.5% of the incumbent's right answers broken, and an 11.2-point drop in one segment. A gate that has never refused anything has not been shown to refuse; the notebook asserts that the control is refused.

A pass is a statement about the questions counted, so the regressions are read. v2 breaks 27 questions the incumbent answers correctly. The first four:

question : Name the latitude for deer lake
gold     : SELECT latitude FROM table_18600760_4 WHERE township = "Deer Lake"
candidate: SELECT COUNT(latitude) FROM table_18600760_4 WHERE township = "Deer Lake"

question : What was the date of the finale for Season 3?
gold     : SELECT finale FROM table_name_61 WHERE season = 3
candidate: SELECT finale FROM table_name_61 WHERE season = "season 3"

All four are real errors, none a harmless rewrite: two wrap the column in COUNT where the question asks for a value, and two put words into a value that is a bare number ("Game 5" for 5). Kasisto reports in the same spirit. Its production comparison of 3,297 queries over seven months raised resolution from 77.4% to 84.5% (p < 0.001), and it states that satisfaction rising from 59.5% to 62.9% is not significant (p = 0.26, interval −2.5 to +9.3 points). A release record that says "not significant" next to a significant result is doing the same job as this gate.

6. What is released?

Everything needed to audit or rebuild the release goes into one record, and the part a person reads is generated from the same numbers, never typed. The record ties four things together, the data hash, the config, the gate and the adapter hash, on a base model pinned to a revision. The model card follows the section list of Mitchell et al. in short form:

# Model card: sql-assistant-v2-20261126
Base model: Qwen/Qwen2.5-1.5B-Instruct, revision 989aa7980e4c...   Adapter: LoRA, 73.9 MB, sha256 d7ba4d877b44...
Intended use: a plain-English question about a stated SQLite schema -> one read-only SELECT query
Out of scope: no read-only connection; many-table joins; other languages; decisions made without a person reading the result
Evaluation (gate set, 500 questions): incumbent 61.6% execution, this release 81.3%; well-formed 93.8% -> 100.0%; unsafe 0 and 0
Known limits: synthetic rows, not a customer's data; gate and training data share two public benchmarks; slow queries on large tables not checked
Approval: Owner ________  Risk reviewer ________  Date ________

The approval line is empty on purpose.

In a regulated firm the empty line has a process behind it, and the sources are careful about its scope. The Federal Reserve's SR 26-2 (17 April 2026) superseded SR 11-7, and a footnote of its attachment places generative and agentic AI models outside its scope, so a bank's fine-tuned language model falls under the bank's own governance rather than under that letter. What carries over is the practice. SR 11-7 named three validation elements, conceptual soundness, ongoing monitoring and outcomes analysis; in this release they are the decision, data and gate records, the guard metrics that keep running after release, and the gate and canary results. A bank's own practitioners (Wells Fargo authors, arXiv 2503.15668) describe the version for generative models: the specification has to discuss the choice and parameters of customisation, simpler methods are benchmarked to justify the model, and a higher-parameter model, tuned or not, can serve as the benchmark, and a monitoring plan names its metrics, thresholds and actions for poor performance. Those are the zero-shot and 3-shot baselines, the config file and the guard thresholds above. It is a paper, not a deployment record.

EXL's medical-claims system on AWS shows controls of the same family in production: the LoRA fine-tune of a domain model ran in an isolated SageMaker environment separate from production inference, three insurance experts reviewed outputs blind, each field carries a confidence score from 0 to 100 with a configurable threshold below which a person reviews it, and every answer is traceable to its source. The blog gives review time falling from days to hours and no accuracy figures, so it supports the shape of the controls and not any claim of accuracy.

7. Does it hold on traffic that looks different?

The gate set is a benchmark. Live traffic has another mix, so a second held-out slice is drawn on purpose with more Spider-style questions, which are the ones with named tables like a company's own schema. Two things are simulated. In shadow, every request is answered by both systems and only the incumbent's reply would be served, so the candidate's quality and latency are measured at no risk. In the canary, a rising share of requests is routed to the candidate, with guards (unsafe replies, well-formedness, queries that run) that stop the rollout.

In shadow, v2 gave a different query on 37.5% of 400 requests and was right more often where they differed, at 1.8 times the latency

Both systems answered the same 400 requests on a second held-out slice; only the incumbent's reply would be served

4

Same query on 62.5%

Share of 400 requests, %

a
same, 62.5%differ, 37.5%Only differing requests can change an outcome

Slower per answer

Time per answer, ms

b
Incumbent129v2, adapter loaded236

Better on every measure

Canary slice, incumbent → v2, %

c
Execution accuracy63.078.8Exact match53.269.2Query runs96.299.5Well-formed95.0100.0○ incumbent ● v2, %

Who is right when they differ

Questions out of 373 with a checkable answer

d
Only v2 right80Only incumbent right21
Source: lesson notebook, Colab T4, batches of 16. Execution accuracy on the 373 requests whose gold query returns rows. Same query means equal after whitespace, case and quote normalisation.

The two systems gave the same query on 62.5% of the 400 requests. On the 373 with a checkable answer, v2 was right where the incumbent was not on 80 questions and the reverse on 21. It was slower, 236 ms against 129, which the gate's 400 ms ceiling allows and a latency budget should still weigh.

Live traffic is never the benchmark's mix: here it is two thirds Spider-style, and the gain is still there

Left: share of each question style. Right: execution accuracy of the incumbent and v2 on the canary slice, by style

5

Spider-style share: 34%, 34%, then 65%

Questions by table style, % of the set

a
Test split3,923 questions66%34%Gate set500 questions66%34%Canary slice400 questions35%65%WikiSQL styleSpider style (named tables)

Both segments gain; the named tables gain less

Canary slice, execution accuracy, incumbent → v2, %

b
Spider style255 questions66.376.9WikiSQL style118 questions55.983.1○ incumbent ● v2; axis 40% to 100%
Source: lesson notebook, Colab T4. The canary slice was drawn on purpose with 35% WikiSQL-style questions to play a live mix (about 66% in the test split). Segment sizes count the 373 questions with a checkable answer. Gate and canary questions are disjoint.

The slice is 65% Spider-style against 34% in the gate set, and the gain held in both segments: 66.3% to 76.9% on the 255 named-table questions, and 55.9% to 83.1% on the 118 WikiSQL-style ones. The named tables gain less, which matters because they are the ones that look like a customer's schema. The gain is not a mix effect. Whether it would survive a mix further from the benchmark is not something this slice can say.

The staged rollout then routed 10%, 50% and 100% of requests to v2 in windows of a quarter, a quarter and a half of the slice. The routing is a fixed hash of the request id, so the same request always takes the same path.

A canary can show a model is not broken early, but only the full slice is tight enough to confirm a gain: +15.8 points, 10.8 to 20.9

Candidate minus incumbent execution accuracy on the requests routed to v2, points (dot, 95% interval); bars: requests that reached v2 at each stage

6
-200+20+40+60+80declared floor for the interval's low end: −2.0better ↑+37.51.6 to 73.48Stage 110% of traffic+4.3-9.0 to 17.652Stage 250%+17.610.7 to 24.5200Stage 3100%+15.810.8 to 20.9400Whole sliceall 400 requestsrequests that reached v2
Source: lesson notebook, Colab T4. Routing is a fixed hash of the request id. Guards at every stage (unsafe, well-formed, queries that run) passed. Delayed labels: the full slice is scored on the 373 requests with a checkable answer; 80 only v2 got right, 21 only the incumbent.

Every stage advanced: no unsafe replies, every reply well-formed, and the share of queries that run never fell. The labelled gap is the instructive column. At stage 1 only 8 requests reached v2, and the interval on the gap runs from +1.6 to +73.4 points, too wide to tell a small gain from a huge one. At stage 2, with 52, the point estimate is +4.3 and the interval, −9.0 to +17.6, still includes zero. Only the full slice is tight, at +15.8 points with an interval of +10.8 to +20.9, above the declared floor of −2.0 for its low end. A canary at this size can catch a broken model early, and it cannot certify a gain; the certificate is the gate, and the canary is a second look on another mix. A real canary is sized from a power calculation with the half-width formula in section 4, not from a convenient number of requests.

Amazon's reversal is the case for keeping that second look. Its candidate won on the benchmark and lost live, and the paper's explanation is a distribution shift between the two. Here the shift was built in, the gain survived it, and that is evidence, not a guarantee: the slice is still two public benchmarks. Shopify went further. It deployed to 1% of traffic after benchmark parity, found the 35% lower activation, read the failures by tagged slice (email workflows were 25% of them, diverse condition patterns 16%), added what the benchmark lacked and, by its account, closed the gap in two weeks. The deployed model is now reported as 2.2 times faster and 68% cheaper than the closed model it replaced, and serves most of its traffic. Its guardrail was a metric the team did not optimise, which is the job a canary's guards do here.

8. Can we go back?

A rollback that has never been run is a hope. The release is registered with two aliases, production and previous, and each version stores what it needs to be rebuilt: the base model's pinned revision, the adapter path and the adapter's hash. Promotion is allowed only for a version that passed the gate and the canary, and moving production is a pointer move on the aliases.

def load_version(vid):
    """Rebuild a version from the registry alone: pinned base revision, verified adapter."""
    v = REGISTRY["versions"][vid]
    model = load_base().eval()                       # passes revision=BASE_REV
    if v["kind"] == "prompt":
        return model, PROMPT[vid]
    verify_adapter(v["path"], v["sha256"])           # raises if one byte differs
    return PeftModel.from_pretrained(model, v["path"]).eval(), zero_shot

Rollback was run, not described: the old and new versions each reproduced 96 of 96 recorded replies, and damage was caught

Rollback drill and manifest check; bars: probe replies that are byte-for-byte the recorded ones, out of 96; every digest over the 96 replies matched

7
Same replies, of 96Fresh load of v2 from the registrypinned base revision, hash-checked adapter96 of 96digest equal ✓Adapter switched offreproduces the zero-shot replies recorded before training96 of 96digest equal ✓Alias flipped to zero-shot, fresh loadthe rollback itself96 of 96digest equal ✓Adapter with one byte changedloader: does not match its registered hashrefusedManifest of the release11 hashed entries0 mismatchesOne space appended to the release recordonly that file is named1 mismatch foundRecord restoredmanifest verifies again0 mismatches
Source: lesson notebook, Colab T4. Probe: the first 96 gate questions, same batches of 16, greedy decoding. Fresh loads rebuild from the registry alone. The manifest holds 7 record files, 2 adapter hashes and 2 training configs.

Three things were checked, not assumed. A fresh load of v2 from the registry alone reproduced all 96 recorded replies, byte for byte. Switching the adapter off reproduced the 96 zero-shot replies recorded before any training, and flipping the alias to the incumbent and loading it from scratch did so again; production is then flipped back to v2. A copy of the adapter with one byte changed was refused by the loader. Bit-for-bit equality on a GPU is expected but not guaranteed, so the notebook prints the counts rather than asserting them; here they were 96 of 96 each time.

The manifest does the same for the records: 11 hashed entries, none mismatching, and after one space was appended to the release record the check named that file and no other. It then restored the record and verified again.

LoRA is what makes this cheap. The adapter is 73.9 MB and the base model is shared, so a previous version costs a second small file and an alias, not a second copy of a 1.5B model. Three things would make it hard, and each is a decision made earlier: a merged or quantised artefact with no stored original, a base model revision that is no longer available (which is why the revision is pinned), and a previous version that was never run through a drill.

9. What to keep

If you have a task like this one:

  • Write the decision rule, the gate and the data card before you train. Here they were hashed before any candidate existed, so a threshold edited after the results would show as a stale hash in every run record. Treat a changed threshold as a new gate with a recorded reason and re-run the candidates against it.
  • Submit a control to the gate. The 3-shot prompt, the worse baseline, was refused on four checks; a gate that has never refused anything has not been shown to refuse.
  • Read the regressions, not only the average. v2 passed at 9.7% against a 10% limit and breaks 27 questions the incumbent answers correctly; the first four are real errors (COUNT wrapped around a value, words put into a bare number).
  • Stage the exposure on a slice with a different mix, and do not read a small stage as proof. At 8 and 52 requests the interval on the gap included values from about zero to a very large gain; only the full slice (+15.8 points, +10.8 to +20.9) was tight. Use the stages to catch a broken model and the gate to certify a gain.
  • Run the rollback and generate the model card from the record. 96 of 96 replies reproduced in three drills, a damaged adapter was refused, and the manifest named the one edited file. Release the hashed artefact rather than the recipe, because the adapter hash can differ on a rerun with the same seed on a GPU, and compare replies in the same batches or compare execution results and say so.
  • Match the process to the cost of a wrong answer. Use the full set for a model serving customers, in a regulated firm, or where the person who trained the model is not the person who accepts the risk; a lighter process is enough for an internal prototype where a person reads every answer. The records are small, so the heavy part is the discipline of writing them first. Approval stays with a person: the fields are empty.

Next to try, not tested here:

  • v1 against v2 directly. 81.3% against 79.3% sits inside the intervals and the notebook did not run the paired test between them, so the extra 12.7 minutes of training is unproven on the number that decides the gate.
  • A stricter regression limit set from the cost of a broken answer. With the limit at 9% v2 would fail and v1 would pass; the limit should come from that cost, not from which candidate fits.
  • A canary slice further from the benchmark. The gain held on a slice that is 65% Spider-style, but both slices come from the same two public benchmarks, and the named tables gained less (66.3% to 76.9%).
  • A canary sized from a power calculation. The half-width formula in section 4 gives the requests a stage needs to detect a given gap; the stages here were fixed by quarters of the slice.

How it was built

ItemSetting
Base modelQwen/Qwen2.5-1.5B-Instruct, revision 989aa7980e4cf806f80c7fef2b1adb7bc71aa306, fp16
Datasql-create-context at commit 9d80a6a118b8, cleaned and split by table in lesson 3 (78,577 raw, 76,910 kept; train 69,170, validation 3,817, test 3,923). v1 trains on the first 1,000 of 8,000 training examples sampled with seed 42, v2 on all 8,000; 200 validation examples give the loss curve
TestGate set: 500 questions from the test split, seed 42, the same as lessons 4 and 5. Canary slice: 400 further test questions, disjoint from the gate set, 35% WikiSQL-style. Metric: execution accuracy on two differently filled copies of the tables with 30 rows each, over the questions whose gold query returns rows; exact match and well-formed rate alongside
MethodLoRA through TRL SFTTrainer: r=16, lora_alpha=32, lora_dropout=0.05, target_modules="all-linear", 18,464,768 trainable weights
Training1 epoch (62 steps for v1, 500 for v2), batch 8 × 2 accumulation = 16, learning rate 2e-4 with cosine decay and 3% warm-up, fp16, gradient checkpointing, max_length=256, loss on the answer only, seed 42; each run's settings are written to config.json and the trainer is built from that file
DecodingGreedy, batches of 16, at most 128 new tokens, left padding; the adapters use the zero-shot prompt
GateExecution gain at least 5.0 points, sign test p below 0.05, exact-match gain at least 0, regression share at most 10%, well-formed at least 99%, no unsafe reply, at most 400 ms per answer, no segment more than 3.0 points below the incumbent; canary guards: no unsafe reply, well-formed at least 95%, queries that run down by at most 5 points, interval low end at least −2.0 points
HardwareOne Tesla T4 on Google Colab; transformers 4.51.3, peft 0.15.2, trl 0.19.1

Time and cost. v1 trained for 2.2 minutes at a peak of 6.68 GB and a final validation loss of 0.0368; v2 for 14.9 minutes at 6.78 GB and 0.0196. Both adapters are 73.9 MB. On the gate set the incumbent took 127 ms per answer, the 3-shot prompt 170 ms, v1 222 ms and v2 214 ms; on the canary slice the incumbent took 129 ms and v2 236 ms. The eight release records add up to about 14 KB (derived from the printed sizes), and the whole notebook took about 27 minutes.

Which set each number comes from. The baselines, the candidate table, the gate checks, the regression list and the model card come from the 500-question gate set (450 checkable). The shadow, mix and canary numbers come from the 400-question canary slice (373 checkable); the shadow runs on the same 400 requests the canary routes. The rollback probe is the first 96 gate questions. None of them is the 3,923-question test split.

Run it yourself

The notebook runs on a free Colab T4 and took about 27 minutes in total, of which training took 2.2 minutes for v1 and 14.9 for v2. It writes the release folder: the decision, data card, gate, registry, release record, model card and manifest. Its sections follow this page: 1 is the decision, 2 the data card, 3 declares the gate and trains the candidates in Does a candidate pass?, 4 runs the gate there, 5 writes the release record, 6 is the shadow and canary and 7 the rollback; the closing comparison is in What to keep. Three changes to try:

  1. Lower max_regression_share from 10% to 9% and rerun the gate. v2 fails and v1 passes; does the release rule still pick the candidate you would choose, and what would you want the rule to say?
  2. Set N_TRAIN_FULL to 4,000 and test v1 against the new adapter directly with the paired interval. Where does extra data stop paying?
  3. Redraw the canary slice with 10% WikiSQL-style questions and add the per-segment drop to the canary guards. Does the gain on the named tables hold?

Looking back over the course, it began by asking whether to fine-tune at all, and it ends with a model that can be explained, checked and withdrawn: lesson 1 set the decision, lesson 3 the data, lessons 4 and 5 the training, and lesson 11 the evidence, and this release is those choices written down in the order they were made.

Sources

Amazon, progressive fine-tuning for structured attribute generation · Shopify Engineering, Flow generation through natural language · Kasisto and Backbase, FinRAG-12B (ACL Industry 2026) · AWS Machine Learning Blog, EXL Medical IDP · Federal Reserve SR 26-2 · Model risk management for generative AI in financial institutions · Dialpad, DACP · Mitchell et al., Model Cards for Model Reporting · Gebru et al., Datasheets for Datasets

How is this page?

Last updated on