循环回环Transformer

·

研究论文 · 2026/10/08

状态跟踪需要在每个输入处进行更新,但Transformer对每个token施加的深度是固定的,与序列长度无关。我们提出了循环环状Transformer(RLT),它将层分为并行因果编码器和循环解码器。在每个token处,解码器将编码器输出与前一个token的最终解码器状态合并,因此计算路径随序列长度增长,而每个token的成本固定。在六个算法任务上,我们比较了八层的五种分割与八层Transformer在三个种子上的表现。在最多40位的训练下,两种RLT分割在每个种子中都将奇偶校验泛化到256位,准确率达100%,而Transformer保持随机水平。在基于交换的S_5排列跟踪任务上,训练长度的八倍时,RLT达到97%的最终状态准确率,而Transformer低于1%,且准确率随解码器深度增加。在超出训练长度的模算术任务上,RLT达到高达93%,而Transformer为33%。消融实验表明,这些增益依赖于反馈:移除反馈后,奇偶校验和基于交换的S_5在每个分割上都降至随机水平。每四token块更新一次反馈,使块内已知token可以并行运行,并将64位奇偶校验保持在99%,而排列跟踪依赖于每token反馈:分块将长度64的基于交换的S_5从100%降低到20%。

该研究提出了一种新颖的循环环状Transformer架构,通过引入循环解码器和反馈机制,使模型能够处理比训练时更长的序列,并在多个算法任务上显著优于标准Transformer。这项工作对于理解Transformer在长度泛化方面的局限性以及设计更强大的序列建模架构具有重要意义。

State tracking requires an update at every input, but the depth a Transformer applies to each token is fixed regardless of sequence length. We introduce the Recurrent Looped Transformer (RLT), which splits its layers between a parallel causal encoder and a recurrent decoder. At each token, the decoder merges the encoder output with the previous token's final decoder state, so the computation path grows with sequence length at a fixed per-token cost. On six algorithmic tasks, we compare five splits of eight layers with an eight-layer Transformer over three seeds. Trained on at most 40 bits, two RLT splits generalize parity to 256 bits with 100% accuracy in every seed, while the Transformer stays at chance. On swap-based S_5 permutation tracking at eight times the training length, RLT reaches 97% final-state accuracy versus under 1% for the Transformer, and accuracy increases with decoder depth. On modular arithmetic beyond the training lengths, RLT reaches up to 93% versus 33% for the Transformer. Ablations show that these gains depend on the feedback: removing it drops parity and swap-based S_5 to chance at every split. Updating the feedback once per four-token chunk lets known tokens in a chunk run in parallel and keeps 64-bit parity at 99%, while permutation tracking depends on per-token feedback: chunking lowers length-64 swap-based S_5 from 100% to 20%.

阅读原文

参与讨论