What Carries Over from CIFAR to Language-Model Pretraining从 CIFAR 到语言模型预训练,什么能迁移过去
Setup设置
Language-pretrained transformers help on images, but what carries over is mostly attention structure and well-conditioned weights, not language (Lu et al. 2021). We ask the reverse: whether training a small transformer on CIFAR first helps it learn language, and which property of the image task decides it. One 6-layer, 256-wide decoder (4.7M parameters without embeddings) first trains on a source task for 40M tokens, keeps its layers, gets a new embedding and output layer, and then trains on FineWeb text for 100M tokens. The source is either plain CIFAR-100 classification or the same images arranged so that each label must be copied from an earlier image in the sequence. We compare validation loss on text and the point at which the model starts copying repeated token sequences.
在语言上预训练的 transformer 对图像任务有帮助,但迁移过去的主要是注意力结构和条件良好的权重,而不是语言本身(Lu 等 2021)。我们问反方向:先在 CIFAR 上训练一个小 transformer,能不能帮它学语言?图像任务的哪种性质决定了这一点?一个 6 层、宽 256 的解码器(不含 embedding 共 4.7M 参数)先在源任务上训练 40M token,保留各层,换上新的 embedding 和输出层,再在 FineWeb 文本上训练 100M token。源任务要么是普通的 CIFAR-100 分类,要么是同一批图像排成序列,每个标签只能从前面出现过的同一张图那里抄。我们比较文本上的验证损失,以及模型开始复制重复 token 序列的时间点。
Details详细说明
The body is a pre-norm decoder with rotary position embeddings, causal attention in every task, 4 heads and a 1,024-wide MLP. Images enter as 16 patches of 8×8 pixels; a sequence holds 9 images, each followed by its label token, and the label is predicted from the image's last patch. In the copy task each sequence shows 3 images at least twice each, and the 3 labels are drawn afresh for every sequence, so a label can only come from context. Every stage uses AdamW at learning rate 2×10⁻³, batch 128, a 5% warmup and cosine decay to 10%. The copy probe is 256 sequences of 64 random tokens shown twice; the circuit counts as present once the loss on the second copy falls below half the loss on the first.
模型主体是 pre-norm 解码器,用旋转位置编码,所有任务都用因果注意力,4 个头,MLP 宽 1,024。图像切成 16 个 8×8 像素的块输入;一个序列有 9 张图,每张图后面跟它的标签 token,标签由这张图最后一个块预测。在抄标签任务里,每个序列有 3 张图,每张至少出现两次,3 个标签对每个序列重新随机分配,所以标签只能从上下文得到。每个阶段都用 AdamW,学习率 2×10⁻³,batch 128,前 5% 预热,余弦衰减到 10%。复制探针是 256 条序列,每条是 64 个随机 token 重复两遍;第二遍的损失降到第一遍的一半以下,就算复制回路已经出现。
Experiments实验
Testing检验中Does CIFAR help a language model when its labels must be copied from context?当 CIFAR 的标签必须从上下文里抄时,它能帮语言模型吗?
In the first full run (3 seeds, 100M text tokens), the copy circuit did not form in any seed during the CIFAR stage: accuracy on the query label ended at 34%, 43% and 6%, where 33% is a guess among the three labels in context. So this run cannot answer the question yet. It does show that every first stage left the language model worse than text only at the same number of text tokens: nested brackets by 0.05 nats at 100M tokens, plain CIFAR by 0.10 and the copy episodes by 0.38 on average (0.23 for the two seeds that reached the guessing level, 0.67 for the seed that stayed below it). The same compute spent on 40M more text tokens lowered the loss by 0.10. No run, text only included, reached the copy-probe threshold within 100M tokens.
第一次完整运行(3 个 seed,100M 文本 token)里,CIFAR 阶段的抄写回路在所有 seed 上都没有形成:查询标签的准确率最后是 34%、43% 和 6%,而在上下文的 3 个标签里随机猜是 33%。所以这次运行还回答不了这个问题。它说明的是:在相同的文本 token 数下,每种前置训练都让语言模型比只训文本更差。到 100M token 时,嵌套括号差 0.05 nats,普通 CIFAR 分类差 0.10,抄标签序列平均差 0.38(达到随机猜水平的 2 个 seed 差 0.23,低于这个水平的那个 seed 差 0.67)。把同样的算力用来多训 40M 文本 token,损失降低 0.10。100M token 内,没有一个运行(包括只训文本)达到复制探针的阈值。
Before this run, on another GPU, the circuit formed for one seed (13% at step 800, 94% at step 1,600) and not for two others even after 120M source tokens (48% and 32%). With crops and flips, or with different images of one class, it stayed near 30%: the model learns to name a label it has seen, but not which one. Image-label copy tasks in the literature that form the circuit reliably differ from ours: they score only the query label, give each image one token, use fewer label symbols, and train with a lower learning rate, a longer warmup and no weight decay (Chan et al. 2022; Reddy 2024). The next run changes the copy task in these ways and requires the circuit in all three seeds before the language stage.
这次运行之前,在另一块 GPU 上,回路在 1 个 seed 上形成了(第 800 步 13%,第 1,600 步 94%),另外 2 个 seed 即使训了 120M 源任务 token 也没有形成(48% 和 32%)。加上裁剪和翻转,或者换成同一类的不同图片,准确率一直在 30% 左右:模型学会了说出一个见过的标签,但分不清是哪一个。文献里能稳定形成回路的图像-标签抄写任务,和我们的设置有几处不同:只对查询标签计算损失,每张图只占 1 个 token,标签符号更少,学习率更低,预热更长,没有 weight decay(Chan 等 2022;Reddy 2024)。下一次运行按这些方面修改抄标签任务,并要求 3 个 seed 都在语言阶段之前形成回路。
Testing检验中Which first stage helps which target?哪种前置训练帮得上哪个目标?
Testing检验中Does a heavy-tailed image task rank optimizers as language pretraining does?类别长尾的图像任务,给优化器排的名次和语言预训练一样吗?
Takeaways核心结论
Acknowledgements致谢
The author is pleased to acknowledge that the work reported on in this post was substantially performed using the Princeton Research Computing resources at Princeton University. Princeton Research Computing is a consortium of groups including the Princeton Institute for Computational Science and Engineering (PICSciE) and Research Computing at Princeton University.
本文报告的工作主要使用普林斯顿大学 Princeton Research Computing 的计算资源完成。Princeton Research Computing 是由普林斯顿计算科学与工程研究所(PICSciE)和普林斯顿大学 Research Computing 等团队组成的联合体。
Experiment record实验记录
Citation
@misc{chai2026mix,
title = {What Carries Over from CIFAR to Language-Model Pretraining},
author = {Chai, Wenhao},
year = {2026},
howpublished = {Blog post},
url = {https://wenhaochai.com/exps/mix.html}
}