back to home

Post-Training a Slide-Design Model: SFT, DPO, a Verifier, and a Prompt Bug

#post-training#sft#dpo#tinker#evals#best-of-n#qwen

Here's the week, run by run. The most useful row has no training in it at all.

# Version Change Result What happened
1 v1 SFT First LoRA on a curated design set Visual galleries only It could produce valid slides
2 v2 scaled 93 designer-grade slides, 88% clean 9 fail / 5 borderline (of 14) Top-loading persisted. Read as an SFT ceiling
3 SFT tweak +24 sparse examples, 60 steps 9 → 3 fails Better, not fixed
4 Best-of-N + verifier No training 8 → 0 fails, 14/14 acceptable A cheap check picked a good sample
5 Step 80 Later checkpoint 19/20 on the target editor's HTML validator The one miss fell back to a placeholder
6 Float DPO 92 same-input pairs, from step 80 Single-sample fails 11 → 7; 0 fails with best-of-6 Became the champion, despite truncating at 4,096 tokens
7 Lower-N DPO 138 pairs Held-out single-sample pass 65% → 58% Overfit, dropped
8 Taste study Vision judge 2.95 vs teacher 3.83 The model had no high-taste mode
9 Taste DPO 158 pairs Superseded Built the same day the real cause turned up
10 Contract fix Prompt change, new gold, retrain Top-loaded gold slides 78% → 1% The "model bug" was a contract bug
11 v3 SFT 135 rows, LoRA rank 16, SFT only Final model Prompt frozen byte-for-byte for serving

In three lines: I fine-tuned Qwen3.6-35B-A3B with LoRA on Tinker to turn a slide spec into one block of editable HTML. Sampling a few candidates and letting a deterministic layout check pick one took held-out failures from 8 to 0 with no weight change, and a float DPO run cut single-sample failures from 11 to 7. Two days later the defect turned out to be in the instruction the training targets were written under, and a prompt fix took top-loading in the gold slides from 78% to 1%.


The Task: a Slide Is a Contract

The model gets three things: a design identity (a look, a 12-token colour palette, explicit typography), a slide spec (an archetype such as big_stat, timeline or comparison, a title, a density), and the content. It returns a short <reasoning> block, then a single root <div> with inline styles that implements the slide.

The output has to survive an in-place editor, so the rules are strict:

  • one root element, inline styles only: no <style> tags, no classes, no scripts,
  • colours only through the 12 --slide-* tokens, used by role, with one accent,
  • the identity's type scale, weights and tracking, with clamp() sizing that works at 1920×1080 and on a ~400px phone,
  • every piece of text an editable leaf node, decorative nodes hidden from screen readers, and no text collisions,
  • image slots as a styled placeholder element carrying an image prompt, filled later.

The design vocabulary was fixed: 14 archetypes, 10 looks (editorial, brutalist, swiss-white, mono-dark…) and 25 palettes, each with typography mined from real designs.

Why train a model instead of prompting a frontier one per slide? Consistency inside a fixed design system, a strict output contract that a small model could learn, and every generation becoming a training record for later.


Setup

