arXiv:2503.13305cs.CLcs.AI2025-03ACL被引 2

揭示大模型位置泛化背后的计算机制

Computation Mechanism Behind LLM Position Generalization

  • 发现注意力分数与位置重要性+语义重要性的和呈高度线性相关
  • 模型通过学习到的特征模式实现对位置扰动的容错能力
  • 为理解大模型文本位置灵活性提供了可解释的计算依据

大多数自然语言由词和句子序列构成。与人类类似,大语言模型(LLMs)在处理文本位置时表现出灵活性——我们称之为位置泛化。它们能容忍位置扰动,并通过最新技术推广到训练中未见的更长文本。这表明LLMs对位置变化具有容忍性,但其内部如何计算位置相关性仍不明确。本文将语言现象与模型计算机制联系起来,揭示了模型在位置扰动下保持容忍性的内在机制。尽管自注意力机制复杂,但研究发现,LLMs学到了一种反直觉的注意力分值解耦:其值与位置相关性与语义重要性之和的近似值有0.959的线性相关性。同时,我们识别出中间特征中的普遍模式,并从理论上证明该模式可实现此效果。该模式不同于随机初始化参数的行为,表明是模型学习所得而非架构固有特性。基于这些发现,本文提供了位置灵活性的计算解释与判断标准。这是首次将位置泛化与现代大模型内部机制建立直接关联的开创性工作。

原文摘要 · Abstract (English)

Most written natural languages are composed of sequences of words and sentences. Similar to humans, large language models (LLMs) exhibit flexibility in handling textual positions - a phenomenon we term position generalization. They can understand texts with position perturbations and generalize to longer texts than those encountered during training with the latest techniques. These phenomena suggest that LLMs handle positions tolerantly, but how LLMs computationally process positional relevance remains largely unexplored. This work connects the linguistic phenomenon with LLMs' computational mechanisms. We show how LLMs enforce certain computational mechanisms for the aforementioned tolerance in position perturbations. Despite the complex design of the self-attention mechanism, this work reveals that LLMs learn a counterintuitive disentanglement of attention logits. Their values show a 0.959 linear correlation with an approximation of the arithmetic sum of positional relevance and semantic importance. Furthermore, we identify a prevalent pattern in intermediate features, which we prove theoretically enables this effect. The pattern, which is different from how randomly initialized parameters would behave, suggests that it is a learned behavior rather than a natural result of the model architecture. Based on these findings, we provide computational explanations and criteria for LLMs' position flexibilities. This work takes a pioneering step in linking position generalization with modern LLMs' internal mechanisms.

大模型位置泛化注意力机制可解释性

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