When Does In-Context Search Help? A Sampling-Complexity Theory of Reflection-Driven Reasoning

Yotam Wolf, Noam Wies, Amnon Shashua
7/7/2026
cs.AIcs.CL

No confident code implementation found for this paper.

Abstract

Training large language models (LLMs) with extended reasoning has enabled in-context search, in which models iteratively generate, critique, and revise solution attempts. We provide a theoretical analysis of in-context search by modeling it as approximate inference over reasoning traces, where the base model defines a prior and self-reflection provides feedback for posterior updates, and study the resulting inference-time sampling complexity - the number of sequential attempts needed to achieve high success probability.

Show full abstract

We show that when reflections reliably localize early mistakes, in-context search can yield exponential improvements over the base model, solving problems with exponentially small zero-shot pass rates using only a polynomial number of sequential attempts, whereas when this property fails, conditioning on past attempts offers no asymptotic benefit over parallel sampling. We further show that these gains are robust and learnable: approximate posterior updates suffice, and cross-entropy training on search rollouts recovers the required behavior with polynomial sample complexity. Finally, we show that under a stagewise abstraction of reinforcement learning with verifiable rewards, the optimal policy extension implements the same posterior reweighting rule. We validate key qualitative predictions of the theory on real large reasoning models.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{wolf2026when,
  title  = {When Does In-Context Search Help? A Sampling-Complexity Theory of Reflection-Driven Reasoning},
  author = {Yotam Wolf and Noam Wies and Amnon Shashua},
  year   = {2026},
  eprint = {2607.06720},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2607.06720v1}
}

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/2607.06720.svg)](https://codeofpaper.com/paper/2607.06720)

Discussion