arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2503.13305cs.CLcs.AI
收藏

LLM位置泛化背后的计算机制

Computation Mechanism Behind LLM Position Generalization

University of Illinois Urbana-Champaign(伊利诺伊大学厄巴纳-香槟分校)

Chi Han, Heng Ji

AI总结:

本研究揭示了LLM实现位置泛化的计算机制,发现其注意力logits与位置相关性和语义重要性的算术和近似值呈0.959线性相关,从内部机制角度为位置灵活性提供了计算解释。

摘要:

大多数书面自然语言由单词和句子序列组成。与人类类似,大型语言模型(LLMs)在处理文本位置方面表现出灵活性,我们将这一现象称为位置泛化。它们能够理解带有位置扰动的文本,并借助最新技术泛化到比训练时遇到的更长的文本。这些现象表明LLMs对位置的处理具有容错性,但LLMs在计算上如何处理位置相关性在很大程度上仍未被探索。这项工作将这一语言现象与LLMs的计算机制联系起来。我们展示了LLMs如何通过实施特定的计算机制来实现上述对位置扰动的容错性。尽管自注意力机制设计复杂,但本研究揭示了LLMs学习到了一种反直觉的注意力logits解耦。它们的值与位置相关性和语义重要性的算术和近似值之间表现出0.959的线性相关性。此外,我们在中间特征中识别出一种普遍模式,并在理论上证明了该模式能够实现这一效应。该模式不同于随机初始化参数的行为方式,表明这是一种学习到的行为,而非模型架构的自然结果。基于这些发现,我们为LLMs的位置灵活性提供了计算解释和标准。这项工作在将位置泛化与现代LLMs内部机制联系起来方面迈出了开创性的一步。

英文摘要:

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.

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

↑