TL;DR
Giving Large Language Models (LLMs) a memory usually means choosing between stuffing raw text into the prompt (flexible, but bloated and distracting) or fine-tuning knowledge into the weights (deep, but rigid and prone to overfitting). MemPilot introduces a decoupled "latent memory" middle ground: it compresses past reasoning experiences into compact vector banks and teaches a frozen LLM how to read them. Because the memory content is separated from the skill of using memory, you can adapt the model to an entirely new domain in seconds just by swapping out the memory bank—zero retraining required.
What Problem Does This Paper Address?
For LLM agents to solve multi-step problems, they need to learn from past successes and failures. Historically, we’ve handled this in two ways:
- Explicit text memory (like RAG): Store past reasoning traces as text and paste them into the prompt. It’s easy to edit, but long trajectories blow up inference costs and create "lexical traps"—where a retrieved example looks superficially similar to the current problem, distracting the model onto the wrong reasoning path.
- Parametric memory (like fine-tuning): Bake past experiences directly into the model’s weights. This guides internal reasoning deeply without prompt bloat, but updating it requires expensive retraining. Worse, it tangles domain-specific quirks with general reasoning, causing catastrophic forgetting or negative transfer on new tasks.
Recent "latent memory" methods try to store compressed continuous vectors externally, but they usually train the memory encoder and the LLM end-to-end. As a result, the system overfits to task-specific shortcuts rather than learning a universal way to read memory. The authors ask: Can we teach a frozen LLM a general, reusable skill for consulting external latent memories, keeping the memories themselves completely swappable?
Methods
MemPilot splits memory-augmented reasoning into two strictly decoupled phases while keeping the base LLM reasoner completely frozen:
- Offline Memory Construction: A separate memory encoder (initialized from the base LLM and lightly tuned via LoRA using a contrastive retrieval loss—never the downstream generation loss) compresses full text reasoning trajectories into a tiny sequence of continuous vectors (defaulting to $S=8$ latent tokens per trajectory). Each entry is stored in an external bank alongside a pooled summary vector acting as a retrieval key.
- Coarse-to-Fine Retrieval & Gated Fusion: At inference time, right before the frozen LLM's final language-modeling head, MemPilot pools the query's hidden states to fetch the top-$K$ ($K=4$) relevant memory entries. A lightweight cross-attention module then lets the LLM’s active hidden states "read" the fine-grained latent tokens. Crucially, before adding this signal into the LLM's residual stream, it passes through a learned gating mechanism—a dynamic filter that dials down the external memory if it doesn't match the current reasoning step.
To deploy on a brand-new domain, you freeze everything, run the new domain's trajectories through the encoder to build a fresh memory bank, and plug it in.
Datasets
The authors evaluate MemPilot across five established benchmarks spanning three distinct reasoning modalities (no new datasets are introduced):
- Mathematical Reasoning: GSM8K and MATH.
- Question Answering: HotpotQA and TriviaQA.
- Executable Code Synthesis: KodCode.
Key Insights and Ideas
- Coupled memory causes severe negative transfer: When existing latent/parametric methods (like MemGen) are trained on HotpotQA and tested out-of-domain on MATH, accuracy collapses from a 36.63% vanilla baseline down to 2.14%. Decoupling the memory bank prevents the model from memorizing source-domain habits.
- The gate acts as an out-of-domain immune system: Why doesn't MemPilot break on unfamiliar tasks? When given mismatched memories, the learned gate automatically suppresses them.
- Base LLMs naturally cluster reasoning modalities: Even without LoRA-tuning the memory encoder, MemPilot scores huge gains (jumping from 24.5% to 53.3% on KodCode). A t-SNE visualization reveals that frozen LLMs naturally organize math, code, and QA trajectories into cleanly separated latent clusters.
- Procedural affinity matters: Cross-domain transfer works best when underlying logic aligns—for instance, a memory reader trained on algorithmic coding (KodCode) transfers remarkably well to formal math (GSM8K), suggesting MemPilot genuinely learns to extract procedural structure rather than surface facts.
Key Results
Tested on Qwen2.5-1.5B-Instruct and Qwen3-8B, MemPilot achieves the highest overall in-domain accuracy (58.06% and 77.06%, respectively), beating SFT, text-retrieval (ExpeL, MemoryBank), and latent baselines (SoftCoT, MemGen).
- Zero-Update Transfer: Trained solely on KodCode (1.5B backbone) and handed a GSM8K memory bank, MemPilot hits 63.01% on GSM8K—beating the vanilla model (56.79%), MemGen (33.87%), and SFT (8.12%) without a single parameter update. Across 12 cross-domain pairs, MemPilot averages 43.96%, outperforming target-domain text RAG baselines like MemoryBank (42.92%).
- Speed & Adaptation Efficiency: On KodCode, MemPilot runs 5.2x faster than text RAG (1.12s vs. 5.87s per example) by avoiding ~2,000 tokens of prompt bloat, and even runs faster than the vanilla model (3.51s) because latent guidance helps it generate more concise solutions. Adapting to a new domain takes just 45 seconds to encode a new bank, compared to 2.1–2.5 hours of retraining for SFT or MemGen.
Limitations and Future Work
While the authors do not include a dedicated limitations section, they explicitly note a boundary in cross-domain transfer: gains depend on the structural affinity between source and target reasoning modalities. When transferring from multi-hop QA (HotpotQA) to advanced competition math (MATH), improvements become much more modest—though the gating mechanism still prevents the catastrophic collapse seen in fine-tuned baselines. Furthermore, in the current setup, retrieval is triggered only once at the start of generation rather than dynamically re-querying mid-thought, leaving room for more adaptive multi-step retrieval in future iterations.
Summary updated