发现大模型能通过自适应注意力机制预测带层级结构的重复模式。
A circuit for predicting hierarchical structure in-context in Large Language Models
- 设计合成任务验证模型能否处理层级重复模式
- 发现模型会学习动态选择关注哪些历史上下文
- 揭示了注意力头如何通过隐式上下文发现不同转换关系
大型语言模型(LLMs)在上下文学习中表现出色,即利用输入中的信息来提升未来词元的预测能力。诱导头(induction heads)被认为是变压器语言模型中实现上下文学习的关键机制,它们使一个词元关注过去相同词元后续出现的词元。这种基础机制支持模型复制和预测重复模式。然而,该机制是否能支持更复杂的、具有层级结构的重复模式尚不明确。自然语言中普遍存在此类情况:如英语中“the”通常引导多个名词。当预测某个“the”之后的词元时,需结合文本中的进一步上下文线索以确定正确名词。若诱导头盲目地对所有“the”后继词元统一关注,则无法实现这种上下文整合。本研究设计了一种合成的上下文学习任务,其中词元以层级依赖方式重复出现。在此类序列上,均匀关注所有后继词元不足以准确预测未来词元。评估多种LLM在这些序列及自然语言类比任务上的表现,发现自适应诱导头能够学习选择性关注,从而支持预测。进一步探究诱导头自身的上下文学习机制,发现其学习受注意力头驱动,这些头揭示一组潜在上下文,用以决定不同的词元转移关系。总体而言,不仅证明了LLMs具备可学习的诱导头,还提供了其在上下文中预测高阶重复模式的完整机制解释。
原文摘要 · Abstract (English)
Large Language Models (LLMs) excel at in-context learning, the ability to use information provided as context to improve prediction of future tokens. Induction heads have been argued to play a crucial role for in-context learning in Transformer Language Models. These attention heads make a token attend to successors of past occurrences of the same token in the input. This basic mechanism supports LLMs' ability to copy and predict repeating patterns. However, it is unclear if this same mechanism can support in-context learning of more complex repetitive patterns with hierarchical structure. Natural language is teeming with such cases: The article "the" in English usually prefaces multiple nouns in a text. When predicting which token succeeds a particular instance of "the", we need to integrate further contextual cues from the text to predict the correct noun. If induction heads naively attend to all past instances of successor tokens of "the" in a context-independent manner, they cannot support this level of contextual information integration. In this study, we design a synthetic in-context learning task, where tokens are repeated with hierarchical dependencies. Here, attending uniformly to all successor tokens is not sufficient to accurately predict future tokens. Evaluating a range of LLMs on these token sequences and natural language analogues, we find adaptive induction heads that support prediction by learning what to attend to in-context. Next, we investigate how induction heads themselves learn in-context. We find evidence that learning is supported by attention heads that uncover a set of latent contexts, determining the different token transition relationships. Overall, we not only show that LLMs have induction heads that learn, but offer a complete mechanistic account of how LLMs learn to predict higher-order repetitive patterns in-context.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。