Articles · 2026 · Reading: 10 min, plus 3 in closed details.
Article · research post · SimEdw's Blog

WorldTUI: I trained a 360M model to pretend to be a terminal

Simon Edwardsson (V7) · published 21 October 2026

In one line: Edwardsson fine-tuned Qwen2.5-Coder-0.5B (358M parameters once its vocabulary is cut) to predict a terminal's row edits per keypress, from 336k recorded sessions. On his own small tests, run once: 80 of 106 ShellBench commands exact (prompted base models 52, 60); self-repair plus more data took PresetBench from 24 to 38 of 47; parallel rows cut large-frame p95 latency from 6.7 s to 0.87 s.

24 to 38 of 47 PresetBench cases
self-repair training plus more data, int4
cases drawn from the author's demo failures · in the article: Learning from its own mistakes
6.7 s to 0.87 s p95 latency, large frames
rows decoded in parallel, RTX 4090
decoding mode not stated · in the article: Rows in parallel
64 to 0 of 64 memory readbacks
layer 7 removed; next-token accuracy 99.3% to 98.9%
true history fed in · in the article: Distilling

How far to trust it: Believe the engineering: clear, arithmetically sound, and matched by the demo's source. Read the accuracy as one author's small tests: memory is tested on the true history, so free-running drift is unmeasured, and self-repair's gain is mixed with extra data. The evidence, judged.

The idea in one sentence: fine-tune a small coding model to write, for each keypress, the edit to a terminal's screen; with no shell behind it, whatever stays consistent between commands is what the network carries in its context.

You need: world models and why their errors compound when fed their own output (Model-based RL and planning, sections 11 and 13); DAgger (Offline RL and imitation, section 3); draft-then-verify decoding (Speculative decoding).

New terms: screen delta (one keypress's output: row edits plus the cursor); COPY (copy a row of the previous screen); self-repair example (a training frame from the model's own wrong screen to the real next one); readback (reading back a file the session wrote).

Predict, then click: Enter on a full 32-row screen moves 31 rows up. How many tokens with COPY, and without? Then try cat server.log, the worst case.

A keypress costs one decode step per token of its screen edit; copying rows and decoding rows side by side cut that
written spancopied row (then patched)unchanged
The two screens, before and after
Fig. 1. The 32 rows of a 32 × 96 screen, columns to scale, for an illustrative session. Encoding: the post's rules and the demo's grammar, cheapest edit per row (the author's encoder is unpublished). Sequential: every token; row-parallel: the longest row plus 3 cursor numbers. Checked against src/recompute.py.

1. One keypress in, one screen edit out

How it sees a terminal Copying rows

A terminal is a grid, not a stream: clear sends the cursor to the top, so I need to predict changes to the screen. After a snapshot of the screen, each keypress goes in as a terminal's bytes, and the answer names rows to rewrite and the cursor: l at the prompt gives ROW_0 17 'l', CURSOR 0 18 1. Nothing gets cleared first, so a row's edit runs from its first changed cell to its last. Idle time goes in as a WAIT token.

Copying a row makes a scroll cheap. Rewriting every row costs around 3,000 tokens for a single keypress; with ROW_0 COPY 1, a scroll costs three tokens per row, and a copied row can be patched (Fig. 1, Enter at the bottom: 98 tokens against 901).

A tiny vocabulary, every output valid: Qwen's 256 byte tokens, 64 row tokens and a few operations make 333 tokens (the demo lists 334, with a draft marker), and decoding is grammar-constrained (Sampling and Decoding).

2. Training data: real programs in Docker, typed like a person

Generating the training data

The recordings he found lacked keystroke-to-screen alignment, so he made his own: vim, python, tmux, man and snake in offline Docker containers, random personas and screen sizes, one-key typing with 1.2% typos, and 35% of sessions starting partway through: 336k episodes, about 2B tokens.

A self-repair example: the model's own wrong screen, then the edit that takes it to the real next screen
Fig. 2. Illustrative screens built from the post's own example and rule. Red: cells where the model's screen differs from the recording; green: the correction.

3. Training it to repair its own mistakes

Learning from its own mistakes

Plain fine-tuning drifted: a mistake in a filename propagated, since at use time the model reads its own screens, never seen in training. That is behaviour cloning's compounding error; the fix is DAgger's (Offline RL and imitation, sections 2 and 3), the recording standing in for the expert:

  1. Pick a point in a recorded session, usually just before a command's output.
  2. Let the model play the next 1 to 4 events on its own screens.
  3. Compare with the recording; use the frame if the difference is small enough.
  4. Write the correction: the target for the next keypress is the edit from the model's wrong screen to the real next one.
  5. Train on it, then on a few real events after it.
  6. Skip what cannot be known: words a correction introduces must have appeared on an earlier real screen or in the typing; otherwise training would reward hallucinations.

About a third of sampled sessions gave a correction, over three rounds. With some additional training data, it took PresetBench from 24 to 38 of 47. All training took about 75 GPU-hours on an RTX 4090.

4. Three small tests, all the author's own

Testing

Three small tests. ShellBench is 106 commands in 24 handwritten sessions; PresetBench 47 cases drawn from failures he hit in the demo; the memory test 32 worlds, each writing two random values to two files and reading both back in separate sessions. Neither test appears in the training data.

Fine-tuning gained most on memory (the table), though the prompted baselines predict whole command outputs, as he notes. Combined in new ways, commands break: after an append, cat often doesn't show the appended line. Memory tests are short-gap, zero or one command between write and read (ShellBench spans 18).

Small suites, one run each, none released; the memory test is Fig. 3
Test (size)ModelScore
ShellBench (106 commands, exact output)Qwen2.5-Coder-0.5B, prompted52
Qwen3-0.6B, prompted60
WorldTUI80
File readbacks (13, not defined)Qwen2.5-Coder-0.5B, prompted2
Qwen3-0.6B, prompted3
WorldTUI9
PresetBench (47 demo failures, int4)before self-repair24
after self-repair plus more data38
row-parallel unverified, earlier checkpoint26, 31
From the post's "Testing" and "Learning from its own mistakes"; the last row is a comment in the demo's rowparallel.js (PresetBench v1.1: cursor drafted with the rows 26, decoded after them 31).

5. Making it fast: rows drafted side by side, then checked in order

Rows in parallel Rows that can't talk to each other

One token at a time suits typing (about 38 ms a key), not a redraw: up to 12 s on an RTX 4090, about 4 ms a token (derived, 12 s over about 3,000).

Rows rarely depend on each other, so each changed row gets its own batch element with the same previous history and KV cache: a frame takes as many steps as its longest row, then the cursor (training needed a matching attention mask). Large-frame p95 latency fell 7.7 times. Fig. 1's step ratios are an upper bound: a parallel step costs about 6 single steps on Apple GPUs (a comment in the demo's source).

