I built an LLM where Gemini 4 wrote the initial weights as code

An LLM writes the program that fills 97% of a language model’s stored weights with corpus statistics, with no gradient step. Gradient descent trains only a 103M-parameter network on top, and the model supports continual knowledge updates without training.

一个大语言模型(LLM)编写了一个程序,该程序利用语料库统计数据填充了语言模型 97% 的存储权重,且无需任何梯度步骤。梯度下降仅用于训练顶层的一个 1.03 亿参数网络,该模型支持在无需训练的情况下进行持续的知识更新。

Weight-space programming (WSP) is the idea that a frontier LLM can read and write the weights of a neural network directly, without gradient descent. So far, however, WSP has been limited to small networks or to sparse edits of existing models, and it has not been used to build a language model from scratch. We instead have an LLM write a compiler that builds the model’s initial weights. The compiler turns 31.8B tokens of corpus statistics into a 7.96 GiB bank of sparse tables, over 97% of the model’s stored bytes, without a single gradient step. Gradient descent then trains a 103M-parameter network on top of the frozen tables. After pretraining, an external edit layer adds new facts without any training, enabling continual knowledge updates. Trained on 10B tokens on a single GPU, the table model reaches a word-level perplexity of 46.4 on held-out FineWeb-Edu documents, 11% lower than a parameter-matched model without tables (52.1), comparable under standard parameter scaling laws to making the network about 1.5 times larger, and raises mean zero-shot accuracy on ten tasks by 1.2 points. Over 10,000 sequential WikiBigEdit edits, the edit layer answers 99.9% of the edited questions and 97.4% of their paraphrases, leaves 98.2% of unrelated answers unchanged, and changes perplexity by only 0.003%, at 12 ms per fact with no gradient step. Fine-tuning and LoRA, by comparison, recall at most 36.3% of the edits and push perplexity above 1,000. Code and results are available at github.com/Kim-Ai-gpu/wtable-lm.

权重空间编程(WSP)的核心理念是:前沿大语言模型可以直接读取和写入神经网络的权重,而无需梯度下降。然而,到目前为止,WSP 仅限于小型网络或对现有模型进行稀疏编辑,尚未被用于从零开始构建语言模型。我们转而让一个大语言模型编写了一个编译器来构建模型的初始权重。该编译器将 318 亿个 token 的语料库统计数据转化为一个 7.96 GiB 的稀疏表库,占模型存储字节的 97% 以上,且无需任何梯度步骤。随后,梯度下降在冻结的表之上训练一个 1.03 亿参数的网络。预训练完成后,一个外部编辑层可以在无需训练的情况下添加新事实,从而实现持续的知识更新。该表模型在单块 GPU 上使用 100 亿个 token 进行训练,在留出的 FineWeb-Edu 文档上达到了 46.4 的词级困惑度,比不带表的同参数模型(52.1)低 11%,根据标准参数缩放定律,这相当于将网络规模扩大了约 1.5 倍,并将十项任务的平均零样本准确率提高了 1.2 个百分点。在 10,000 次连续的 WikiBigEdit 编辑中,编辑层回答了 99.9% 的已编辑问题及其 97.4% 的释义,保持了 98.2% 的无关答案不变,困惑度仅变化 0.003%,且每个事实的处理时间仅为 12 毫秒,无需梯度步骤。相比之下,微调和 LoRA 最多只能回忆起 36.3% 的编辑内容,并将困惑度推高至 1,000 以上。代码和结果可在 github.com/Kim-Ai-gpu/wtable-lm 获取。

Hover over any bar or point for exact values.

将鼠标悬停在任何条形或点上以查看精确数值。

Both models have the same backbone, about 103M trained parameters, and the same 10B training tokens. The only difference is the frozen tables.

两个模型具有相同的主干,约 1.03 亿个训练参数,以及相同的 100 亿个训练 token。唯一的区别在于冻结的表。

Word-level perplexity on 2,000 held-out FineWeb-Edu test documents, context 1,024. The 1.5× estimate uses the parameter scaling law of Kaplan et al. (2020), loss ∝ N−0.076.

