MILES: Modular Instruction Memory with Learnable Selection for Self-Improving LLM Reasoning

Ruilin Tong, Dong GongNeurIPS 2026

TL;DR

When solving tough math or science problems at test time, most Large Language Models (LLMs) suffer from a kind of groundhog-day amnesia—treating every new query in complete isolation. MILES equips frozen LLMs with an evolving, step-by-step memory bank that learns what reasoning tactics work and when to use them on the fly, using the model’s own confidence on easier problems to guide it through harder ones. No model fine-tuning or human-labeled training data required.

What Problem Does This Paper Address?

Scaling up test-time compute—letting an LLM "think longer" via Chain-of-Thought or tree search—has become a reliable way to boost reasoning. Yet, when problems arrive sequentially in the real world, models usually start from scratch every single time. Updating the LLM's actual weights on the fly is expensive or downright impossible for closed-source APIs, making an external "notepad" (memory) the natural alternative.

However, existing memory methods hit two major snags:

  1. Whole-solution templates save entire problem strategies, which fail to generalize when a new problem requires a novel combination of steps.
  2. Step-level memories break reasoning into smaller, reusable Lego blocks, which is much more flexible. Yet, deciding which block to grab next usually relies on simple semantic similarity ("this looks like that") rather than whether that block actually leads to the right final answer. Furthermore, standard reinforcement learning can't easily learn a selection policy here because the memory bank is constantly growing and there are no ground-truth answer keys at test time.

Methods

MILES (Modular Instruction Memory with LEarnable Selection) turns step-by-step memory retrieval into a learned decision process while keeping the base LLM completely frozen.

Figure 1: Overview of MILES. MILES improves test-time reasoning by constructing memory and learning memory selection from confident samples, then applying the learned memory to guide reasoning on uncertain samples.

Here is what happens under the hood as a stream of test questions arrives:

  • Confidence-Based Routing: For each new problem, the LLM generates several independent answers. If they agree (high confidence), the majority answer becomes a "pseudo-label," and MILES enters Write Mode. If the model is torn (uncertain), it enters Read Mode.
  • Asymmetric Modular Memory: Instead of saving raw text traces, MILES clusters successful steps from Monte Carlo Tree Search (MCTS) rollouts on confident samples into modular pairs: a sub-goal embedding (a vector representing what the next step aims to achieve) and a sub-instruction (natural-language guidance for the LLM).
  • Per-Unit Learnable Heads: Crucially, every memory unit gets its own tiny, independent binary classifier (an ensemble of 3-layer MLPs). Trained on MCTS outcomes, this head predicts whether applying this specific instruction in the current context will actually lead to a correct final answer. Because each unit has its own one-vs-rest classifier, new memories can be added anytime without retraining old ones!
  • Coarse-to-Fine Retrieval (Read Mode): On uncertain problems, MILES runs a memory-guided tree search using two stages. Layer 1 (Coarse) uses fast cosine similarity on sub-goal embeddings to fetch semantically relevant candidates. Layer 2 (Fine) uses the learned selection heads to rerank those candidates based on historical success, blending relevance with battle-tested utility.

Datasets

No new benchmarks are introduced. The authors evaluate MILES sequentially at test time across six existing, challenging reasoning benchmarks:

  • Competition Math: MATH-500, AIME 2024, and AIME 2025.
  • Graduate-Level Science & Engineering: GPQA-Diamond, plus 200-sample subsets of MMLU-Pro Physics and MMLU-Pro Engineering.
  • (Offline Transfer Setting): AIME 2020–2024 and non-Diamond GPQA splits are used to pre-build memory when testing offline supervision.

Key Insights and Ideas

  • Semantic relevance $\neq$ problem-solving utility: Ablation studies show that picking instructions by similarity alone—or even asking the LLM itself to rerank candidates—falls short. An instruction can look topically relevant to the current state while still steering the math off a cliff. Combining coarse semantic filtering with outcome-trained classifiers drives a massive jump in step-level accuracy.
  • Cross-model "brain transplants" work: Because the sub-instructions are stored as plain text, you don't need an expensive model to build the memory. Smaller open-weight models (like Qwen3-4B or 30B) can do the heavy MCTS lifting to build the memory bank, which a stronger frozen model (like GPT-4.1-mini) can then read to boost its own accuracy.
  • Compute breaks past the plateau: Standard memoryless search methods (like Self-Consistency or Tree-of-Thought) quickly hit a ceiling as you throw more tokens at a problem. MILES continues to scale upward with extra compute because those extra tokens build a richer, broader memory bank that pays dividends on future questions.
