Skip to content
#natural language processing Preprint Open access

Why Knowing Both Hops Is Not Enough: Understanding Two-Hop Generalization in Language Models

Zili Zhang Yilin Wang Heng Wang Herun Wan Minnan Luo
Aug 2026
Natural Language Processing

Abstract

Large language models (LLMs) can solve complex multi-hop problems yet exhibit puzzling failures on simple two-hop queries: although a model may correctly store each individual hop, it often fails to combine them. To understand the internal mechanisms of this phenomenon, we train transformers from scratch in a controlled symbolic environment. Our experiments reveal a pattern in two-hop generalization: models generalize reliably when the second hop follows the training distribution, but always fail when it deviates. Through mechanistic analysis, we provide a complete explanation for these distinct generalization behaviors: in settings where models generalize successfully, performance is driven by the emergence of consistent intermediate representations for the same entities across contexts, whereas failures on settings where the second hop is out-of-distribution arise from a mismatch across layers: lower layers correctly construct these intermediate representations, but upper layers, while trained on corresponding atomic facts, primarily learn to map them to outputs rather than to reason over them. Driven by this insight, we propose a recurrent-style training strategy, which enables transformers to reuse their reasoning circuitry across input forms and substantially improves generalization on out-of-distribution two-hop queries. Our data and code are available at https://github.com/zzl-strong/two_hop .

View source

Similar papers

Jailbreaking in the Haystack

NINJA (short for Needle-in-haystack jailbreak attack), a method that jailbreaks aligned LMs by appending benign, model-generated content to harmful user goals to reveal fundamental vulnerabilities in modern LMs.

R. Shah, C. Wu, Shashwat Saxena et al. · 4 citations

SimulRAG: Simulator-based RAG for Grounding LLMs in Long-form Scientific QA

SimulRAG, a simulator-based RAG framework with a generalized retrieval interface that translates between text and simulator parameters/outputs, is proposed, which improves informativeness and factuality over the strongest adapted RAG baselines, while UE+SBA enhances claim-level efficiency and quality.

Haozhou Xu, D. Wu, M. Chinazzi et al. · 3 citations

Convergent Evolution: How Different Language Models Learn Similar Number Representations

This paper identifies two different routes through which models can acquire geometrically separable features: they can learn them from complementary co-occurrence signals in general language data, including text-number co-occurrence and cross-number interaction, or from multi-token addition problems.

Deqing Fu, Tianyi Zhou, Mikhail Belkin et al. · 3 citations
#artificial intelligence Preprint Aug 2026

Evaluating and Explaining Prompt Sensitivity of LLMs Using Interactions

Interactions are introduced as a fine-grained tool to analyze prompt sensitivity of LLMs and it is discovered that subtle changes to prompts can trigger severe instability in interactions, even when the outputs of the LLM remain the same.

Ruiyang Qin, Qingzhuo Wang, Tianhao Wang et al. · 2 citations · ⚡1

When Audio-Language Models Fail to Leverage Multimodal Context for Dysarthric Speech Recognition

A benchmark built on the Speech Accessibility Project (SAP) dataset is introduced that tests whether diagnosis labels, clinician-derived speech ratings, and progressively richer clinical descriptions improve transcription accuracy for dysarthric speech, finding that current models do not meaningfully use this context.

P. Moure, Niclas Pokel, Bilal Bounajma et al. · 2 citations

Making Implicit Premises Explicit in Logical Understanding of Enthymemes

A pipeline that integrates a large language model to generate intermediate implicit premises based on the explicit premise and claim, a neuro-symbolic reasoner based on a SAT solver to determine entailment, and a neuro-symbolic reasoner based on a SAT solver to determine entailment is proposed.

Xuyao Feng, Anthony Hunter · 2 citations

Related blog posts

MIT News · Artificial Intelligence Aug 27, 2026

Looking beyond natural sequences

A new machine-learning framework aims to improve the success rate of computational protein design while moving away from results that reproduce sequences found in nature.