跳到主内容
精选88Hacker News Best(web_list)技巧与观点

5090训练小Transformer在ARC-AGI-1达44%得分的工程实践

67美分成本在ARC-AGI-1取得44%得分的工程实践

原文
推荐理由

ARC-AGI是检验AI推理能力的硬核标杆,这篇博客给出了低成本复现高分的完整工程细节与消融实验,对追求极致样本效率的研究者极具参考价值。

I trained a small transformer from scratch in 1.5hrs on a 5090

我在5090上花了1.5小时从零开始训练了一个小型Transformer

Beats many LLMs, and scores the same as TRM/HRM

击败了众多大语言模型,得分与TRM/HRM持平

This is an upgrade to my previous model

这是我之前模型的升级版

Faster, better, cheaper and still open source.

更快、更好、更便宜,且仍然开源。

Also gets 7% on ARC-2

在ARC-2上也取得了7%的分数

Discussion on Twitter, Code on github

Twitter上的讨论,GitHub上的代码

Performance on ARC-1 public eval. I only compare against models that do similar test time training

ARC-1公开评估的性能表现。我只与进行类似测试时训练(test time training)的模型进行比较

This is the 3rd blog in a series of works on ARC-AGI. Prev: Blog 2, Blog 1.

这是关于ARC-AGI系列工作的第3篇博客。前作:博客2,博客1。

Many ppl thought the prev result was impossible. It got attention from top researchers and went viral on X. Eg: Discussions by Lucas Beyer, Jeremy Howard, Rohan Anil, and comments by many others.

许多人认为之前的结果是不可能的。它引起了顶级研究人员的关注并在X平台上病毒式传播。例如:Lucas Beyer、Jeremy Howard、Rohan Anil等人的讨论,以及许多其他人的评论。

Why work on this?

为什么要做这项工作?

I think sample efficiency is the most important problem in AI today and I want to solve it.

我认为样本效率是当今AI领域最重要的问题,我想解决它。

The intention behind this work is to (1) find the limits of sample efficiency when restricted to transformers / today’s deep learning methods and (2) reduce costs so iteration is much faster and cheaper.

这项工作的目的是(1)在限制为Transformer/当前深度学习方法的条件下,找到样本效率的极限;(2)降低成本,使迭代速度更快、成本更低。

ARC is a great benchmark to test this:

ARC是一个测试这一点的绝佳基准:

  • Very few samples (only a 1000 puzzles) in a high dimensional space
  • Its a metalearning benchmark, so each puzzle uses a different rule, with some common concepts
  • Very few priors needed: every concept needed in the eval set is present in the train set
  • It is incredibly easy for humans to solve, and accessible to even poor AI researchers
  • Benchmark is still unsaturated (for data efficiency, ignore LLMs and approaches that use tons of synthetic data or human inductive biases)
  • 在高维空间中只有极少的样本(仅1000个谜题)
  • 它是一个元学习基准,因此每个谜题使用不同的规则,但包含一些共同的概念
  • 几乎不需要先验知识:评估集中需要的每个概念都存在于训练集中
  • 对人类来说极其容易解决,甚至对能力较差的AI研究人员也是可及的
  • 基准仍未饱和(针对数据效率而言,忽略LLMs和使用大量合成数据或人类归纳偏置的方法)

Next, I’ll work on new research ideas to break these limits. I’ll try to keep costs low so that anyone in the world can work on this.

接下来,我将致力于新的研究想法以突破这些极限。我会尽量保持低成本,以便世界上的任何人都能参与这项工作。

Tech details

技术细节

How does it work?

它是如何工作的?

The overall approach is similar to last time (full technical details here), but I added a bunch of upgrades. Here’s a quick summary of the approach:

整体方法与上次相似(完整技术细节见此处),但我添加了一系列升级。以下是该方法的快速总结:

  • Each input-output pair is converted to a sequence of tokens. These sequences are autoregressively trained on by a small transformer. This is done from scratch at test time on both the train set and eval set puzzles (test labels hidden).
  • To enable cross-task learning, each puzzle is given a separate additive embedding (learnt). Since each sequence has two 2D grids, positional are learnt using 3D RoPE embeddings.
  • The sequences are augmented with color and dihedral permutations. During inference, the test inputs are augmented, and the inverse aug is applied on the outputs produced. The 2 most common outputs are submitted (AAIVR).
  • 每个输入-输出对被转换为一个token序列。这些序列由一个小型Transformer进行自回归训练。这是在测试时在训练集和评估集谜题上从零开始进行的(测试标签被隐藏)。
  • 为了实现跨任务学习,每个谜题都被赋予一个独立的加法嵌入(经过学习)。由于每个序列包含两个2D网格,位置编码使用3D RoPE嵌入进行学习。
  • 序列通过颜色和二面角排列进行增强。在推理阶段,测试输入会被增强,并对生成的输出应用逆增强操作。提交出现频率最高的两个输出(AAIVR)。

Changes since last time

自上次以来的变更

The main goal was to find improvements to the architecture / algorithm that improve the sample efficiency of the model.

