arXiv:2601.19208cs.CLcs.LG2026-01被引 4

揭示Transformer如何通过梯度机制学习词义关联,让模型可解释性更进一步。

How Do Transformers Learn to Associate Tokens: Gradient Leading Terms Bring Mechanistic Interpretability

  • 用梯度主项近似推导出训练初期权重的闭式表达
  • 发现权重由三个基础函数组合而成,对应文本统计特征
  • 理论结果与真实大模型权重高度吻合,适合研究模型机理者

语义关联(如'bird'与'flew'之间的联系)是语言建模的基础,使模型能超越记忆而实现泛化与连贯生成。理解这些关联在基于注意力的语言模型中如何习得与表征,对连接深度学习与语言理论、构建大语言模型的机制基础至关重要。本文从训练动态角度分析注意力模型如何从自然语言数据中涌现出语义关联。通过梯度主项近似,我们推导出训练早期权重的闭式表达,揭示每个Transformer权重均为三个基础函数(二元组、词元可互换性、上下文映射)的简单组合,反映语料统计特性,并阐明各组件如何基于这些组合捕捉语义关联。在真实LLM上的实验表明,我们的理论权重表征与实际学习到的权重高度一致;定性分析进一步证明该理论能有效揭示Transformer中习得关联的内在机制。

原文摘要 · Abstract (English)

Semantic associations such as the link between "bird" and "flew" are foundational for language modeling as they enable models to go beyond memorization and instead generalize and generate coherent text. Understanding how these associations are learned and represented in language models is essential for connecting deep learning with linguistic theory and developing a mechanistic foundation for large language models. In this work, we analyze how these associations emerge from natural language data in attention-based language models through the lens of training dynamics. By leveraging a leading-term approximation of the gradients, we develop closed-form expressions for the weights at early stages of training that explain how semantic associations first take shape. Through our analysis, we reveal that each set of weights of the transformer has closed-form expressions as simple compositions of three basis functions (bigram, token-interchangeability, and context mappings), reflecting the statistics of the text corpus and uncovering how each component of the transformer captures semantic associations based on these compositions. Experiments on real-world LLMs demonstrate that our theoretical weight characterizations closely match the learned weights, and qualitative analyses further show how our theorem shines light on interpreting the learned associations in transformers.

Transformer可解释性语义关联梯度分析

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