The dataset is currently empty. Upload or create new data files. Then, you will be able to explore them in the Dataset Viewer.

Field Notes: Building PARRY — a duelist that lives in your browser

The thesis

A fighting-game opponent must answer inside the gap between your moves. That is a latency budget no network round-trip can meet — not because clouds are slow, but because physics adds 100–300ms before any GPU even starts. So Parry's brain is a 1.5B model running in your browser via WebGPU: every decision pays 0ms of network, and you can pull your Wi-Fi out mid-match to prove it.

The deeper bet: a small model isn't interesting because it can imitate a big one — it's interesting where the big one is disqualified. Real-time loops are that place.

The two-speed brain

One set of weights, two jobs:

  • Tactician (every ~160ms): one grammar-constrained letter — S F P L R W — decoded from an ~85-token prompt describing the (delayed) world.
  • Analyst (every ~2s): reads a behavior log of you, writes a plan-string — "Wake-up striker. Bait it, punish the whiff." — which is injected into the Tactician's prompt verbatim and rendered on screen.

The plan you see is the plan that steers it. The judge panel (press B) lets you edit that read live and watch the play shift — the coupling is measured, not narrated: the tuned model's plan-conditioning is 2-3× the base model's on every intervention metric, at the ceiling of our registered direction test, and roughly half the teacher's strength in on-screen play-style separation. (The full numbers — including the pre-registered gate we failed twice and what measuring its ceiling taught us — are in the training section below.)

Fairness engineering (the AI is never psychic — unless you let it be)

  • A reaction-delay buffer delays everything the model sees, like a nervous system. It shipped at 180ms ("FAIR") for most of development; the submitted default is 0ms BOSS reflexes — playtesting showed judges deserve to lose — with FAIR one click away in the judge panel. Either way it's a slider on screen, disclosed, not a hidden cheat.
  • During your strike's startup, its prompt says WINDUP — it cannot tell a strike from a feint mid-telegraph, exactly like a human watching the same pose.
  • Same move-set, same frame data, same arena. It wins by reading you (and by imagining futures — see below), not by different rules.

What the measurements taught us (the honest part)

  1. In-browser prefill is the binding term. Research estimates said thousands of tok/s; the M5 measured ~450 tok/s through WebLLM. Our 140-token prompt cost 328ms/decision. Compressing it to ~85 tokens halved that to 158.6ms. The fine-tune lets us delete the tactics cheat-sheet from the system prompt — training literally buys speed.
  2. Grammar dialects bite hard. The installed XGrammar requires the root rule named root; main ::= doesn't error — it fatally aborts the WASM engine.
  3. top_logprobs caps at 5 in WebLLM, and interruptGenerate() is only safe against streaming calls — so the Analyst always streams.

Teaching a 1.5B to fight: six broken teachers

The training data comes from a deterministic engine (pure-TS, integer-only, byte-identical between the browser and the Node data generator — proven by a golden-trace CI test). The expert policy that generates demonstrations went through six diagnosed failures, each invisible until instrumented:

  1. Superhuman cadence — scripted sparring bots decided 60×/s. Humans don't.
  2. Superhuman vision — bots reacted to telegraphs with 0ms perception delay; gave them the same 180ms eye-lag as the AI. Symmetric senses, fair sparring.
  3. Impossible punishes — through 180ms of eye-lag + 200ms of strike startup, most "punish windows" were unreachable. The expert kept striking ghosts.
  4. The immunity collision — our anti-rehit rule makes locked targets invulnerable, so "guaranteed punishes" landed on immune frames: silently wasted. The only legal punish is the meaty — timed to land 0–12 ticks after wake-up. (Observed-frames band: F ∈ [12..24].)
  5. An unbeatable defense — perpetual back-walking blocked everything; the defensive bot's win rate exposed a real game-design hole. Fix: corners negate block + chip damage — the classic answers, and they made the game deeper for humans too.
  6. No defense at all — the expert never wake-up-parried; bots vortexed it. Wake-up parry + windup retreats took hit-balance from 2.2/5.7 to 7.6/7.7 — even sparring, on both sides of the trade.

