终端在做梦 · 3.6亿参数神经网络伪装的幻影终端
终端在做梦THE PHANTOM TERMINAL
没有 Shell,没有文件系统:3.6 亿参数神经网络直接预测屏幕差分No Shell, No Filesystem: A 360M Neural Network Predicts Screen Diffs Per Keystroke
2026 年 10 月 21 日,Hacker News 首页热门讨论(作者 simedw,斩获约 621 点赞、186 条深度讨论)引爆了极客社区:《WorldTUI: I trained a 360M model to pretend to be a terminal》。屏幕背后没有 bash、没有 zsh、没有任何 Linux 内核与物理磁盘——用户的每一个原始按键字节直接喂给一个小模型,模型直接预测终端屏幕字符网格的局部差分与光标位置。On 21 October 2026, a front-page Hacker News post by simedw (~621 points, ~186 comments) captured the imagination of systems hackers worldwide: "WorldTUI: I trained a 360M model to pretend to be a terminal." There is no bash, no zsh, no operating system, and no filesystem. Every raw keystroke enters a small neural network, which directly predicts screen character-grid diffs and cursor movements.
这是谷歌 Genie 3(应用由模型生成而非代码编写)理念在现实中最轻巧的落地雏形。本页面并非对该演示的机械复制,而是我们针对其核心技术机理的原创深度剖析与交互演练场。从 333 个极端微词表、屏幕差分 COPY 压缩,到 DAgger 自我修复与第 7 层被剔除后“记忆悄然暴毙”的残酷蒸馏事故,带你完整透视这个 208MB 的“终端世界模型”。This is Google's Genie 3 vision (applications learned rather than written) condensed into the smallest viable universe. This page is our original interactive exploration of WorldTUI's inner mechanisms: the 333-token vocabulary, the COPY scroll trick, DAgger self-repair, and the chilling distillation finding where dropping Layer 7 silently vaporized all memory while keeping next-token accuracy intact.
幻影终端演练场 · THE PHANTOM TERMINALTHE PHANTOM TERMINAL · Playable Toy
屏幕即状态 · 屏幕差分与 COPY 技巧THE SCREEN IS THE STATE · Screen Diffs & The COPY Trick
终端本质上是一个二维字符矩阵(如 80 列 × 24 行),而非像 ChatGPT 对话框那样的单向文本流。普通语言模型只能向末尾追加 token,根本无法原生表达光标跳跃回顶部、vim 插入新行或终端清屏。WorldTUI 的核心突破在于:将终端屏幕视为显存快照,每次按键只预测修改了哪些行(Screen Diffs)与最终光标位置。A terminal is fundamentally a 2D character matrix (e.g. 80 columns by 24 rows), not a unidirectional stream of text. Conventional LLMs append tokens to the end, making it impossible to express cursor jumps to the top left, vim row insertions, or screen clears. WorldTUI's key insight: the terminal screen is a frame buffer; each keystroke predicts which rows changed (Screen Diffs) and where the cursor ended up.
全屏滚动画布开销算力对比 · THE COPY TRICKScroll Cost: Full Redraw vs COPY Trick
普通全屏重绘每按一次回车需约 3,000 tokens;COPY 技巧使每行缩减至 3 个 tokens。Redrawing 24 rows costs ~3,000 tokens per Enter; COPY trick uses just 3 tokens per row.
整屏 80×Rows 字符全部重新生成,单次按键即耗尽大半注意力窗口与算力。Regenerates all characters per row; exhausting GPU attention and context budgets.
333 词表与极限瘦身阶梯333 TOKENS & THE SHRINKING LADDER
基座模型 Qwen2.5-Coder-0.5B 包含 4.94 亿参数,仅其庞大的 151,936 个自然语言词表嵌入层(Embedding Table)就占了 1.36 亿参数。对于纯字符网格终端而言,这几乎全都是浪费。WorldTUI 将词表极限精简至恰好 333 个 tokens,直接砍掉了 1.34 亿嵌入权重,再辅以 int4 量化,成功将模型塞进浏览器的 208 MB 内存中。The base Qwen2.5-Coder-0.5B model has ~494M parameters, of which the embedding table for its 151,936-token vocabulary occupies 136M parameters. WorldTUI pruned this to strictly 333 tokens, immediately ditching 134M weights. Combined with int4 quantization, the final browser package lands at just 208 MB.
覆盖全部标准单字节 ASCII 与 UTF-8 原始字节流。普通字母为自身(如 'a' 为 0x61),Enter 键为 0x0D (\r),Escape 为 0x1B,方向键为 ESC [ D 等标准 VT100 序列。
基准与诚实的惨痛教训BENCHMARKS, HONESTLY · ShellBench & The Layer 7 Collapse
在作者自行设计的非训练集测试基准中,WorldTUI 展现出了惊人的拟真度。但模型绝非万能:它依然远不是一个可靠的文件系统,一旦进行陌生的多步复合操作就会迅速崩溃。更震撼的是在模型蒸馏(Distillation)实验中发生的“第 7 层隐性死亡”惨剧。In the author's handwritten evaluations (held out from training data), WorldTUI showed impressive exact outputs. Yet it remains far from a reliable shell. The starkest finding came from distillation experiments: removing Layer 7 silently destroyed memory readbacks while next-token accuracy appeared virtually untouched.
在不重训的情况下直接砍去第 7 层。下一个 Token 预测准确率从 99.3% 仅微降至 98.9%,指标看起来几乎完好如初。Removing Layer 7 without retraining barely dented next-token accuracy: 99.3% to 98.9%. Surface metrics looked healthy.
构建 16 层学生模型并强制保留第 1、7、15、22 层。此时模型成功恢复了 64/64 记忆回读。A 16-layer student retaining layers 1, 7, 15, and 22 recovered 64/64 exact memory readbacks.
在多次权衡容量与记忆深度后,作者最终决定放弃蒸馏,转而使用 int4 量化保留完整的 24 层结构。The author abandoned distillation, opting instead for int4 quantization on the full 24-layer model.
为什么这至关重要 · WHY IT MATTERSWHY IT MATTERS · The Smallest Viable World
🎮Genie 3 哲学在微型世界的投射Genie 3's Dream in the Smallest World
谷歌的 Genie 3 揭示了一种全新的软件范式:应用程序不再由工程师逐行编写业务逻辑,而是由多模态神经网络根据玩家输入预测下一帧画面。WorldTUI 则将这一庞大愿景压缩到了极简的“字符网格世界”中:终端不需要内核与文件驱动,一切行为皆因因果演化而涌现。Google's Genie 3 demonstrated software where game engines are replaced by neural predictions of the next video frame. WorldTUI scales this down to the minimal character grid: no kernel, no disk driver — behavior emerges purely from learned screen dynamics.
📦Docker 赋予的完美无尽标注Docker's Infinite Free Supervision
为什么终端是世界模型的最佳起点?因为真实程序在 Docker 容器内的运行可以产生近乎无限、毫无噪声且百分之百准确因果的屏幕录像。33.6 万条会话、随机化提示符、注入的打字手误,加上预训练代码大模型本身就具备的 bash 知识,使其在仅 75 GPU 小时内便完成了拟真。Why is the terminal the ideal first world? Because running real code in Docker provides limitless, noiseless, perfectly causal ground-truth recordings. 336k episodes, randomized personas, and simulated typos combined with pretrained coding weights yielded an interactive world in just 75 RTX 4090 hours.
⚡差分预测:把终端当显存而非打字机Predicting Diffs: Framebuffer Over Typewriter
绝大多数试图让 LLM 充当终端的项目都失败在“文本追加”的思维陷阱里。终端从不是打字机,而是二维显存。通过屏幕快照对齐、行标记(ROW_n)、COPY 指令与语法受限解码,WorldTUI 彻底解决了光标跳转、清屏与滚动计算开销爆炸的技术死穴。Previous attempts to make LLMs mimic terminals stumbled into the typewriter trap. A terminal is a 2D framebuffer. Using screen snapshots, ROW tokens, the COPY operator, and grammar-constrained decoding solves cursor leaps, clears, and scroll latency in one stroke.
🧩投机并行验证:突破自回归延迟高墙Parallel Rows & Speculative Verification
终端的大多数行相互独立。WorldTUI 在 batch 内并行生成各行预测,再由串行验证器对齐冲突,使大画面重绘延迟暴降近 90%。在配备 M4 芯片的 Mac 浏览器中,单键击键延迟仅为 60 毫秒,实现了真正可玩的本地交互体验。Most terminal rows are independent. WorldTUI drafts rows in parallel within a single batch, checked by a sequential verifier. Large-frame p95 latency fell from 6.7s to 0.87s on an RTX 4090, achieving ~60ms keystroke response on an M4 Mac WebGPU tab.
现实审视 · REALITY CHECKREALITY CHECK · Honest Boundaries
• 本页面的终端是玩具,不是模型:它无法产生真实 WorldTUI 那种源自数十亿 token 权重的未定义涌现乐趣;其“漂移现象”是手写的教学脚本,旨在帮助读者形象理解世界模型的局限。• The terminal on this page is a toy, not a model: It cannot surprise you with organic emergent hallucinations; its drifts are scripted to educate readers on world-model limitations.
• WorldTUI 本身绝不可信任:它不是一个可靠的文件系统。多次追加写入极易丢失,非常规命令组合容易失控,严禁用于任何严肃生产场景。• WorldTUI itself is not a dependable shell: It drops appended lines, stumbles on novel pipelines, and must never be trusted with real files.
• 基准数据为作者自测:所有 ShellBench 与记忆回读测试均为原作者 simedw 独立评估发布,非第三方独立机构背书。• Benchmarks are author-reported: All scores (ShellBench, memory readbacks) originate from simedw's self-published evaluation.


