TL;DR
MoLEM (Mixture of Latent Memories) is a novel framework that allows large language model (LLM) agents to continually learn new domains without suffering from catastrophic forgetting. By keeping the base LLM frozen and dynamically recruiting domain-specific groups of latent memory experts routed via a task-ID-free autoencoder ensemble, MoLEM achieves a 10.40% accuracy boost over vanilla baselines while maintaining zero forgetting.
What Problem Does This Paper Address?
For an intelligent agent to truly "self-evolve," it must continuously accumulate new knowledge across a sequence of diverse tasks without erasing its previously acquired abilities.
Current approaches to this problem fall into two flawed categories:
- Parametric Memory (Fine-tuning): Modifying the model's core parameters directly to learn new tasks. This inevitably triggers catastrophic forgetting, where learning a new skill (like coding) severely degrades a previously learned skill (like mathematics).
- Retrieval-Based Memory: Storing experiences in external databases and fetching them at inference time. While this avoids forgetting, it amounts to mere context engineering; the model's intrinsic capabilities are never actually enhanced.
Recent "latent memory" methods attempt to bridge this gap by using continuous vectors as high-density internal memory carriers. However, they rely on static architectures that overwrite previous behaviors when reused across shifting task sequences. The authors of this paper introduce MoLEM to provide a flexible, extensible cognitive architecture that dynamically expands capacity while completely isolating learned skills.
Methods
MoLEM introduces a generative latent memory framework built on a dynamic Mixture-of-Experts (MoE) architecture. The framework operates via two main phases:
1. Stage-wise Evolutionary Training
The core reasoning LLM remains entirely frozen throughout the process. When the agent encounters a new domain (e.g., transitioning from Math to Science), it executes a Stage-wise Recruiting strategy:
- It freezes all previously trained memory modules.
- It recruits a fresh group of parameter-isolated LoRA adapters (the experts) and a corresponding domain router.
- It trains only this new group using Supervised Fine-Tuning (SFT) combined with a Switch-style load-balance loss to ensure expert diversity.
2. Domain-Aware Inference & Latent Memory Injection
At inference time, the agent operates without explicit task labels (task-ID-agnostic). To determine which memory group to activate, each training stage is paired with a lightweight Autoencoder (AE) trained to reconstruct the prompt-end hidden states of the frozen LLM.
The inference pipeline proceeds as follows:
- The input query is passed through the frozen LLM to extract its prompt-end feature vector.
- This vector is fed into the ensemble of stage-wise autoencoders.
- The routing group associated with the AE yielding the smallest reconstruction error is selected.
- If the reconstruction errors for all AEs exceed a calibrated threshold, the input is flagged as Out-of-Distribution (OOD), and the system safely falls back to the vanilla pretrained model.
- The selected router uses key-query matching (cosine similarity) to weight and aggregate the latent memories generated by individual experts, injecting the final representation back into the reasoning process.
Datasets
The authors evaluated MoLEM on a multi-stage continual learning sequence spanning three distinct domains:
- Math: Mathematical reasoning questions drawn from Nemotron MATH.
- Science: Multiple-choice scientific questions drawn from Nemotron Science.
- Code: Code-generation problems drawn from KodCode.
The framework was tested across different sequential permutations (e.g., Math $\rightarrow$ Science $\rightarrow$ Code) to ensure stability against task-ordering variations.
Key Insights and Ideas
- Inherent Discriminability of LLM Hidden States: Rather than training a complex, joint domain classifier, MoLEM leverages the fact that a pretrained LLM naturally clusters different domains within its internal representation space. A simple ensemble of independent, lightweight autoencoders is sufficient to accurately route inputs based purely on reconstruction error.
- Spontaneous Expert Diversity: Even though the roles of individual experts within a domain pool are not manually defined, the combination of key-query routing and load-balancing losses forces the experts to specialize in distinct sub-features of the input domain.
- OOD Protection via Fallback: By allowing unfamiliar inputs to bypass the memory modules entirely, MoLEM ensures that the agent's baseline general-purpose competence is never corrupted by irrelevant or harmful expert memories.
Key Results
MoLEM demonstrates a clear advantage over standard fine-tuning and alternative memory baselines after completing the full training sequence (Math $\rightarrow$ Science $\rightarrow$ Code):
- Superior Accuracy: MoLEM achieved a final average accuracy of 73.93% across all test sets, outperforming the Vanilla baseline (63.53%), standard SFT (34.40%), and the latent-memory baseline MemGen (63.47%).
- Zero Catastrophic Forgetting: While standard SFT's performance on the Math test set collapsed from 57.20% at Stage 1 down to 12.80% at Stage 3 due to parameter overwriting, MoLEM maintained a strict 0.00% forgetting rate across all stages.
- Order Invariance: The performance gains remained highly consistent regardless of the training order (e.g., Code $\rightarrow$ Science $\rightarrow$ Math), proving that the framework effectively isolates cross-domain parameter interference.
Limitations and Future Work
The primary limitation acknowledged by the authors is parameter overhead. Because each new domain requires recruiting a new set of experts, routers, and autoencoders, the total parameter count scales linearly with the number of training stages.
Although these modules utilize parameter-efficient fine-tuning (PEFT) and remain compact relative to the frozen backbone, scaling the system to dozens or hundreds of highly granular tasks will eventually demand more sophisticated expert-pruning, consolidation, or sharing mechanisms.
Summary updated