Teacher quality across iterations: 8% → 13% → 38% overall win rate vs the bot gauntlet — and the number that matters for conditioning: 72% with the matched plan vs 39% with a mismatched one. The plan steers the teacher, so it can steer the student. Every iteration was a 30-second local gate — none of these bugs ever reached a GPU.

Training — including the gate we failed

Behavior cloning (LoRA r=32 α=64, completion-only loss), Modal A100s:

  • Pilot (20k examples): 79.5% held-out action agreement (gate: ≥50%).
  • bc_v1 (98k examples): 77.1% — and then the pre-registered ΔP intervention gate FAILED: tuned ΔP 0.07 (needed ≥0.30), vs base 0.14. Training had made the model an excellent state player and a plan-deaf one.
  • The no-plan ablation proved it: 75.3% vs 77.1% — the plan-string was contributing just +1.8 points. Our conditioning signal was homeopathic.
  • Diagnosis: the six plan-personalities were too similar (most states had ONE correct action regardless of plan), and counterfactual rows were dominated by plan-invariant punish situations. Conditioning is only learnable where plans disagree.
  • Fix (bc_v2): personalities widened to extremes (rush 0.92 aggression vs turtle 0.06), counterfactual rows emitted ONLY at disagreement-states (83k of 153k rows), 2 epochs. Result: ΔP 0.159 (2.3× v1), direction 62.3% vs base's 44% (chance) — and the registered gate FAILED a second time.

Then we measured the yardstick — and found the gate was partly unpassable

After the second failure we computed what the registered metric awards the teacher itself (its per-plan policy is a one-hot, so its pairwise TV is just "do two plans disagree here?"):

on the same 400 eval states ΔP direction-OK
expert (= the ceiling) 0.374 0.620
gate threshold ≥ 0.30 ≥ 0.70
bc_v2 0.159 0.6225
base 0.137 0.438

38% of eval states are plan-invariant (every plan demands the same action). On those, the metric awards a perfect clone zero direction hits (1 > 1 is false) — so the direction gate could never be passed by anything that imitates this teacher. We had pre-registered thresholds against a yardstick whose ceiling we never measured. bc_v2 sits at 100% of the direction ceiling.