Base and platform. Qwen3.6-35B-A3B, a mixture-of-experts model with 35B parameters in total and about 3B active per token (the Tinker cookbook's qwen3_5 renderer is only its chat template), LoRA fine-tuning on Tinker, with runs, checkpoints and adapters tracked in MLflow. LoRA rank 32 at first, rank 16 for the final model. The learning rate came from an LR finder.

Data. The first set was curated from real design layouts, with a quarantine list and a dataset card. To scale it I built a cascade:

  1. fabricate a slide spec,
  2. sample a strong teacher model several times (best-of-N),
  3. pass the candidates through a float gate (below), a no-drop check (every content string must survive into the HTML) and a cheap text-only judge,
  4. route each one: accept, rescue a borderline one, or reject.

The first round accepted 5 slides, 4 of them designer-grade. Scaled up, it took the clean set from 28 to 93 slides across six cells, after a "borderline rescue" path fixed grid layouts being starved out.


The Defect: Top-Loading

From the second version on, one failure dominated. On slides with only a few items, the model stacked everything at the top and left the bottom half of the canvas empty. I called it float.

To measure it I wrote a deterministic float detector. Render the slide, measure the vertical gaps, and score. Calibrated on labelled examples, floaty slides scored ≥ 0.276 and clean ones ≤ 0.151. A composite gate (the gap score plus top and bottom margins plus vertical fill) blocked the junk and kept the good slides. Running it over my "pristine" set found 3 floaty slides hiding in it. They moved to the negative pile.

On a 14-slide held-out set, the scaled retrain still failed 9 and was borderline on 5. The data was 88% clean and more of it didn't help. I read that as an SFT ceiling on few-item layouts and planned preference training.

Before that, a smaller fix. Adding 24 sparse examples and training for 60 steps took float fails from 9 to 3. And checkpoint selection had a bug of its own: my first selection objective picked step 10, the checkpoint with the most float failures. Ranking by the float gate first (fewest fails, then most clean) picked step 60.


Best-of-N With a Cheap Verifier

The cheapest experiment of the week: instead of changing weights, sample several candidates from the same model and let the float detector choose.

Held-out slides with a layout failure: 8 of 14 with a single sample, 0 of 14 with best-of-N and the verifierHeld-out slides with a layout failure: 8 of 14 with a single sample, 0 of 14 with best-of-N and the verifier

In the inference shim's own run, a single sample per slide gave 8 layout failures on the 14 held-out slides (that run didn't record which checkpoint it sampled or how many samples it drew, so the 8 doesn't compare with the 3-fail count above). Best-of-N plus the deterministic check: 0 failures, 9 clean, 14/14 acceptable. No training run, no new data.

One caveat I want to be clear about: the float detector is both the selector and the metric here. This shows the model can produce a passing layout within a few samples, and that a free check can find it. It doesn't show a judge-independent quality gain. n = 14, so the upper bound on the true failure rate is still about 23%.

The next day, a later checkpoint (step 80) went through the target editor's HTML validator: 19/20 slides passed. The one miss was a bar chart on a dark theme where all six samples floated, and it fell back cleanly to a placeholder slide. The weakness was concentrated in the thinnest data cell.


Float DPO: It Helped, Then More Pairs Overfit

Preference training still looked like the principled fix for float. I harvested 92 same-input pairs (one filled layout, one floated layout, same spec) and ran DPO from the step-80 checkpoint: β 0.1, LR 1e-5, LoRA rank 32.

It helped. On the held-out set, single-sample float failures went from 11 to 7, clean slides under best-of-6 went from 8 to 11, and best-of-6 had 0 failures on the 14 held-out slides. That checkpoint became the champion.

Then I pushed further, aiming to make single samples good enough that best-of-3 could replace best-of-6: 138 pairs, the 92 plus 46 from the model's own samples. That run overfit. The held-out single-sample pass rate fell from 65% to 58%, so I dropped it and kept the 92-pair champion.

I never ran DPO and the verifier head to head on the same set, so I can't say which one mattered more. What I can say is that DPO made single samples better, and the verifier made best-of-N safe.

Two things went wrong on the way, both worth knowing:

  • Sampler checkpoints can't seed training. The checkpoint I wanted to start from had been saved as sampling weights only, which can't be loaded for further training. Since then I save the full training state alongside every sampler checkpoint.
  • Truncation. Max length in the float DPO was 4,096 tokens, and full HTML slides with reasoning ran longer, so targets were cut off. It helped anyway; the next round raised the limit to 6,144.

The Taste Study: What Selection Can't Fix

Float is geometry. I also wanted to know whether the slides were good. I built a vision-model taste judge with a rubric that separates intentional restraint from broken layout, and scored the trained model against the teacher models under the same contract.

Taste judge scores out of 5: trained model 2.95, teacher with best-of-N 3.77, frontier teacher 3.83Taste judge scores out of 5: trained model 2.95, teacher with best-of-N 3.77, frontier teacher 3.83

Arm Mean taste score Top
Trained model 2.95 4.0, none ≥ 4.5
Open teacher + taste-guided best-of-N 3.77 --
Frontier teacher, same contract 3.83 4.4

Two findings changed the plan.

The trained model had no high-taste mode. Its best slide scored 4.0 and none reached 4.5. Best-of-N can only pick from what the model produces, so selection couldn't close a 0.9-point gap. That's a data and training problem, not a decoding one.

The float gate was anti-taste. Slides the judge rated 4.0 failed my geometry check. Deliberate whitespace looks like float to a detector that only measures gaps. A geometry metric is a floor, not an objective.

I built another DPO set from this: 158 taste pairs, chosen = tasteful, rejected = airy or broken hard negatives, with length bias checked (65% of chosen sides were longer, so I made sure length alone didn't decide).


The Root Cause Was the Contract

Then, the same day, the actual answer. Going back through why the model top-loaded, I found the problem in the contract: the instruction the training targets had been written under didn't ask for the canvas to be filled. The model was faithfully following a prompt that never asked for what I was penalising it for.

The renderer put each slide in a fixed 1920×1080 frame, but the contract told the root element to use min-height: 400px. That fills the width, not the height, so content sat at its natural height at the top. Under the old contract even the teacher models top-loaded 31 of 40 slides. With the root set to fill the frame and the main block centred, top-loading in the teacher's gold slides fell from 78% to 1% (66 of 72 clean), and the model retrained on that gold filled the canvas by default. DPO had reduced the symptom; the prompt removed the cause.

The lesson I took: before reaching for preference training, re-read the instruction the targets were made under. A model that consistently does something "wrong" may be consistently doing what it was told.

The final round (v3) trained on 135 rows of gold slides. A rank sweep showed rank made no difference at this data size (rank 32 is tens of millions of trainable parameters against 135 rows), so I used rank 16. The LR finder's "steepest slope / 3" rule turned out to be broken; I switched to Smith's "minimum / 10", clamped to [5e-5, 3e-4], with the note that a train-loss finder biases high on small data and has to be confirmed on validation.


Serving: Every Byte Must Match

The serving path takes best-of-N: N = 4 parallel samples at temperature 0.6 (the serving endpoint doesn't support n > 1, so they're separate calls), max 6,144 tokens, any output that didn't finish cleanly rejected. Each candidate is rendered and scored with a port of the training repo's scorer:

  • hard gates: valid HTML, at least 3 distinct palette tokens used, no off-palette saturated colours, completeness ≥ 0.9 (each content string at ≥ 70% word recall), no overflow (more than 32 px clipped on any side), no collision (more than 30% overlap), no leaked escaped tags,
  • ranking: passes the gates, then no overflow, then vertical fill inside [0.42, 0.70], then completeness, then distance to that band.

The system prompt in serving is byte-identical to the one the model was trained on, with a comment saying not to "improve" it: retrain first, then bump the version.

Integration surfaced a whole class of train/serve skew. Each one would have quietly degraded the model:

  • Archetypes. The host app tagged slides with 4 types; the model knew 14. A deterministic content-shape → archetype map fixed it.
  • Looks. Mapping the host app's themes to the nearest look reached only 5 of the 10 trained looks. Feeding the 25 training palettes directly fixed it.
  • Fill metric. Training scored vertical fill as a 1-D band; the serving renderer measured 2-D area coverage. I added a vertical-fill measure so the band meant the same thing in both places.
  • Image slots rendered as 0×0 until filled, so image slides scored as empty. Scoring now fills the slot with a placeholder first.
  • The picker preferred the worst slide. When no candidate passed every gate, the first ranking used raw vertical fill as its last key, so it chose the most overflowing slide (fill > 1.0 means content clipped off the frame). Adding a no-overflow key and ranking by distance from the band fixed it.
  • Training-record index. The record of which candidate won indexed the filtered pool, not the stored candidate list, so it would have credited the wrong slide as the winner.

What I'd Do Differently

  1. Check the contract before the weights. The defect I trained against for two days was in the instruction the targets were written under.
  2. Try a verifier and best-of-N first. It took held-out failures from 8 to 0 for the cost of a few extra samples.
  3. Know what selection can't fix. Best-of-N over a model with no high-taste mode tops out where the model's distribution does.
  4. Treat geometry metrics as floors. My float gate rejected slides a taste judge rated 4.0.
  5. Watch what your selector selects. One objective picked the worst checkpoint; one ranking picked the most overflowing slide.
  6. Save training state, not just sampling weights, and size max length to your longest target before you run preference training.
  7. Freeze the training prompt byte-for-byte in serving, and diff every input key, name and field against training.

The model learned a strict HTML contract in a week. What I'd carry forward is the order of operations: check the instruction, then the verifier, then the data, and only then the weights.