arXiv:2502.02004cs.CL2025-02ICLR被引 7

用小波变换提升长文本位置编码,让模型能更好处理超长序列。

Wavelet-based Positional Representation for Long Context

  • 基于小波变换设计多尺度位置表示,突破传统方法的单一尺度限制。
  • 在短序列和长序列上均提升性能,支持无损外推位置信息。
  • 适合需要处理超长上下文的场景,如文档理解、代码生成等。

在大规模语言模型中,当序列长度超出训练时的最大限制时,位置编码机制难以有效表示更长序列中的位置信息。本文分析了现有长序列位置编码方法,发现:(1) 旋转位置编码(RoPE)可视为使用海氏小波的受限小波变换,但因仅采用固定尺度参数,未能充分利用小波变换在多尺度下捕捉非平稳信号细节的优势,导致外推能力差;(2) 线性偏置注意力(ALiBi)类似窗口化注意力,具有可变窗口大小,但受限于接收域,难以建模深层依赖。基于以上洞察,本文提出一种基于小波变换的新位置表示方法,通过多尺度特征捕捉实现无限制注意力场下的位置信息外推。实验表明,该方法在短序列与长序列上均提升模型性能,显著增强长序列外推能力。

原文摘要 · Abstract (English)

In the realm of large-scale language models, a significant challenge arises when extrapolating sequences beyond the maximum allowable length. This is because the model's position embedding mechanisms are limited to positions encountered during training, thus preventing effective representation of positions in longer sequences. We analyzed conventional position encoding methods for long contexts and found the following characteristics. (1) When the representation dimension is regarded as the time axis, Rotary Position Embedding (RoPE) can be interpreted as a restricted wavelet transform using Haar-like wavelets. However, because it uses only a fixed scale parameter, it does not fully exploit the advantages of wavelet transforms, which capture the fine movements of non-stationary signals using multiple scales (window sizes). This limitation could explain why RoPE performs poorly in extrapolation. (2) Previous research as well as our own analysis indicates that Attention with Linear Biases (ALiBi) functions similarly to windowed attention, using windows of varying sizes. However, it has limitations in capturing deep dependencies because it restricts the receptive field of the model. From these insights, we propose a new position representation method that captures multiple scales (i.e., window sizes) by leveraging wavelet transforms without limiting the model's attention field. Experimental results show that this new method improves the performance of the model in both short and long contexts. In particular, our method allows extrapolation of position information without limiting the model's attention field.

位置编码长序列小波变换外推

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