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

Transformer 中支撑组合推理的层特化

Layer Specialization Underlying Compositional Reasoning in Transformers

ENS, Université PSL, EHESS, CNRS(高等科学研究院、巴黎高等科学研究所、国家科学研究中心)

Jing Liu

AI总结:

该研究利用 Random Hierarchy Model 分析 Transformer 的组合推理,揭示层特化随训练逐步形成,并与不同泛化条件下的性能相关。

摘要:

Transformer 会在训练期间未观察过的序列上表现出组合推理能力,这种能力通常被归因于上下文学习(ICL)和技能组合。我们使用 Random Hierarchy Model(RHM)研究这一现象,该模型是一种通过递归规则应用生成序列的概率上下文无关文法。模型在序列子集上进行训练,并在四种泛化条件下评估:记忆、分布内泛化、使用相同规则的分布外泛化,以及跨层迁移。在行为层面,性能随任务复杂性和上下文示例数量系统性提升,而分布外任务比分布内场景需要显著更多的示例。在机制层面,我们发现训练过程中层特化会逐步出现,并且与泛化性能相关。主成分分析和注意力模式聚类表明,Transformer 会在特化层中形成结构化、按层级组织的表示。这些结果证明,Transformer 发展出了支持组合推理的模块化、可解释机制,将内部算法结构与观察到的行为能力联系起来。

英文摘要:

Transformers exhibit compositional reasoning on sequences not observed during training, a capability often attributed to in-context learning (ICL) and skill composition. We investigate this phenomenon using the Random Hierarchy Model (RHM), a probabilistic context-free grammar that generates sequences through recursive rule application. Models are trained on subsets of sequences and evaluated across four generalization conditions: memorization, in-distribution generalization, out-of-distribution generalization with the same rules, and cross-layer transfer. Behaviorally, performance improves systematically with task complexity and the number of in-context examples, with out-of-distribution tasks requiring substantially more examples than in-distribution scenarios. Mechanistically, we identify a progressive emergence of layer specialization during training that correlates with generalization performance. Principal component analysis and attention pattern clustering reveal that transformers develop structured, hierarchically organized representations in specialized layers. These results demonstrate that transformers develop modular, interpretable mechanisms supporting compositional reasoning, linking internal algorithmic structure to observed behavioral capabilities.

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

↑