arXiv:2412.11459cs.CLcs.LG2024-12

揭示Transformer如何用联想记忆融合上下文与预训练知识

Rethinking Associative Memory Mechanism in Induction Head

  • 从联想记忆视角分析两层Transformer的注意力权重与输出逻辑
  • 实验证明模型能准确匹配由二元模型生成提示的理论预测结果
  • 适合研究大模型上下文学习机制的读者深入理解其内在原理

归纳头机制是大语言模型实现零样本上下文学习的关键计算通路,使模型无需微调即可适应新任务。现有研究多关注该机制的训练动态,但对模型在长上下文下协调上下文信息与预训练全局知识的能力仍缺乏理解。本文从联想记忆角度出发,理论分析了两层Transformer在注意力层权重表示及生成提示时的输出逻辑,这些提示由二元模型生成。通过设计特定提示进行实验,验证了训练后模型的输出是否与理论预测一致,揭示了模型在长期上下文与预训练知识间平衡的内在机制。

原文摘要 · Abstract (English)

Induction head mechanism is a part of the computational circuits for in-context learning (ICL) that enable large language models (LLMs) to adapt to new tasks without fine-tuning. Most existing work explains the training dynamics behind acquiring such a powerful mechanism. However, the model's ability to coordinate in-context information over long contexts and global knowledge acquired during pretraining remains poorly understood. This paper investigates how a two-layer transformer thoroughly captures in-context information and balances it with pretrained bigram knowledge in next token prediction, from the viewpoint of associative memory. We theoretically analyze the representation of weight matrices in attention layers and the resulting logits when a transformer is given prompts generated by a bigram model. In the experiments, we design specific prompts to evaluate whether the outputs of the trained transformer align with the theoretical results.

上下文学习联想记忆Transformer机制语言模型

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