Manuscript Offprint

arXiv:2610.17734

Explore with Memory, Learn without It: In-Context Exploration and Self-Distillation for LLM Reasoning

Yutong Chen, Zhichao Xu, Rui Liu, Kunpeng Liu

Abstract

Exploration bounds learning efficiency in reinforcement learning with verifiable rewards (RLVR). Current methods explore mostly through independent sampling, without fully using the information gathered along the way, such as known wrong answers and environment feedback. We propose LEAF, which injects a dynamic, problem-specific memory into the context before every rollout. The memory contains the most recent response, its reward, and other environment feedback. It is updated after every verifier call. We decouple policy updates from rollouts and update the policy through self-distillation. On four benchmarks and two open models, LEAF accelerates exploration by about 4×4\times compared with a random sampling baseline. On unseen test sets, it improves accuracy over the strongest baseline by 1.59 and 1.83 percentage points on the two models, while using less compute than any RL baseline. These results highlight the potential of LEAF in improving both exploration and learning efficiency.

Code is available at: https://github.com/on1262/LEAF.

1 Introduction

Reinforcement learning with verifiable rewards (RLVR) has become the main recipe for improving the reasoning and coding abilities of large language models (LLMs) (Shao et al., 2024; Guo et al., 2025; Yu et al., 2025; Zheng et al., 2025; Gao et al., 2025). It maximizes the expected reward, which must be estimated at each rollout step. Since this expectation cannot be computed exactly, most RLVR methods estimate it with Monte Carlo methods (Metropolis and Ulam, 1949), which require sampling several responses independently for each prompt.

In general RL, estimating advantages from rewards is challenging. Group-based methods compute advantages using a group of independent responses to the same prompt (Shao et al., 2024; Yu et al., 2025; Zheng et al., 2025). A larger group yields more accurate estimates but reduces rollout efficiency. Single-rollout methods such as PPO use a value function (Schulman et al., 2017). However, this requires a critic network. Learning an accurate critic is also challenging when training LLMs (Shao et al., 2024; Kazemnejad et al., 2025).

Research on iterative refinement investigates how to improve later responses using earlier attempts. Kumar et al. (2025) and Ekbote et al. (2025) use multi-turn reinforcement learning to train revision behavior, including intrinsic self-correction and refinement guided by execution feedback. Some methods learn from feedback and transfer knowledge into parameters. Song et al. (2026b) learns from feedback through self-distillation or feedback modeling. Shi et al. (2026) uses reinforcement learning combined with self-distillation.

Self-distillation methods (Hübotter et al., 2026; Zhao et al., 2026; He et al., 2026; Liu et al., 2026a; Wang et al., 2026; Jiang et al., 2026; Wu et al., 2026b) use the same model with privileged context, such as feedback, memories, or skills, as the teacher for an unconditioned student. Although self-distillation does not require duplicated responses, model behavior changes only during the policy update phase, without fully leveraging the model's in-context learning ability. Methods such as those proposed by Dilkes et al. (2026) and Liu et al. (2026b) change exploration behavior using a fixed instruction or a self-generated tip. However, they still use duplicated group sampling. As Fig. 1 shows, our method is the only one of these designs that combines rich feedback, inference adaptation and a single rollout per step.

In our experiments, independent sampling tends to fail with the same wrong answer. For example,

∗^{*}Corresponding author.

Random samplingSDPOSCoReRLVROurs
Rich feedback✕✓✕✕✓
Inference adaptation✕✕✓✕✓
Single rollout✓✕✕✕✓

Figure 1: Properties of exploration methods as evaluated here. Rich feedback: uses textual feedback such as test output, not only the scalar reward. Inference adaptation: the rollout context changes with earlier attempts on the same problem, without a parameter update. Single rollout: one verified answer per problem per step.

with random sampling on MBPP+, 77.3% (Qwen3-8B) and 78.0% (Olmo-3-7B-Instruct) of the failed samples reproduce exactly the failing test output of an earlier sample for the same problem, and on MATH-500 47% of the wrong answers repeat an earlier wrong answer. When the previous answer is in the context, adding its feedback significantly reduces the rate of repeating that wrong answer, from 62.8% to 35.9% on average over MATH-500, LCB and MBPP+ and the two models. Refer to Appendix A for details.

Motivated by the strong effect of in-context learning, this work asks whether exploration can be improved by changing the context of each rollout. As illustrated by Fig. 2, our method keeps a memory for each problem that contains the last response, its reward and its environment feedback. During rollout, each problem only generates one sample per step. We update the memory based on previous attempts on the same problem. The memory is written into the rollout context as a short dialogue, so each new attempt revises the previous one, as the in-context refinement (Shinn et al., 2023; Madaan et al., 2023). During the policy update, the policy conditioned on the memory serves as the teacher, and self-distillation (Agarwal et al., 2024; Snell et al., 2022; Zhao et al., 2026) moves what the memory provides into the parameters. We name it LEAF, short for Learning from Earlier Attempts and Feedback, because each new attempt learns from the previous attempt and the feedback on it in context, and the policy update then learns from these attempts in its parameters.

We evaluate LEAF on four benchmarks, MATH-500 (mathematics), LiveCodeBench and MBPP+ (code generation) and SciKnowEval (science), with Qwen3-8B and Olmo-3-7B-Instruct. In exploration tasks, LEAF raises the cumulative pass rate over Random Sampling by 4.88 pp on average and reaches the final pass rate of Random Sampling with four times fewer verifier calls. In generalization tasks on unseen test sets, LEAF has the highest overall test accuracy, which is 1.59 pp (Qwen3-8B) and 1.83 pp (Olmo-3-7B-Instruct) above the strongest baseline. We perform ablation studies on key components such as the feedback, the last response and the restart schedule. Results show that removing any of them lowers the final pass rate on both models.

Figure

Figure 2: Overview of LEAF. Rollout: each problem keeps a memory of its last response, reward and feedback, which forms the context of the next attempt. The memory is updated after each trial. Policy update: after all rollout steps are finished, the teacher conditioned on a successful context teaches the student without context through self-distillation.

References (98)