Manuscript Offprint

arXiv:2610.06516

Test-Time Adaptation of Reasoning Strategies with Bayesian Nonparametric Memory

Keshav Ramji, Tahira Naseem, Ramón Fernandez Astudillo

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

ABSTRACT

While modern large language models (LLMs) have been trained to reason through verbalized chains-of-thought, the generation cost grows substantially due to suboptimal paths to reach the final answer. Furthermore, as new insights are discovered while observing various input queries (e.g. through self-reflection), limited mechanisms exist for carrying forward these findings to be applied to subsequent problems. One can view the list of such strategies or behaviors as a growing cheatsheet, with elements retrieved from this memory module at inference-time. In this work, we consider structured cheatsheets, with learned clusters of behaviors. We introduce a Hierarchical Dirichlet Process Gaussian Mixture Model (HDP-GMM) over behavior embeddings, which shares components across domains while allowing domain-specific mixing weights, and uses the posterior predictive to retrieve relevant behaviors for a query; we call this a Bayesian Cheatsheet. This mechanism allows for cheap adaptation in an online test-time training (TTT) setting, softly updating the mixture's sufficient statistics following each sample and enabling the creation of new components when the synthesized behaviors are sufficiently novel. We demonstrate that Bayesian Cheatsheet achieves clear performance gains relative to existing memory modules across reasoning benchmarks such as AIME'25, Omni-MATH, and PhysReason, even in the cold-start setting. We show that the Bayesian Cheatsheet is an adaptively reorganizing memory module, as behaviors can be re-assigned to components through a single step of collapsed Gibbs sampling. Our findings highlight the value of Bayesian-inspired memory modules for effective test-time adaptation and the role of structure in metacognitive reasoning.

Offline: Fit Memory Module

Figure

Online: Efficient Test-time Adaptation

AIME'25 performance

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.

*Correspondence to keshav.ramji@ibm.com

1 INTRODUCTION

Large language models increasingly solve complex problems by generating verbalized intermediate reasoning steps (Wei et al., 2022; Nye et al., 2021). Given that related problems can often be solved with similar strategies, storing such strategies, which we call behaviors, can improve reasoning efficiency in solving future problems — that is, they do not need to be rediscovered. This is a key premise of metacognitive reasoning (Shinn et al., 2023; Didolkar et al., 2024; 2025), where reflecting on reasoning to extract generalizable lessons and using those lessons to guide subsequent attempts have been shown to be effective. At the same time, this begs the question: how can we design systems to optimally retain and retrieve useful abstractions for LLM reasoning and decision-making?

Recent methods accumulate and revise reasoning behaviors, reflections, and procedural guidance over time (Didolkar et al., 2025; Suzgun et al., 2026; Zhang et al., 2026b; Ouyang et al., 2026). As memory grows, context limits and costs make it desirable to maintain an external, structured memory with selective reuse to avoid context explosion. Existing structured memory systems (Xu et al., 2025; Chhikara et al., 2025) often rely on LLM judgments and similarity-based heuristics to define and evolve the memory structure; this organization can become difficult to maintain as the memory grows.

In this work, we use the term cheatsheet to refer to a general abstraction: it is a collection of concise, natural-language insights that can be consulted while solving a new problem. A cheatsheet induces two key design questions: 1) what type of information should be stored? and 2) how should it be organized for effective reuse and continual adaptation? In this work, we focus on the latter, while for the former, we simply use short reasoning behaviors generated through self-reflection to form the memory content. This allows for a clear comparison of memory organization mechanisms without the confounding effect of differences in the memory content. As a cheatsheet grows, its organization must support more than the retrieval of similar entries — related behaviors may form groups, which may also be reusable across domains. New experiences encountered at test-time may reinforce the contents of an existing group, or reveal a strategy that is not captured under the current organization. However, static cheatsheets, as well as flat similarity-based retrieval, do not address this, and while clustering provides additional organization for reuse, it does not facilitate principled growth and requires the number of clusters to be known in advance.

We introduce the Bayesian Cheatsheet, a structured memory module based on a Hierarchical Dirichlet Process Gaussian Mixture Model (HDP-GMM) (Rasmussen, 2000; Teh et al., 2006) over behavior embeddings. The HDP-GMM formulation, as a non-parametric unbounded clustering mechanism, offers a few benefits that are particularly desirable for test-time memory management: 1) the number of clusters is purely driven by the data seen thus far, 2) the hierarchical structure offers a flexible mechanism to distinguish generally usable memories from domain-specific ones, and 3) the posterior probabilities of cluster assignment serve a dual purpose, in assigning memories to clusters as well as input-conditioned retrieval. The HDP prior additionally induces a rich-get-richer bias – memory components repeatedly observed in experience become more likely to be used in the future, while new components may still be created.

Our Bayesian Cheatsheet memory learns globally shared components (clusters) of behaviors, allowing for probabilistically latent assignment. At inference time, it predicts the query's domain and retrieves behaviors from components to add to the language model's context. In an online test-time training setting with streaming samples, Bayesian Cheatsheet cheaply incorporates newly mined behaviors into the memory through additive sufficient statistics, while also permitting the creation of new components for samples where the behaviors are sufficiently novel. Bayesian Cheatsheet also allows the memory to periodically reorganize itself as its contents evolve without requiring a refitting step every sample. As a result, this mechanism supports lightweight continual adaptation in a statistically-informed, training-free manner through principled changes to an external memory module.

References (97)