Rows that cannot see each other disagree, so the same model verifies the draft. Independent rows put vim on row 3 instead of row 0, so a sequential pass keeps tokens up to the first disagreement and redrafts the rest. Decoding is greedy, so a fully verified frame equals sequential output (Speculative decoding). In the browser on an M4, man test takes 2.5 s sequentially, 0.9 s drafted and verified.

The demo's decoding settings, and which mode the 0.87 s used

The demo offers sequential, row-parallel plus verification (default) and row-parallel unverified decoding, and a per-frame verification budget: none (exact, the default) or 200 to 800 ms, past which the rest of the draft is committed unchecked. A source comment puts the unverified mode at 26 or 31 of 47 on PresetBench v1.1, on an intermediate checkpoint; the final model's sequential 38 is another checkpoint, so the gap is suggestive, not measured. The post gives the 0.87 s before introducing verification and does not say which mode produced it; its footnote adds that the speed-up is much larger on the 4090 than on the M4.

6. Making it small, and what distilling showed about memory

Making it smaller Distilling

The title's 360M is the base model without its vocabulary: 136M of Qwen2.5-Coder-0.5B's 494M are the 151,936-token embedding; keeping 384 rows leaves 358.3M (derived), the model card's "0.36B non-embedding". At 4 bits it is 208 MB, run by a hand-written WebGPU decoder with 32-bit activations and cache.

Removing one layer kept next-token accuracy and erased memory (Fig. 3). On an earlier checkpoint, removing layer 7 without retraining moved next-token accuracy from 99.3% to 98.9% and exact readbacks from 64/64 to 0/64; the tests fed in the true history, so retrieval lived in a few layers. A 12-layer student without layers 1, 7, 15 and 22 picked the wrong written value about half the time; a 16-layer student keeping them remembered but lost ShellBench commands, and he gave up on distilling. The lesson, a student can look fine and have quietly lost its memory, belongs beside depth pruning (Distillation and Small Language Models).

Next-token accuracy barely moved; exact memory readbacks went from all to none
Fig. 3. Exact readbacks of 64 (32 worlds, true history fed in) and the other number the post gives per model, one run each: teacher 64, next-token 99.3%, ShellBench 78; without layer 7, 0 and 98.9%; 12-layer student 31 after 480M tokens; 16-layer student 64, ShellBench 65. The 12 layers are derived (even layers 0 to 20, plus 23).