Figure 2: Accuracy vs. response-token cost on AIME 2024 and AIME 2025 with GPT-4.1-mini, comparing MILES with test-time scaling and memory-based baselines. MILES reaches the highest accuracy on AIME 2024 and ties the strongest baseline, DC, on AIME 2025.

Key Results

Tested across four frozen backbones (GPT-4.1, GPT-4.1-mini, GPT-OSS-20B, and Qwen3-30B-Instruct), MILES consistently matches or beats both memoryless baselines and recent memory frameworks (like Dynamic CheatSheet and ReasoningBank).

  • Math: On MATH-500, MILES pushes GPT-4.1-mini to 92.27% accuracy (up from 89.20% with Self-Consistency). On AIME 2025 with Qwen3-30B-Instruct, it hits 72.66% (beating Self-Consistency at 66.67% and ReasoningBank at 65.33%).
  • Science/Engineering: On GPQA-Diamond with GPT-OSS-20B, MILES reaches 74.58% (vs. 71.05% for Self-Consistency).
  • Offline Pre-building: When pre-building memory on past AIME exams (2020–2024) and testing on the hardest, most uncertain AIME 2025 questions, GPT-4.1-mini’s accuracy doubles from 18.46% (no memory) to 36.92%.

Limitations and Future Work

  • Domain & Order Assumptions: MILES assumes incoming problems share underlying reasoning structures. Under tight rollout budgets, seeing easy problems before hard ones helps considerably—though increasing MCTS rollouts from 20 to 40 per confident sample makes the system largely order-insensitive.
  • The Overconfidence Trap: Test-time learning relies on majority voting for pseudo-labels. If a weak backbone is confidently wrong on a super-hard benchmark, it could poison its own memory with bad supervision.
  • Rollout Overhead: Running MCTS to build memory costs extra tokens, though offloading this to cheap auxiliary models helps. Future directions include letting the system self-refine the text of its stored instructions and organizing the flat memory into hierarchies for faster search.

Summary updated

Abstract

Large language models (LLMs) increasingly improve their reasoning at test time via additional computation, yet most existing works treat each problem in isolation. When problems arrive sequentially, accumulating reusable experience across them can further improve performance. Existing memory-based methods either store whole-solution templates that generalize poorly to novel problems or use heuristic step-level selection that is not optimized for final-answer correctness. Learning selection policies requires large-scale training data and fixed action spaces, making such approaches unsuitable for test-time settings where memory expands incrementally and only limited supervision is available. We propose **MILES** (**M**odular **I**nstruction Memory with **LE**arnable **S**election), a framework that dynamically expands step-wise memory and applies correctness-optimized memory composition under realistic test-time constraints. MILES maintains modular memory units consisting of asymmetric pairs of sub-goal embeddings and sub-instructions, each associated with a learnable selection head. This memory structure enables a coarse-to-fine retrieval mechanism: The coarse level enables memory expansion and collects supervision for training selection heads from confident samples, while the fine stage applies learned selection heads to rerank coarse-level candidates and guide reasoning for uncertain samples. MILES achieves self-improvement by using its own confidence as the learning signal at test time, or given feedback such as labeled data in an offline setting. MILES consistently matches or outperforms prior methods while achieving superior accuracy–efficiency tradeoffs. Extensive experiments demonstrate its effectiveness, robustness, and transferability. Code and resources are available at https://artificer-ai-lab.github.io/MILES.
BibTeX
@inproceedings{tong2026miles,
  author = {Ruilin Tong and Dong Gong},
  title = {{MILES: Modular Instruction Memory with Learnable Selection for Self-Improving LLM Reasoning}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=94TqZuHU8A},
}
Figure