arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2502.16792cs.LGcs.AIcs.CL
收藏

稀疏性在Transformer长度泛化中的作用

The Role of Sparsity for Length Generalization in Transformers

MIT EECS(麻省理工学院电子工程与计算机科学系);Harvard University(哈佛大学);Kempner Institute at Harvard University(哈佛大学肯普纳研究所)

Noah Golowich, Samy Jelassi, David Brandfonbrener, Sham M. Kakade, Eran Malach

AI总结:

本文提出理论框架证明,当每个预测词元仅依赖少量先前词元(稀疏依赖)时,Transformer可实现长度泛化,并据此引入预测性位置耦合方法以扩展应用范围。

摘要:

近年来,训练大型语言模型以预测超出其训练上下文长度的内容引起了广泛关注,然而驱动这种长度泛化行为的原理仍未得到充分探索。我们提出了一个新的理论框架,用于研究仅解码器Transformer在执行下一个词元预测任务时的长度泛化。从概念上讲,我们表明,只要每个预测的词元依赖于少量(固定数量)的先前词元,长度泛化就会发生。我们通过一个称为$k$-稀疏植入相关分布的概念来形式化此类任务,并展示了一个理想化的Transformer模型(其注意力头具有泛化能力)能够在这些任务上成功实现长度泛化。作为额外收获,我们的理论模型为某些用于改进长度泛化的位置嵌入修改技术(如位置耦合)提供了合理性依据。我们通过合成任务和自然语言实验支持了我们的理论结果,这些实验证实了驱动长度泛化的一个关键因素是每个词元对先前词元的“稀疏”依赖结构。受我们理论的启发,我们引入了预测性位置耦合,该方法训练Transformer预测位置耦合方法中使用的位置ID。预测性位置耦合因此使我们能够拓宽位置耦合可成功应用以实现长度泛化的任务范围。

英文摘要:

Training large language models to predict beyond their training context lengths has drawn much attention in recent years, yet the principles driving such behavior of length generalization remain underexplored. We propose a new theoretical framework to study length generalization for the next-token prediction task, as performed by decoder-only transformers. Conceptually, we show that length generalization occurs as long as each predicted token depends on a small (fixed) number of previous tokens. We formalize such tasks via a notion we call $k$-sparse planted correlation distributions, and show that an idealized model of transformers which generalize attention heads successfully length-generalize on such tasks. As a bonus, our theoretical model justifies certain techniques to modify positional embeddings which have been introduced to improve length generalization, such as position coupling. We support our theoretical results with experiments on synthetic tasks and natural language, which confirm that a key factor driving length generalization is a ``sparse'' dependency structure of each token on the previous ones. Inspired by our theory, we introduce Predictive Position Coupling, which trains the transformer to predict the position IDs used in a positional coupling approach. Predictive Position Coupling thereby allows us to broaden the array of tasks to which position coupling can successfully be applied to achieve length generalization.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