arXiv:2502.16792cs.LGcs.AI2025-02被引 9

发现稀疏依赖是模型长文本预测的关键,提出新理论与方法。

The Role of Sparsity for Length Generalization in Transformers

  • 用稀疏相关分布建模,证明仅依赖少量历史词可实现长度泛化
  • 实验证明:真实语言中每个词仅依赖少数前序词时,模型泛化能力更强
  • 提出预测性位置耦合,扩展位置编码技巧适用范围

近年来,训练大语言模型以预测超出训练上下文长度的文本受到广泛关注,但其长度泛化的内在机制仍不明确。本文针对仅解码器架构的Transformer,提出一种新的理论框架,研究下一词预测任务中的长度泛化问题。概念上,我们证明只要每个被预测词仅依赖于有限(固定)数量的前序词,就能实现长度泛化。通过引入称为 $k$-sparse planted correlation distributions 的稀疏相关分布形式化该类任务,并证明理想化的注意力头能成功泛化。此外,理论还解释了某些提升长度泛化的技术(如位置耦合)的有效性。我们在合成任务和自然语言数据上进行了实验,证实每个词对前序词的‘稀疏’依赖结构是长度泛化的核心因素。受此启发,我们提出预测性位置耦合(Predictive Position Coupling),让模型学习位置耦合中的位置ID,从而扩展该技术在更多任务上的应用,实现更广泛的长度泛化。

原文摘要 · Abstract (English)

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.

Transformer长度泛化稀疏性位置编码

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。