How do Transformers Learn Implicit Reasoning?
Jiaran Ye, Zijun Yao, Zhidian Huang, Liangming Pan, Jinxin Liu, Yushi Bai, Amy Xin, Weichuan Liu, Xiaoyin Che, Lei Hou, Juanzi Li
TL;DR
This work investigates how Transformer models develop implicit multi-hop reasoning in a controlled symbolic environment, disentangling genuine internal reasoning from memorization. By training a decoder-only Transformer on atomic triples and multi-hop queries, and by employing cross-query semantic patching and a cosine-based representational lens, it uncovers a three-stage developmental trajectory: memorization, in-distribution generalization, and cross-distribution generalization. Key findings include that second-hop generalization requires query-level exposure to exact compositional structures, ID triples accelerate but are not strictly necessary for ID generalization, and successful cross-distribution reasoning correlates with cosine-space clustering of intermediate representations anchored by ID supervision. The work provides mechanistic, interpretable diagnostics linking training dynamics to internal geometry, offering pathways to enhance transparency of implicit reasoning in LLMs and informing data-design choices to improve generalization across distributions.
Abstract
Recent work suggests that large language models (LLMs) can perform multi-hop reasoning implicitly -- producing correct answers without explicitly verbalizing intermediate steps -- but the underlying mechanisms remain poorly understood. In this paper, we study how such implicit reasoning emerges by training transformers from scratch in a controlled symbolic environment. Our analysis reveals a three-stage developmental trajectory: early memorization, followed by in-distribution generalization, and eventually cross-distribution generalization. We find that training with atomic triples is not necessary but accelerates learning, and that second-hop generalization relies on query-level exposure to specific compositional structures. To interpret these behaviors, we introduce two diagnostic tools: cross-query semantic patching, which identifies semantically reusable intermediate representations, and a cosine-based representational lens, which reveals that successful reasoning correlates with the cosine-base clustering in hidden space. This clustering phenomenon in turn provides a coherent explanation for the behavioral dynamics observed across training, linking representational structure to reasoning capability. These findings provide new insights into the interpretability of implicit multi-hop reasoning in LLMs, helping to clarify how complex reasoning processes unfold internally and offering pathways to enhance the transparency of such models.
