arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2510.09340cs.AIcs.CL

语言模型中的演绎推理:横向与纵向推理

Deductive Logic in Language Models: Horizontal vs Vertical Reasoning

Department of Computer Science and Engineering, University of Bologna(博洛尼亚大学计算机科学与工程系)

Davide Maltoni, Matteo Ferrara

AI总结:

研究小型Transformer语言模型在演绎任务中的推理机制,区分横向推理(自回归生成中间步骤)和纵向推理(跨层隐式推理),发现思维链监督有助于学习基于规则的推理,并通过机械可解释性揭示其实现方式。

摘要:

近期语言模型展现出显著的逻辑推理能力,但支持演绎推理的机制仍不明确。本文研究从头训练的小型基于Transformer的语言模型在多步演绎任务上的表现,重点关注横向推理(中间步骤自回归生成)与纵向推理(在第一个输出token产生前,推理跨层隐式展开)之间的区别。我们分析了两个合成任务:符号蕴含链上的逻辑推论和二叉树中的根到叶导航。机械可解释性表明,思维链监督使模型能够学习基于规则的推理,而非统计捷径。在横向设置中,一个浅层仅注意力模型发展出可解释的电路,用于规则补全、规则链接和最终决策,主要通过类归纳头机制实现。我们进一步引入一种截断伪逆方法来解码查询、键和值所携带的信息。对于纵向推理,思维链似乎较少作为显式的逐步指导,而更多作为一种课程学习形式,帮助模型获取日益复杂的推理模式。没有思维链时,模型倾向于记忆或利用数据集偏差。这些结果提供了Transformer如何实现演绎推理的低层解释,并提示思维链在横向和纵向推理中可能发挥不同功能。

英文摘要:

Recent language models exhibit significant logical reasoning abilities, yet the mechanisms supporting deductive inference remain poorly understood. This paper studies small transformer-based language models trained from scratch on multi-step deductive tasks, focusing on the distinction between horizontal reasoning, where intermediate steps are generated autoregressively, and vertical reasoning, where inference unfolds implicitly across layers before the first output token is produced. We analyze two synthetic tasks: logical consequence over chains of symbolic implications and root-to-leaf navigation in binary trees. Mechanistic interpretability reveals that Chain-of-Thought supervision enables models to learn rule-based inference rather than statistical shortcuts. In the horizontal setting, a shallow attention-only model develops interpretable circuits for rule completion, rule chaining, and final decision making, largely implemented through induction-head-like mechanisms. We further introduce a truncated pseudoinverse method to decode the information carried by queries, keys, and values. For vertical reasoning, Chain-of-Thought appears to act less as explicit step-by-step guidance and more as a form of curriculum learning, helping the model acquire increasingly complex reasoning patterns. Without Chain-of-Thought, models tend to memorize or exploit dataset biases. These results provide a low-level account of how transformers can implement deductive reasoning and suggest how Chain-of-Thought may serve different functions in horizontal and vertical reasoning.

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

↑