· via Hacker News – Front Page (native)
Fine-tuned 360M model simulates a whole terminal with no shell behind it
A developer fine-tuned a 360M-parameter Qwen model to act as a full terminal with no shell behind it, predicting screen changes from each keypress. It runs as a 208 MB WebGPU browser demo.

A terminal with no shell underneath
A developer posting as simedw has fine-tuned a 360M-parameter language model to behave like a complete terminal, in a writeup that reached the front page of Hacker News. Nothing real executes underneath: every keypress is fed to the model as raw bytes, and the model predicts how the character grid on screen should change in response. According to the post, it can create files, run vim and tmux, play snake, and usually recall text typed a few commands earlier.
The project began as a scaled-down attempt at a "world model" in the style of Genie 3, where a model predicts what happens next from user input instead of an engine doing the rendering. A terminal suited the goal: it is a grid of characters rather than pixels, and recording real shells produces effectively unlimited, perfectly labelled training data.
How the model sees the screen
Ordinary LLMs append tokens to the end of a prompt, which maps badly onto terminals. A lone Escape key does something in vim, and the clear command redraws from the top rather than printing at the bottom. So the model predicts screen changes instead of text streams.
Every session opens with a snapshot describing the screen dimensions, contents and cursor, and sessions can start mid-application — from a bash prompt, a vim buffer or a running game. Each keypress then arrives as the bytes a real terminal would send, and the model replies with the rows to rewrite and the final cursor position, including a flag for whether the cursor is visible. Time is modelled too: a WAIT token carrying a duration keeps snake moving when nobody types.
Scrolling is where a naive approach blows up — shifting every line up could cost around 3,000 tokens for a single Enter press. A COPY operation instead pulls rows forward from the previous screen at three tokens per row, and the same mechanism covers cleared screens, vim line edits and man page navigation. The entire vocabulary is 333 tokens: the 256 byte tokens Qwen already has, reused for characters and small numbers, plus 64 row tokens and a few operations. Decoding is grammar-constrained, so every prediction is a valid screen update.
Synthetic data and self-repair training
The author found no existing corpus, asciinema recordings included, with exact keystroke-to-screen alignment, so training data was generated by running real commands inside Docker containers and recording each keypress and the resulting screen. Usernames, hostnames, prompt styles, terminal sizes and file layouts were randomized around fictional personas; each session picked 6–24 weighted activities; typing included tab completion and a 1.2% typo rate. Around 35% of sessions start partway through. The finished dataset holds 336k episodes, roughly 2B tokens — a sliver of the approximately 18T the base model saw during pretraining.
That base is Qwen2.5-Coder-0.5B, chosen for its small size, since getting close to real-time output matters, and for its prior exposure to command-line usage. Straightforward supervised fine-tuning learned typing quickly, but errors compounded over long sessions, with one wrong filename contaminating everything after it.
The remedy borrows from DAgger, training on states the model actually reaches rather than only ideal demonstrations. At sampled points in recorded sessions the model predicts the next few events, its screen is compared against the real one, and a correction is constructed that repairs the model's screen on the following keypress. Crucially, a correction may only contain information that appeared on earlier real screens or in the user's own typing — training on corrections the model could not infer would reward hallucination. About a third of sampled sessions produced usable corrections; across three rounds, alongside additional data, this lifted a benchmark the author calls PresetBench from 24/47 to 38/47 at int4, making self-correction one of the most effective training changes.
Running it yourself
The demo is a 208 MB download intended for a desktop browser with WebGPU and a physical keyboard, with Chrome or Edge recommended; it works on a modern phone but slowly. The author's suggested sanity check is to type "pythoon" — the misspelled command makes it obvious that no real shell is present.
Why it matters
This is a compact, reproducible demonstration that a small model can maintain a consistent world rather than merely emit convincing terminal-shaped output. The ingredients — screen deltas as the prediction target, grammar-constrained decoding, a cheap COPY encoding for scrolling, and DAgger-style training on self-repair — transfer well beyond terminals, to any interface expressible as a state plus updates. It also connects to agent research: a model that simulates an environment faithfully could serve as a lightweight sandbox or a data generator. And at 360M parameters running in a browser tab, it suggests that learned, simulated software may not require frontier-scale compute.
- #machine-learning
- #language-models
- #fine-tuning
- #terminal
- #qwen