WorldTUI: I trained a 360M model to pretend to be a terminal
- ID: 8802a789
- 原文链接: https://simedw.com/2026/10/21/world-model-terminal
- 作者: Simon Edwardsson
- 日期: 2026-10-21
- 更新: N/A
- 分类: learning
- 来源类型: article
- 标签: world-model, fine-tuning, terminal, qwen, speculative-decoding
- 质量评分: 4/5
- 抓取时间: 2026-10-23T12:26:03Z
中文导读
一次完整的终端世界模型实战:把 Qwen2.5-Coder-0.5B 微调成假终端,背后没有 shell 与文件系统,模型按字符网格预测屏幕增量,词表只有 333 个 token(256 字节64 个行操作加少量特殊操作),解码用文法约束保证每步输出都是合法屏幕更新训练数据是精确标注的合成数据:在 Docker 里逐键录制真实会话并随机化用户主机提示符与尺寸(33.6 万局约 2B token)亮点包括:教模型自我修复错误用 COPY 操作把滚动成本从每行约 96 token 降到 3并行行草稿加自身 speculative 解码最终 208MB 在浏览器 WebGPU 里运行,每次按键约 38 毫秒,能开 vim 与 tmux玩贪吃蛇,并在几条命令后仍记得上下文
为什么值得关注
360M 模型假扮终端:字符网格预测屏幕增量,333 个 token 词表加文法约束解码,208MB 跑进浏览器 一个人 75 GPU 小时的完整工程实录:DAgger 式自我修复把 PresetBench 从 24/47 提到 38/47,行级并行加自身 speculative 解码把全屏重绘 p95 从 6.7 秒压到 0.87 秒,最终 int4 208MB 跑在浏览器 WebGPU 里;蒸馏消融还顺带证明精确记忆高度依赖个别层(删第 7 层,精确回读从 64/64 跌到 0/64)。对做小模型 agent、世界模型与浏览器端推理的人,这是一份可复用的手册。
关键信息
- 文章标题:WorldTUI: I trained a 360M model to pretend to be a terminal
- 在线演示:https://simedw.com/projects/worldtui(208 MB,本地 WebGPU 运行)
- 作者:Simon Edwardsson
- 原文:https://simedw.com/2026/10/21/world-model-terminal
- 发布时间:2026-10-21
- 关联标签:world-model, fine-tuning, terminal, qwen, speculative-decoding
English Source Excerpt
TL;DR: I fine-tuned a 360M-parameter language model to act as a terminal. There's no shell or filesystem behind it: every keypress goes in, and the model predicts how the screen changes. It can create files, run vim and tmux, play snake, and usually remembers what you wrote a few commands later. The biggest wins were teaching it to repair its own mistakes and decoding screen rows in parallel.
English Summary
The author fine-tuned Qwen2.5-Coder-0.5B (about 494M parameters) to emulate a terminal with no shell or filesystem behind it: the model predicts screen deltas on a character grid using a 333-token vocabulary (256 byte tokens, 64 row tokens, a few specials) with grammar-constrained decoding, so every prediction is a valid screen update. Training data is synthetic but exact: 336k episodes (roughly 2B tokens) recorded keypress-by-keypress from real programs inside Docker, with randomized personas, hosts, prompts and terminal sizes. A DAgger-style self-repair loop lifted PresetBench from 24/47 to 38/47 at int4; WorldTUI scores 80/106 on ShellBench versus 52 for the prompted base model and passes 9/13 file readbacks versus 2-3. Dropping the 151,936-entry embedding table cut the model to about 360M parameters, and int4 quantization brought it to 208 MB running fully in-browser via WebGPU (about 60 ms per keypress on an M4 Mac). Parallel per-row drafting cut large-frame p95 latency from 6.7 s to 0.87 s on an RTX 4090, with self-speculative decoding fixing cross-row coordination; distillation ablations showed exact memory depends on individual layers - removing layer 7 collapsed exact readbacks from 64/64 to 0/64, and a 16-layer student that kept layers 1, 7, 15 and 22 passed all memory worlds but lost ShellBench accuracy (65 vs 78).
Obsidian Notes
- 页面全文由
opencli web read(networkidle 重试后成功)抓取。 - 中文导读与价值判断锚定在条目已有摘要与文章正文上;未补充文章之外的细节。