Skip to main content
QUICK REVIEW

[论文解读] Transformers Can Achieve Length Generalization But Not Robustly

Yongchao Zhou, Uri Alon|arXiv (Cornell University)|Feb 14, 2024
Neural Networks and ApplicationsComputer Science被引用 3
一句话总结

该论文表明,通过使用特定的FIRE位置编码、反转数据格式和索引提示,Transformer模型在十进制加法任务中可实现高达2.5倍于训练时所见序列长度的泛化能力。然而,这种成功极为脆弱,且对随机权重初始化和训练数据顺序高度敏感,表明尽管泛化性能出色,稳健性仍是亟待解决的关键挑战。

ABSTRACT

Length generalization, defined as the ability to extrapolate from shorter training sequences to longer test ones, is a significant challenge for language models. This issue persists even with large-scale Transformers handling relatively straightforward tasks. In this paper, we test the Transformer's ability of length generalization using the task of addition of two integers. We show that the success of length generalization is intricately linked to the data format and the type of position encoding. Using the right combination of data format and position encodings, we show for the first time that standard Transformers can extrapolate to a sequence length that is 2.5x the input length. Nevertheless, unlike in-distribution generalization, length generalization remains fragile, significantly influenced by factors like random weight initialization and training data order, leading to large variances across different random seeds.

研究动机与目标

  • 研究Transformer是否能在算法推理任务中实现稳健的长度泛化。
  • 评估位置编码和数据格式对长度泛化性能的影响。
  • 确定仅靠网络架构设计是否足以实现长度泛化,还是数据和训练配置同样关键。
  • 在不同训练条件(如随机种子和数据顺序)下评估长度泛化的稳健性。

提出的方法

  • 本研究使用N位十进制加法的合成任务,评估Transformer在长度泛化方面的表现。
  • 采用FIRE位置编码并引入随机化位置,以提升模型在超过训练长度的序列上的建模能力。
  • 通过将数据格式设为反转顺序并加入索引提示,增强模型对位置依赖关系的学习能力。
  • 实验对比了多种位置编码与数据格式组合在多个随机种子和训练数据顺序下的表现。
  • 模型性能在测试序列上进行评估,最长达100位数字,而训练仅使用最多40位的序列。
  • 系统性地调整学习率、权重衰减和dropout等超参数,以评估其对泛化稳健性的影响。
Figure 1 : Using an appropriate position encoding and data formatting, we demonstrate that Transformers can generalize to 100-digit decimal addition tasks with more than 98% of accuracy when trained up to 40-digit addition, resulting in a length extension ratio of $2.5\times$ , which is much more th
Figure 1 : Using an appropriate position encoding and data formatting, we demonstrate that Transformers can generalize to 100-digit decimal addition tasks with more than 98% of accuracy when trained up to 40-digit addition, resulting in a length extension ratio of $2.5\times$ , which is much more th

实验结果

研究问题

  • RQ1当采用最优数据格式和位置编码时,Transformer是否能泛化到远超训练时所见长度的序列?
  • RQ2不同位置编码方案与数据格式的组合如何影响长度泛化表现?
  • RQ3长度泛化在多大程度上对随机权重初始化和训练数据顺序的变化保持稳健?
  • RQ4通过权重衰减或dropout进行正则化是否能提升长度泛化的稳健性?
  • RQ5是否存在一种数据格式与位置编码的协同组合,能够在其他方法失败时实现强大的长度泛化?

主要发现

  • Transformer在十进制加法任务中可实现2.5倍长度泛化,从40位扩展至100位序列,准确率超过98%。
  • 长度泛化的成功关键依赖于FIRE位置编码(带随机化位置)与反转数据格式(带索引提示)的组合。
  • 尽管泛化性能出色,模型在不同随机种子下的准确率差异显著,表明其对权重初始化极为敏感。
  • 训练数据顺序也具有显著影响,性能随样本呈现顺序的不同而大幅波动。
  • 正则化技术如权重衰减和dropout并未显著提升稳健性,且高dropout率(如0.2)会严重损害泛化能力。
  • 结果表明,尽管通过合理设计可实现长度泛化,但在标准训练条件下,其仍表现脆弱且不可靠。
Figure 2 : Comparative overview of PEs and data formats: While most related studies focus on APE or NoPE, our approach integrates FIRE (Li et al., 2023 ) and Randomized PE (Ruoss et al., 2023 ) . All studies utilize a reversed format. Shen et al. ( 2023 ) enhance this with random space augmentation,
Figure 2 : Comparative overview of PEs and data formats: While most related studies focus on APE or NoPE, our approach integrates FIRE (Li et al., 2023 ) and Randomized PE (Ruoss et al., 2023 ) . All studies utilize a reversed format. Shen et al. ( 2023 ) enhance this with random space augmentation,

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。