主要目标是寻找能够提升模型样本效率的架构/算法改进方案。

The biggest increases in scores were due to

分数的大幅提升主要归功于:

  • Modern architecture (SwiGlu instead of GELU, RMSnorm not layernorm, etc.)
  • More data diversity, better shuffling of data
  • scaling up: 8 layers instead of 4,
  • 现代架构(使用 SwiGlu 替代 GELU,使用 RMSnorm 而非 layernorm 等)
  • 更多样化的数据,更好的数据打乱方式
  • 规模扩大:8 层而非 4 层,

Biggest decreases in cost were due to:

成本的大幅降低主要归功于:

  • Way fewer augmentations (more sample efficient!)
  • AdamW -> Normuon
  • flash attention with varlen training + flex attention kernels for inference
  • 大幅减少增强操作(更具样本效率!)
  • AdamW -> Normuon
  • 用于训练的 flash attention(支持变长)+ 用于推理的 flex attention 内核

A major change is that I don’t train on input tokens anymore. This means the loss function only includes output tokens (which makes the approach supervised). This. performs slightly better 40% $\to$ 44% but I don’t understand why. Perhaps finite model capacity

一项重大变更是我不再对输入 token 进行训练。这意味着损失函数仅包含输出 token(使该方法变为监督学习)。这种方法表现略好,从 40% 提升至 44%,但我不明白原因。也许是模型容量有限所致。

I also increased the training data by adding the non-overlapping tasks from ARC-2. I did this very carefully to ensure no leakage. You can remove the extra data if you don’t like it and it will still score ~40%, but it will need ~double the compute.

我还通过添加 ARC-2 中不重叠的任务来增加训练数据。我非常谨慎地执行此操作以确保没有数据泄露。如果您不喜欢额外数据,可以将其移除,得分仍约为 40%,但计算量将需要增加约一倍。

Context: ARC-2 contains 773 ARC-1 puzzles and 347 new puzzles. Most eval puzzles of ARC-1 are repeated, so if you naively train on ARC-2, then its a dataleak and you will score 100%. I avoid this by carefully filtering out the 773 repeated puzzles (so no leak!)

背景:ARC-2 包含 773 个 ARC-1 谜题和 347 个新谜题。ARC-1 的大多数评估谜题都被重复使用了,因此如果天真地在 ARC-2 上训练,就会发生数据泄露,得分将达到 100%。我通过仔细过滤掉这 773 个重复谜题来避免这种情况(因此没有泄露!)

There are many other changes that gave incremental improvements in performance or speed. Find the full list of changes here.

还有许多其他变更带来了性能或速度的增量改进。在此处查看完整的变更列表。

Interesting behaviour

有趣的行为

Since I am no longer training on inputs, this approach is now supervised. What’s weird is that the test loss is now worse, yet it scores better! Also it is more stable and there’s less variance in scores.

由于我不再对输入进行训练,该方法现在是监督学习。奇怪的是,测试损失现在更差了,但得分却更高了!此外,它更加稳定,分数的方差也更小。

Many ppl today are working on sample efficiency by aiming for the lowest val loss on a small dataset. I think that’s great, but this points out a failure mode in such an approach

如今许多人致力于通过在小数据集上追求最低验证损失来提高样本效率。我认为这很好,但这指出了此类方法的一种失效模式。

I do think the unsupervised style training will be better in some scenarios, and I am evaluating this.

我认为无监督风格训练在某些场景下会更好,我正在对此进行评估。

Before NorMuon, I tried vanilla Muon. Obviously it trained much faster than AdamW, but the loss (and scores) would loiter at the end instead of converging. I found that cranking down the momentum and/or LR drastically at this point helped, but I didn’t want to make manually changes like this. When I switched to NorMuon, the problem disappeared

在使用 NorMuon 之前,我尝试过原始的 Muon。显然,它的训练速度比 AdamW 快得多,但损失(和分数)会在末尾徘徊而不是收敛。我发现此时大幅降低动量和/或学习率会有所帮助,但我不想进行此类手动更改。当我切换到 NorMuon 时,问题消失了。

Ablations

消融实验

The biggest contribution to performance seems to be good representations (3D RoPE + per-task embedding).

对性能最大的贡献似乎来自良好的表示(3D RoPE + 每任务嵌入)。

Removing 3D RoPE or the per-task embedding gives a steep drop. Both ablations saturate at 25%

移除 3D RoPE 或每任务嵌入会导致性能急剧下降。两种消融实验在 25% 时趋于饱和。

  • Training on inputs performs slightly worse -> ~39%
  • Restricting training set to ARC-1+ConceptARC only performs about the same: ~40%
  • Switching from 3D RoPE to 1D drops score to ~24%
  • Removing the per-task embeddings drops score to ~24%
  • Running the model CompressARC style (training from scratch on each task separately, and unsupervised), gives a drops performance down to ~18%
  • CompressARC but supervised gets ~15%
  • 在输入上进行训练表现略差 -> ~39%
  • 仅将训练集限制为 ARC-1+ConceptARC,表现大致相同:~40%
  • 从 3D RoPE 切换到 1D 会使分数降至 ~24%
  • 移除每任务嵌入会使分数降至 ~24%
  • 以 CompressARC 风格运行模型(在每个任务上单独从头开始训练,且无监督),会导致性能下降至 ~18%
  • CompressARC 但采用监督学习可获得 ~15%

