How do Transformers Learn Implicit Reasoning?

Jiaran Ye, Zijun Yao, Zhidian Huang, Liangming Pan, Jinxin Liu, Yushi Bai, Amy Xin, Liu Weichuan, Xiaoyin Che, Lei Hou, Juanzi Li

We know that Large Language Models (LLMs) are remarkably good at multi-step reasoning when they use Chain-of-Thought (CoT) prompting—literally "thinking out loud." But recent research shows they can also perform these complex leaps implicitly, jumping straight to the correct answer without verbalizing intermediate steps.

How does a sequence of matrix multiplications perform a logical "hop" internally? A new paper from researchers at Tsinghua University, Peking University, and Siemens AG pulls back the curtain on this mystery, revealing a structured developmental journey and a geometric secret behind how Transformers learn to reason.

TL;DR

By training Transformers in a controlled symbolic environment, researchers identified a three-stage "learning trajectory" for implicit reasoning: memorization, in-distribution generalization, and finally, cross-distribution generalization. The study reveals that successful reasoning isn't about mere "decodability" of intermediate steps, but rather cosine-space clustering—the model’s ability to group internal representations of the same "bridge" entity into tight geometric clusters.

What Problem Does This Paper Address?

Implicit reasoning is a "black box" within a "black box." While we can see an LLM correctly answer a query like (Alice, mother-of, sister-of) → Carol without mentioning the intermediate person (Beth), we don't know if the model is actually performing a two-step logical traversal or just relying on a massive, memorized lookup table.

The authors sought to determine:

  1. Does the model genuinely conduct step-by-step reasoning internally?
  2. What specific training data is required to trigger this ability?
  3. What do these "internal thoughts" actually look like in the hidden layers?

Methods & Datasets

The researchers used a controlled symbolic environment where they could precisely manipulate what the model sees during training. They trained GPT-2-style decoders from scratch to solve compositional queries using a synthetic dataset of 2,000 entities and 200 relations. The data included atomic triples (single facts) and multi-hop queries, split into In-Distribution (ID) and Out-of-Distribution (OOD) sets to test generalization.

To peek under the hood, they introduced two clever diagnostic tools:

  • Cross-Query Semantic Patching: They took a hidden state from one query (the "source") and surgically swapped it into another query (the "target"). If the model’s final answer changed to reflect the source's intermediate entity, it proved that specific hidden state was carrying transferable semantic information.
  • Cosine-Based Representational Lens: Instead of trying to "read" the model's mind by decoding vectors into words, they looked at the geometry. They measured how closely the model clustered different representations of the same intermediate entity in high-dimensional space using cosine similarity.

Key Insights and Ideas

The Three-Stage Trajectory Models don't just "get it" all at once. As training progresses, they pass through distinct phases. They first memorize specific paths (Phase I), then learn to generalize within the types of hops they've seen (Phase II), and much later, they learn to reason over new distributions (Phase III).

Learning trajectory showing three phases of reasoning

Decodability is a Red Herring Surprisingly, a model can often "know" an intermediate entity—meaning you can decode it from the hidden state—without being able to use it to reach the final answer. Reasoning only emerges when the representations become geometrically consistent.

The "Bridge" Must Cluster The "aha moment" for the model happens when it starts mapping different paths that lead to the same intermediate entity into the same neighborhood in hidden space. This cosine-space clustering is the internal mechanism for semantic abstraction.

Illustration of the transition from scattered memory to clustered implicit reasoning

The First-Hop "Cheat" The model can generalize to OOD facts in the first hop of a chain, but it struggles with the second hop. The authors found that first-hop generalization is actually "propped up" by representational scaffolds built by the ID triples.

Key Results

  • Acceleration, not Necessity: Training on atomic (single) triples isn't strictly necessary for a model to learn multi-hop reasoning, but it acts like a catalyst, significantly speeding up the transition to the generalization phase.
  • The Second-Hop Bottleneck: Generalization to the second hop fails unless the model has seen that specific compositional structure during training. This suggests that "reasoning" is highly dependent on query-level exposure.
  • Clustering Correlates with Accuracy: The researchers found a near-perfect correlation between the "ID Cohesion Score" (how tight the clusters are) and the model's accuracy on unseen test queries.

Limitations and Future Work

The primary limitation is the use of a symbolic environment. While this allows for perfect experimental control, real-world natural language is far noisier and more complex.

When the authors scaled up to a 1.5B parameter model (Qwen2.5), they noticed more "instability" in the third phase of learning, suggesting that larger models might decouple the processes of "aligning representations" and "executing the logic." Future work will likely focus on how to stabilize this cross-distribution reasoning in massive models and whether these geometric patterns hold true for non-symbolic, natural language tasks.

Summary updated

BibTeX
@inproceedings{ye2025how,
  author = {Jiaran Ye and Zijun Yao and Zhidian Huang and Liangming Pan and Jinxin Liu and Yushi Bai and Amy Xin and Liu Weichuan and Xiaoyin Che and Lei Hou and Juanzi Li},
  title = {{How do Transformers Learn Implicit Reasoning?}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=19ygs48nOa},
}
Figure