The registered verdict stays FAIL — that's what pre-registration means. But the post-hoc diagnostics (clearly labeled as such) tell the real story:

  • On disagreement states only: bc_v2 argmax flips on 23% of plan swaps (teacher: 60%, base: 11%); soft-ΔP 0.224 (base 0.139).
  • Per-plan play-style marginals track the teacher closely (rush_down: L .55/S .14/R .17 vs teacher's .50/.13/.17) — while the base model argmaxes FEINT on ~90% of states under every plan (8% expert agreement; this is what the in-game system-prompt engineering was compensating for).
  • The miss, precisely: on rush↔turtle flip states the model learned "turtle → retreat more" (R .12→.33; teacher .14→.64) but not "turtle → stop striking" (S .30→.26; teacher .30→.01). The strike-prior from plan-invariant punish rows overpowers the plan exactly where suppression should kick in. Conditioning is real, ~2-3× base on every measure — and roughly half the teacher's strength where it shows on screen.

Pre-registering thresholds and reporting both failures beats quietly moving the goalposts — and measuring the ceiling after failing (not before registering) is itself the lesson we're sharing: register gates against a measured ceiling, not a hopeful absolute.

bc_v3: weight the exact contrast you need

The diagnostics didn't just explain the failure — they located it so precisely that the fix was surgical. We found every counterfactual group where plans disagree and the action set includes S alongside a non-S (2,901 groups — the literal "this plan strikes here, that plan doesn't" contrast) and gave those rows 3× weight. Nothing else changed.

bc_v2 bc_v3 teacher
held-out agreement 69.5% 73.5%
ΔP (registered) 0.159 0.224 0.374
direction (registered) 0.623 0.672 0.620
argmax flip, disagreement states 0.230 0.317 0.60
rush↔turtle style separation (TV) 0.23 0.602 0.600

The number that matters most is the last one: on the states where the teacher flips between rush and turtle, bc_v3's play-style separation is identical to the teacher's — strikes go 0.33 → 0.00 under the turtle plan (teacher: 0.30 → 0.01), retreats 0.13 → 0.62 (teacher: 0.14 → 0.64). The model that "backed off but kept swinging" now actually sheathes the sword. And the direction metric now exceeds the one-hot teacher's own ceiling — a calibrated soft policy wins ties a deterministic one can't.

The registered gate? Failed a third time (ΔP 0.224 < 0.30). All three verdicts stand as registered. The arc in one line: a pre-registered gate we never calibrated failed three models, two of which were broken and one of which matches the teacher where it counts — measure your yardstick, then weight the exact contrast you need.

bc_v6: classifier-free guidance, the literature's gift

The research said it plainly (Sanchez et al.; Counterfactual Action Guidance; Decision Diffuser): if conditioning is weak, train with conditioning dropout (we blanked the plan in 20% of rows — it cost 0 accuracy) and amplify at inference: guided = uncond + γ·(cond − uncond), where the unconditional branch is the same prompt with the plan line stripped.

The γ sweep, on the same held-out yardstick as every other generation:

γ ΔP flip rate (disagreement states) strike-suppression
1.0 (raw) 0.112 0.179 0.30→0.07
2.0 0.187 0.260 0.29→0.03
4.0 0.292 0.385 0.28→0.03

At γ=4 the conditioning reaches 88% of the one-hot teacher ceiling (0.330) — the highest plan-obedience we measured in six generations, within a hair of the original pre-registered ΔP threshold that three models failed honestly. No quality degradation through γ=4. Serving cost: one extra parallel call. The judge-override demo runs on this: edit the plan, and γ amplifies exactly the part of the model's mind you just rewrote.

The design bug a playtest found (and the matrix that proved it)

Our sharpest tester (the author) reported the trained boss "feels dumb — I just spam attack and win." The per-matchup win matrix we then built showed something worse than a weak model: the spammer bot beat every strategy, 100%, including the teacher itself. Root cause: strike whiff-recovery was 18 frames, and the AI's fair 180ms eye-lag eats 11 of them — whiff-punishing mathematically did not exist in our game. Mashing was dominant by design, and no amount of model intelligence could fix physics.

One constant changed (recovery 18→26: a whiffed swing is now observable AND punishable through fair reflexes), the expert learned rhythm-reading from the same action-tape the model sees, and the matrix flipped: the masher went from beating everything to losing 95% against the counter-plan. The lesson we keep re-learning: instrument the game before blaming the model.

The AI that imagines futures

The endgame difficulty request was explicit: "make it foolproof — but with the model, not rules." The answer is policy + search, miniaturized:

  • One inference returns the model's full distribution over the 6 actions (single-token decisions make this free — same call, same latency).
  • Before committing, each plausible candidate is simulated ~36 ticks into the future inside the same deterministic engine the game runs on, against a lightweight model of the player built from their observed action history (striker / parrier / passive).
  • The action played maximizes the imagined outcome blended with the model's own prior — the SLM stays the brain; the engine is its imagination. Microseconds per decision, pure TypeScript.

It pays off where behavior cloning is weakest: the first probe showed the tuned model wanting to STRIKE into an incoming attack at 96% probability — the imagination simulates that future, watches it eat a counter, and parries instead. The playtest verdict flipped from "I always win" to "the AI wins."

Fighting it with your body

Pose mode (webcam → MoveNet on CPU/WASM in a worker → gesture state machine → the same input buffer the keyboard uses) turned out to be the difficulty feature, not just a gimmick: a human body is rate-limited in ways a keyboard isn't — you physically cannot mash at 5 presses/sec with your fists — so the AI's ~300ms decision loop becomes relatively fast. Things we learned the sweaty way:

  1. 2D pose can't see a camera-facing punch coming — wrist x/y barely moves when the fist comes at the lens. Speed gates must be tuned to ~2 shoulder- widths/sec with a TRAVEL gate (jitter is fast but goes nowhere).
  2. Faster sampling amplifies jitter into phantom punches — pipelined detection doubled frame rate and doubled the apparent speed of noise. dt floors and displacement windows, not smoothing stacks (double-smoothing halved real punch speeds and killed detection entirely).
  3. Disambiguation windows are perceived lag — waiting 170ms to decide punch-vs-feint made everything feel delayed; we cut the feint gesture.
  4. First-feedback latency IS the feel — the swing sound + a ring on your fighter fire at DETECTION (150ms, the physical floor), not at the engine's wind-up (350ms). Same pipeline, feels instant.
  5. A held guard must KEEP parrying — one-shot gesture injections die in input buffers when the fighter is mid-animation.

The fine-tune comes home (via the other runtime)

The MLC toolchain refused seven times to put our tuned weights in the browser. llama.cpp's converter did it on the first tryconvert_hf_to_gguf.py, quantize Q4_K_M, 940MB, done. The tuned model now runs in the browser through wllama (llama.cpp's WASM runtime) as the ANALYST: WASM CPU inference is too slow for the ~300ms Tactician hot path, but the slow loop — reading your behavior log and writing the plan that steers the Tactician — runs every few seconds with a relaxed budget. A perfect division of labor: WebGPU runs the reflexes, llama.cpp runs the published fine-tune, and both live entirely in your tab. (A timing probe auto-benches each machine and quietly leaves the base analyst in charge on hardware that can't afford it.)

The conversion saga (or: why fallback architecture matters)

Getting the tuned weights INTO the browser (WebLLM/MLC format) died on five successive upstream layers in one night: the CPU converter SIGABRTs (needs a device) → the cu123 wheels don't exist → the CUDA image lacked libX11 → the current cu124 nightly pair has a TVM FFI double-registration bug → the one older pair on the index isn't built for Linux. This week's nightlies are simply broken. The pre-designed Posture B absorbed it: the published fine-tune serves via Modal vLLM (LoRA adapter, same grammar, same prompts), playable in-game as the "Trained Duelist" (key 6), while the browser hero runs the base model + an engineered prompt + a grammar-level repetition guard. The submission never depended on upstream nightlies cooperating.

The whole journey, numerically

Everything above happened between June 9 (empty folder) and June 14 (submission). The honest census:

  • 6 expert teachers — each diagnosed by instrumentation, not vibes (superhuman cadence, superhuman vision, impossible punishes, the immunity collision, the unbeatable defense, the defenseless wake-up)
  • 6 model generations (pilot, v1–v4 + the CFG variant), 3 pre-registered gates failed and reported as failed, one yardstick measured after it failed two models, one engine constant that mattered more than any of them
  • 7 dead layers of the weights-to-browser conversion toolchain, across 4 platforms, before accepting the published-artifact posture
  • 4 visual identities (neon cyber → sumi-e gallery → retro pixel → letterboxed commandos) and 9 live playtest iterations of webcam combat to make a fist feel like a button
  • 1 design bug that made button-mashing mathematically dominant — found by a human playtest, proven by a win matrix, fixed by one constant
  • ~$80 of $250 Modal credits: every training run, every eval, every duplicate-trainer incident (orchestrators must be idempotent; we learned)

Future work we chose not to rush: distilling the imagination's choices back into the policy (the AlphaZero loop, miniature); winner-filtered self-play to surpass the scripted teacher; multi-token action chunking for sub-100ms server cadence.

Stack

Engine: deterministic integer-only TypeScript (60Hz), golden-trace parity CI. Brain: WebLLM + XGrammar in a Web Worker; tier auto-probe (1.5B/1B/server). Fallback: stateless relay → Modal vLLM (same grammar) for non-WebGPU browsers. Hosting: gradio.Server — custom canvas at /, Analyst through Gradio's queue. Training: Node datagen → Modal (TRL SFT) → published LoRA + merged + MLC weights.

Total cost: comfortably inside the $250 Modal credit grant — six training generations, eighteen eval reports, a vLLM gateway, and a GGUF conversion. Everything reproducible: commands in the model card.


🧭 All Parry artifacts

Play: the Space · Models: merged / LoRA / GGUF · llama.cpp · Data: agent traces / field notes

Downloads last month
36