Finding the best scores on other ablations. Comparing costs makes little sense here as all but the first ablation requires a lot more compute

寻找其他消融实验的最佳分数。在此比较成本意义不大,因为除第一个消融实验外,其余都需要多得多的计算资源。

How can others contribute?

其他人如何做出贡献?

The code is open source. Feel free to modify it and improve score or reduce cost. (Pls don’t increase training data)

代码是开源的。请随意修改它以提高分数或降低成本。(请勿增加训练数据)

Try reaching 65% – you won’t need many modifications. Evidence: I took the union of all solved tasks from multiple runs, and got 55%. Also a bunch of other tasks are “almost” solved. Some ideas:

尝试达到 65%——你不需要太多修改。证据:我合并了多次运行中所有已解决任务的并集,得到了 55%。此外,还有许多任务“几乎”被解决。一些想法:

  • RoPE mixes positional and content information, which probably worsens performance. PoPE should perform on par or better. Or maybe invent a new pos embedding
  • The architecture can definitely be modernised further
  • RoPE 混合了位置信息和内容信息,这可能会恶化性能。PoPE 的表现应该相当或更好。或者发明一种新的位置嵌入。
  • 架构肯定可以进一步现代化。

Costs can probably be reduced 10x with handmade GPU code. There are architectural changes that can also do this.

通过手工编写的 GPU 代码,成本可能降低 10 倍。还有一些架构变更也能做到这一点。

Lastly, figure out how to remove data augmentations. (I hate that I used it, ignore everyone who thinks its okay). There are a few obvious ways to do so, but the challenge is keeping training costs low.

最后,弄清楚如何移除数据增强。(我很讨厌我使用了它,忽略那些认为这样做没问题的人。)有几种显而易见的方法可以做到这一点,但挑战在于保持训练成本较低。

Misc

杂项

TBH, I didn’t expect to reach 45% with just the transformer, I thought this would need new ideas. I certainly didn’t expect to reach it at such low costs/flops. The ablations show that a surprising amount of perfomance is retained even without augmentations or synthetic data. Now I’m pretty sure 65% can be reached within the transformer framework

说实话,我没指望仅凭 Transformer 就能达到 45%,我以为这需要新点子。我绝对没指望能以如此低的成本/浮点运算次数达到这一水平。消融实验表明,即使没有增强或合成数据,仍能保留令人惊讶的性能比例。现在我非常确信可以在 Transformer 框架内达到 65%。

I don’t understand why others didn’t figure this out. Its just a transformer with the most obvious representation. This benchmark has been open for 6 years, was high profile, and had a million dollar prize! Maybe researchers underestimate deep learning? Maybe the cost of experimentation was high enough that they couldn’t run ablations properly? Blindsided by LLMs or using harnesses?

我不明白为什么其他人没有发现这一点。这只是一个具有最明显表示方式的 Transformer。这个基准测试已经开放了 6 年,备受瞩目,还有百万美元奖金!也许研究人员低估了深度学习?也许实验成本太高,导致他们无法正确运行消融实验?被 LLM 蒙蔽了双眼,还是在使用工具包?

Appendix

附录

Prev criticism/validation on my approach from famous researchers

著名研究者对我之前方法/验证的批评

My old result went viral on X and many experienced researchers debated about it, both for and against. Threads by Jeremy, Lucas, Susan, Andreas, Yoav, and many more. I’m listing all the criticisms here with my answers.

我之前的结果在 X(推特)上火了,许多资深研究人员对此展开了辩论,有支持也有反对。Jeremy、Lucas、Susan、Andreas、Yoav 等人的帖子都涉及了这一点。我在这里列出所有的批评以及我的回应。

Training on the eval puzzles is cheating / “training on test”

在评估谜题上进行训练属于作弊 / “在测试集上训练”

  • No this is false. “Training on test” specifically means training on the labels of test data. The labels were not trained on.
  • Also, ARC is a metalearning benchmark, so you’re supposed to learn from the eval puzzles.
  • Jargon: ARC has a set of train puzzles and a set of eval puzzles. Each puzzle has example pairs and test pairs. A pair consists of an input grid + output grid.
  • 不,这是错误的。“在测试集上训练”特指使用测试数据的标签进行训练。这里并没有使用标签进行训练。
  • 此外,ARC 是一个元学习基准测试,因此你应该从评估谜题中学习。
  • 术语说明:ARC 包含一组训练谜题和一组评估谜题。每个谜题都有示例对和测试对。一对由一个输入网格和一个输出网格组成。

更进一步:量化金融体系

看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力

进入量化体系 →

相似阅读

另一事件,读法相近