WorldTUI: A Terminal Whose Behavior Is Learned, Not Programmed
Type ls into WorldTUI, and a directory listing appears. Open a file in vim, edit it, save it, and later cat may show the same text. You can even open tmux panes or play snake. The surprising part is what sits behind the screen: there is no shell, filesystem, editor, or game engine executing those commands. A small language model reads the keyboard input and predicts the next visible terminal state.
Simon Edwardsson built the experiment to test whether a model can maintain a coherent interactive world, rather than merely produce a plausible answer to one prompt. A terminal makes that question unusually concrete. Its display is a grid of characters, its actions are keystrokes, and real programs can produce unlimited examples of what the next screen should look like. The result is an approximately 360-million-parameter model that runs locally in a browser after a 208 MB download. It is a compelling simulation, though it is still easy to expose as one: pythoon can launch a simulated Python REPL, and file operations sometimes contradict earlier ones.
A screen transition is the unit of prediction
A conventional language model appends text to a prompt. A terminal behaves differently. Pressing Escape in vim changes mode without necessarily printing a line. clear replaces the whole display. Scrolling shifts rows that were already visible. WorldTUI therefore represents a session as a starting screen snapshot, followed by an input event and a compact set of screen edits.
The snapshot records dimensions, visible rows, and cursor position. A key is encoded as the bytes a real terminal would receive: ordinary letters, carriage return for Enter, and escape sequences for arrow keys. When no key is pressed, a timed WAIT input lets the simulation advance an application such as snake. The response can overwrite part of a row, copy a row from the previous screen, and set the cursor. Applying those edits yields the next screen; the next input then sees that result in its history.
This representation matters for speed. Redrawing a 32-by-96 terminal after a scroll could require roughly 3,000 generated tokens. A COPY instruction instead says, for example, that old row 1 becomes new row 0. Edwardsson reports that scrolling then costs about three tokens per row instead of roughly 96. Copying also helps with clearing, inserting lines in vim, and navigating manual pages. Grammar-constrained decoding ensures that the generated sequence is a valid screen update, although valid syntax does not guarantee correct behavior.
The output vocabulary contains only 333 tokens: 256 byte tokens, 64 row markers, and a small set of operations. Characters and small coordinates reuse byte tokens already present in the Qwen2.5-Coder-0.5B base model. That deliberately narrow language reduces both the amount the model must generate and the size of its embedding table.
Training on real programs, then on its own mistakes
For supervision, Edwardsson ran actual terminal programs inside Docker containers and recorded the keypress-to-screen transitions. His generator varied usernames, hostnames, prompts, terminal dimensions, directory trees, and fictional user personas. It assembled sessions with 6 to 24 activities, including shell commands, file changes, vim, Python, and tmux. Inputs were typed one key at a time, with tab completion and occasional mistakes. About 35% of episodes began in the middle of an application, so the model could not assume every session started at a shell prompt.
The final training set contained about 336,000 episodes, or roughly two billion tokens. Supervised fine-tuning quickly taught local effects such as a character appearing or a backspace moving the cursor. Long sessions posed a harder problem. A single wrong filename on a generated screen could become part of the model’s next input, sending every later prediction further from the real session.
The repair step is the most interesting part of the training recipe. Edwardsson let the model generate one to four events from a recorded point, compared its resulting screen with the real screen, and built a correction when the difference was small. Training then continued from the model’s imperfect screen toward the real next state. This resembles the motivation behind DAgger: a learner should practice on states its own decisions cause, not only on pristine expert demonstrations. Edwardsson added a guardrail: a correction could introduce a word only if that word had appeared in the real earlier screen or the user’s input. Otherwise the example might teach the model to invent unseen data.
About a third of sampled sessions yielded useful repairs. He repeated collection and training three times. Correction data and additional training data together moved his 47-case PresetBench result from 24 to 38 cases at four-bit precision; that comparison does not isolate the repair step alone. The full training and refinements took about 75 GPU-hours on an RTX 4090.
The model must draw quickly enough to feel interactive
Autoregressive generation initially made large updates painfully slow. Ordinary typing took about 38 milliseconds per key on Edwardsson’s RTX 4090, but a full-screen change could take up to 12 seconds. The breakthrough was to generate one draft per screen row in parallel. Each row sees the same history and cached attention state but predicts only its own update. The amount of sequential work falls from a possible 3,000 token steps for a frame to roughly the length of its longest row, around 100 steps.
Rows can disagree about shared structure: several might place snake food, or vim content might start in the wrong place. WorldTUI therefore verifies the parallel draft sequentially with the same model. At the first disagreement, the verifier generates a correction and offers the remaining draft again. The cursor is generated after the rows so it can see the completed update.
Edwardsson measured large-frame p95 latency on the RTX 4090 falling from 6.7 to 0.87 seconds. In his browser test on an M4 Mac, a larger update fell from 2.5 to 0.9 seconds, while a typed character took about 60 milliseconds. These are measurements of his implementation on his hardware, not general performance guarantees.
The browser model was made smaller in two stages. The original Qwen model has about 494 million parameters, including a large embedding table for a 151,936-token vocabulary. Retaining the tiny terminal vocabulary reduced the model to about 360 million parameters. Four-bit quantization brought the download to 208 MB. A custom JavaScript Qwen decoder runs WebGPU compute shaders that unpack the weights during inference; activations and the attention cache remain 32-bit floats. The browser demo runs inference locally and is best used with a physical keyboard in Chrome or Edge. Edwardsson reports much slower behavior in Firefox, without a confirmed cause.
Does it actually remember a world?
The project’s strongest and weakest evidence both concern state. In one demonstration, a file edited in vim could later be read with cat from a different tmux pane. That is more demanding than producing a believable one-off directory listing. Yet the author also reports that appending green to a file and then reading it often fails to show the new line. Nested directories can unexpectedly change paths. Python handles simple expressions but can return plausible, incorrect list contents. This is a learned approximation of terminal behavior, not a reliable filesystem.
Edwardsson used three evaluations. ShellBench scores exact outputs for 106 commands across 24 handwritten shell sessions. PresetBench holds 47 scripted cases based on failures found in the demo. A separate memory test creates 32 simulated worlds, writes two random values in each, and checks 64 later readbacks. The test names and values were absent from training. The short-gap memory checks have at most one intervening command; ShellBench also probes persistence over longer spans.
In a comparison using 13 file readbacks, WorldTUI answered 9 correctly and scored 80 of 106 ShellBench commands. Prompted Qwen2.5-Coder-0.5B scored 2 of 13 and 52 of 106; prompted Qwen3-0.6B scored 3 of 13 and 60 of 106. The prompted models generated whole command outputs rather than individual screen edits, so this is useful context but not a controlled like-for-like comparison.
An attempted distillation gave a sharper warning about evaluation. Removing one layer from an earlier checkpoint barely changed next-token accuracy, from 99.3% to 98.9%, while exact memory readbacks collapsed from 64 of 64 to zero. A smaller 16-layer student that preserved particular layers recovered all 64 readbacks, even after four-bit quantization, but fell from 78 to 65 correct ShellBench commands. The final model was not distilled. A model can look fluent and even retain one type of memory while losing other useful behavior.
What the experiment establishes
WorldTUI shows that a small model can learn many visible rules of an interactive interface from screen transitions: prompt editing, mode changes, scrolling, panes, game movement, and some file recall. Its compact edit language, correction examples, parallel drafting, and vocabulary trimming make that idea responsive enough to try in a browser. The result is especially striking because the model has no implementation of the applications it depicts.
It does not show that a learned terminal can replace a real one. The model has no authoritative state store, and familiar operations can fail when composed in unfamiliar ways. The open question is how far a learned simulator can preserve consistency over longer interactions and unseen applications. Edwardsson suggests training on many randomly generated apps to test whether the model can infer new controls and rules from context. WorldTUI gives that broader question a small, playable laboratory.