Test-Time Adaptation of Reasoning Strategies with Bayesian Nonparametric Memory

Keshav Ramji, Tahira Naseem, Ramón Fernandez AstudilloarXiv 2026

TL;DR

The Bayesian Cheatsheet is a structured memory module that allows Large Language Models (LLMs) to learn and reuse reasoning strategies on the fly. By organizing self-reflected insights into clusters using a Hierarchical Dirichlet Process, it enables efficient test-time adaptation, significantly boosting performance on complex math and physics benchmarks without the need for expensive model retraining.

What Problem Does This Paper Address?

While Chain-of-Thought (CoT) prompting has revolutionized LLM reasoning, it comes with a high "generation tax"—models often wander down suboptimal paths before finding an answer. Furthermore, LLMs are typically "forgetful" at inference time; if a model discovers a clever strategy while solving Problem A, it has no native mechanism to carry that insight over to Problem B.

Existing "metacognitive" approaches try to solve this by having the model reflect on its work and store "behaviors" (concise reasoning strategies) in a memory bank. However, these banks are often "flat" (simple lists) or rely on rigid, pre-defined categories. As the memory grows, finding the right strategy becomes a needle-in-a-haystack problem. The authors identify a need for a memory structure that is hierarchical (sharing strategies across domains like math and physics), non-parametric (growing naturally with new data), and adaptive (reorganizing itself as the model learns).

Methods

The authors introduce the Bayesian Cheatsheet, which treats reasoning behaviors as data points in a latent embedding space.

  1. Hierarchical Dirichlet Process Gaussian Mixture Model (HDP-GMM): Instead of using standard k-means (which requires a fixed number of clusters), they use an HDP-GMM. This allows the number of strategy clusters to be determined by the data itself. The "hierarchical" part is crucial: it allows different domains to share the same underlying strategies (e.g., "check for symmetry") while maintaining domain-specific weights.
  2. Online Test-Time Adaptation (TTT): As the model solves new queries, it reflects and generates new behaviors. The system calculates a "novelty score" using the model's posterior predictive density.
  3. Low Novelty: The new behavior is softly added to existing clusters by updating their sufficient statistics.
  4. High Novelty: A new cluster is spawned to accommodate the unique strategy.
  5. Periodic Reorganization: To prevent the memory from becoming messy over time ("drift"), the system periodically performs a single step of collapsed Gibbs sampling. This allows behaviors to be re-assigned to better-fitting clusters in a statistically principled way.
Figure 1: Bayesian Cheatsheet learns a structured memory module offline and adapts it at test time. Left: behaviors are mined offline by an LLM solving problems and self-reflecting on its solutions; the extracted behaviors are embedded and clustered into shared components with domain-specific weights by fitting an HDP-GMM. Middle: at test time, a novelty score based on the HDP-GMM’s posterior predictive determines whether a new behavior updates existing components’ sufficient statistics (top) or spawns a new component and initializes its sufficient statistics (bottom). Right: evaluation on AIME’25 with Granite-4.2-30B shows that Bayesian Cheatsheet (BC-TTT) outperforms the compared adaptive memory mechanisms in the online setting.

Datasets

The authors evaluated their approach using two primary LLMs (Qwen3-32B and Granite-4.2-30B) across several reasoning-heavy benchmarks:

  • AIME’25: A highly challenging American Invitational Mathematics Examination subset.
  • Omni-MATH: A benchmark for Olympiad-level mathematics.
  • PhysReason: A dataset focused on complex physics-based reasoning.

For the initial "offline" memory, they mined behaviors from NuminaMath-CoT and Camel Physics.

Key Insights and Ideas

  • Structure is a Force Multiplier: Simply having a memory isn't enough. Clustering behaviors into abstract "components" significantly outperforms flat retrieval (like simple cosine similarity). It allows the model to retrieve types of strategies rather than just similar-looking text.
  • The "Rich-Get-Richer" Effect: The Bayesian prior naturally favors frequently successful strategies, making them easier to retrieve, while still leaving the door open for rare but vital niche strategies.
  • Cross-Domain Synergy: The hierarchical structure proves that math and physics aren't silos. A "dimensional analysis" strategy learned in a physics context can be successfully retrieved and applied to a relevant math problem.
  • Stability via Bayesianism: Unlike k-means, which can be erratic when new points are added, the Bayesian Cheatsheet is remarkably stable. The authors measured "churn" (how often behaviors change clusters) and found it was significantly lower than non-Bayesian baselines.

Key Results

The Bayesian Cheatsheet (BC-TTT) consistently outperformed existing memory-based adaptation methods like ACE and Dynamic Cheatsheet.

  • AIME'25 Performance: On the AIME'25 benchmark with the Granite-4.2-30B model, BC-TTT achieved 85.6% accuracy, a substantial jump over the 77.8% achieved by the next-best adaptive baseline (see the right-hand bar chart in Figure 1).
  • Cold-Start Success: Even when starting with a "blank slate" (no pre-mined memory), the system was able to build a useful cheatsheet on-the-fly, outperforming models with no memory at all.
  • Qualitative Clarity: The clusters formed by the HDP-GMM are human-interpretable. For example, the system successfully grouped behaviors under meta-labels like "Unit consistency & dimensional-analysis checks" and "Symmetry-based algebraic simplification."

Limitations and Future Work

  • Long-term Scaling: While the sufficient statistics updates are "cheap," the cost of retrieval and periodic refitting will eventually grow as the memory becomes massive. The authors suggest that future work should include "forgetting" mechanisms to prune less useful behaviors.
  • Single-Turn Focus: The current work focuses on single-turn problem solving. Extending this to multi-turn agentic workflows, where a model might query its memory multiple times during a single task, is a promising next step.
  • Projector Dependency: The system relies on a small learned projector ($f_\theta$) to map raw queries into the behavior embedding space, which adds a minor layer of training overhead compared to purely zero-shot methods.

Summary updated

BibTeX
@misc{ramji2026test,
  author = {Keshav Ramji and Tahira Naseem and Ramón Fernandez Astudillo},
  title = {{Test-Time Adaptation of Reasoning Strategies with Bayesian Nonparametric Memory}},
  year = {2026},
  eprint = {2610.06516},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.06516},
}
Figure