7. What it can do, and what breaks

What it can do What doesn't work

The videos show the best case: a file edited in vim in one tmux window comes back from cat in another. Python is forgiving the way a pattern-matcher is: pythoon launches Python, but ython does not. What breaks is state: in nested directories it gets lost, harder Python is guesswork, and the demo ran about 20× slower in Firefox. His summary: "Is it useful? Not really." Yet it keeps a somewhat consistent world without implementing any of the rules underneath.

Related work and next steps, as the post gives them

It sits beside the 2022 prompt that made ChatGPT act as a Linux terminal, GameNGen's diffusion model of DOOM and NeuralOS's desktop GUI, and is closest to the first, trained on keypresses and screen updates. Next: diffusion instead of autoregressive decoding, and training on thousands of generated applications to see whether it can predict one it has never met.

How much of this to believe

The engineering holds up, and much of it is checkable outside the post: the demo's public source and manifest show the grammar, the greedy verifier, 334 tokens and 208,351,744 bytes of weights; Qwen's config gives the 136M embedding; archived copies match the live text. He names his own weak points, and the layer finding is a clean ablation (true history, one change).

The accuracy evidence is thin:

  • Every test is his own, small, unreleased and run once; PresetBench is made of the demo failures his fixes target, so gains on it overstate general improvement.
  • Self-repair is not isolated: 24 to 38 comes with extra data, on PresetBench only, with no with-and-without run.
  • Compounding error is described, not measured: no accuracy against session length; memory tested on the true history shows retrieval, not whether a free-running session stays consistent.
  • Much of the shell is the base model's knowledge: prompted and untuned it gets 52 of 106, fine-tuning adds 28. Misspelt commands that run and appends that vanish point to pattern completion more than tracked state.
  • Loose ends: the 13 file readbacks are never defined; the 0.87 s does not say whether verification was on.

Verdict: believe the design and its costs, visible in the demo's source. Treat the accuracy as one author's small tests: fine-tuning clearly helps memory and familiar commands, self-repair probably helps, long-session drift is unmeasured. The most transferable finding is the layer ablation: next-token accuracy hid a total loss of memory, on one model.

What the responses said

Hacker News (read 27 November): 654 points, 195 comments, mostly on honeypots and "neural operating systems". No replication or rebuttal was found; nothing can be rerun until the weights appear.

Where it moves the knowledge base

  • Model-based RL and planning: a world model need not be video; a character grid gives one small enough for a browser, with a DAgger-style fix for drift.
  • Offline RL and imitation: DAgger without an expert to query: the label comes from the recording, only when the learner could have known it.
  • Speculative decoding: a same-model draft from independent segments (rows), exact under greedy unless a time budget commits unverified tokens.
  • Distillation and Small Language Models: depth pruning can delete one capability while next-token accuracy looks fine; test the capability.
Since the article (checked 27 November 2026): weights, code and follow-ups
  • Weights: not yet posted (27 November 2026): The post's "I'll post the weights soon" stands: nothing on Hugging Face under the author or the name, and no WorldTUI repository on GitHub. The Wayback Machine's copies (22 to 27 October) have the same text as the live post.
  • Harness Corp: a game about making a 0.6B model useful (27 October 2026): The author's next post, six days later; not about WorldTUI.
Provenance: what was read, fetched and compared

The post was fetched on 27 November 2026 and its main text, with footnotes, extracted to src/inputs/article.txt (2,991 words, 13 minutes at 230 words a minute; the 26 October tech-news issue quoted 8). Three distinct Wayback Machine copies (22 October 02:21 and 09:44 UTC, 27 October 20:18) differ from each other and from the live page only in the header's "Discuss on HN" link and the footer's link to the next post. Every "in the article" link is a text fragment or heading id checked against the extract at build time.

Read on 27 November: the demo page and its JavaScript modules (app.js, codec.js, session.js, rowparallel.js; read, never run) and its 54 KB manifest.json (model shape, codec, quantisation, byte count); the weights were not downloaded. Qwen2.5-Coder-0.5B's config.json and model card; the Hacker News item and all its comments through the API (submitted 22 October 02:18 UTC); Leon Becker's vibeSH post; the Anthropic post the thread linked; Hugging Face and GitHub searches for released weights or code (none).

Figures: the post's videos and latency chart carry no open licence and are not reproduced; Fig. 1 is computed from the post's encoding rules on an illustrative session, Fig. 2 is drawn from its description of self-repair, and Fig. 3 from the numbers it prints.