在 2,000 份留出的 FineWeb-Edu 测试文档上的词级困惑度,上下文长度为 1,024。1.5 倍的估算使用了 Kaplan 等人(2020)的参数缩放定律,即损失 ∝ N−0.076。

Keep only the most frequent fraction F of table entries in the trained model, without retraining. Perplexity improves with every doubling and shows no sign of saturating.

在训练模型中仅保留最频繁的 F 部分表条目,无需重新训练。困惑度随着每次翻倍而改善,且没有饱和的迹象。

Accuracy of the table model minus the baseline on ten tasks. The largest gains come on tasks that reward common associations between words and events.

表模型在十项任务上的准确率减去基准准确率。最大的增益出现在奖励词汇与事件之间常见关联的任务中。

lm-eval 0.4.13, zero-shot, length-normalized accuracy where available. Results on all 21 evaluated tasks are in the paper’s appendix.

lm-eval 0.4.13,零样本,在可用情况下进行长度归一化准确率计算。所有 21 项评估任务的结果均在论文附录中。

WikiBigEdit facts are applied one batch after another and never undone. The edit layer stores each fact as a record and trains nothing. Weight editing keeps learning the new facts but forgets the old ones and damages the model.

WikiBigEdit 的事实被逐批应用且从不撤销。编辑层将每个事实存储为一条记录,且不进行任何训练。权重编辑虽然能不断学习新事实,但会遗忘旧事实并损害模型。

EM is SQuAD-normalized exact match (%). Loc keep is the share of unrelated questions whose answer did not change. Perplexity is word-level on 2,000 validation documents. Time is the editing cost per fact on one T4 GPU.

EM 是 SQuAD 归一化的精确匹配率(%)。Loc keep 是答案未改变的无关问题的比例。困惑度是在 2,000 份验证文档上的词级困惑度。时间是在单块 T4 GPU 上每个事实的编辑成本。

Writing facts into the tables fails, because the last few tokens before an answer are almost always the same question template. The edit layer keeps facts outside the tables instead.

将事实写入表中会失败,因为答案前的最后几个 token 几乎总是相同的问句模板。因此,编辑层将事实保留在表之外。

Subject tokens, a key (the hidden state where the answer should be given) and the answer tokens. One forward pass, about 12 ms, no gradient step.

主题 token、一个键(应给出答案的隐藏状态)以及答案 token。一次前向传播,约 12 毫秒,无梯度步骤。

The subject must appear verbatim in the last 64 tokens (stored with and without a leading space, never inside a longer word), and the raw hidden state must match the key, cos(ht, ki) ≥ 0.93. No statistics of the prompt template are needed.

主题必须逐字出现在最后 64 个 token 中(存储时包含和不包含前导空格,绝不在较长单词内部),且原始隐藏状态必须与键匹配,即 cos(ht, ki) ≥ 0.93。无需提示模板的统计信息。

The stored answer token is raised 1.5 above the current top logit, one token after another, until the answer ends.

存储的答案 token 在当前最高 logit 的基础上提高 1.5,逐个 token 进行,直到答案结束。

Records are plain data, so a person or an LLM can write, inspect or delete them. A new edit for the same subject and relation replaces the old one.

记录是纯数据,因此人类或大语言模型可以编写、检查或删除它们。针对相同主题和关系的新编辑会替换旧的编辑。

Every channel answers in the same form, a short list of next-token candidates with scores, so the network only learns how much to trust each one at each position.

每个通道以相同的形式回答,即带有分数的下一个 token 候选列表,因此网络只需学习在每个位置上对每个候选者的信任程度。

The first five groups are counted from 31.8B FineWeb-Edu tokens, disjoint from the network’s training data. The compiler was designed by Gemini 4 Neon.

前五组数据是从 318 亿个 FineWeb-Edu token 中统计得出的,这些数据与网络的训练数据不重叠。该编译器由 Gemini 4 Neon 设计。