How do Transformers Learn Implicit Reasoning?

Jiaran Ye, Zijun Yao, Zhidian Huang, Liangming Pan, Jinxin Liu +6 more
5/29/2025
cs.LG

No official code found. Best implementation: Jiaran-Ye/ImplicitReasoning (18 stars, last commit 2025-07-03).

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.

View on arXivView PDF

Code Implementations(1)

Code for paper 'How does Transformer Learn Implicit Reasoning?'

182Jupyter NotebookMay 28, 20251 years ago

Similar Papers

Cite this paper

@article{ye2025transformers,
  title  = {How do Transformers Learn Implicit Reasoning?},
  author = {Jiaran Ye and Zijun Yao and Zhidian Huang and Liangming Pan and Jinxin Liu and Yushi Bai and Amy Xin and Weichuan Liu and Xiaoyin Che and Lei Hou and Juanzi Li},
  year   = {2025},
  eprint = {2505.23653},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.23653v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.23653.svg)](https://codeofpaper.com/paper/2505.23653)

Discussion