MemFold: Learning Compact Soft Memory for Long-Context Personalization via On-Policy Optimization

Jingxuan Wu, Yuzhe Yang, Yiqiao Huang, Chengzhi Liu, Qingni Wang, Chengxuan Qian, Shutong Wu, Jiawei Zhang, Xin Eric WangarXiv 2026

TL;DR

MemFold is a novel framework for long-context personalization that compresses user history into a fixed-budget "soft memory" of latent vectors. By optimizing this memory through on-policy reinforcement learning and a unique confidence-gated distillation process, it ensures the model doesn't just "remember" text, but actually uses that information to drive correct behavior, outperforming full-text baselines on contexts up to 128K tokens.

What Problem Does This Paper Address?

As AI assistants serve users over longer periods, they must navigate evolving preferences, revised constraints, and complex histories. Current approaches generally fall into two camps:

  1. Textual Memory: Keeping the entire history as text. This is accurate but causes the input length to explode, increasing latency and cost.
  2. Latent Memory: Compressing history into fixed-size vectors. While efficient, these are typically trained to reconstruct the original text or imitate reference answers.

The authors argue there is a gap between retaining information and acting on it. A model might be able to reconstruct a sentence about a user's dislike for wearable tech but still recommend an Apple Watch because the compression didn't preserve the "behavioral signal" needed for the task. MemFold addresses this by optimizing the memory interface directly based on the downstream behavior it supports.

Methods

MemFold consists of a memory writer, a compressor, and a reader, optimized through a three-stage on-policy pipeline:

  1. Fixed-Budget Soft Memory: A query-conditioned textual memory is first extracted from the history. A Perceiver-style compressor then maps this text into $K$ continuous "soft memory" vectors. This keeps the reader's interface size constant, regardless of how long the history is.
  2. On-Policy Rollout: The student model (the reader) generates responses based on the query and these $K$ soft memory tokens.
  3. On-Policy Distillation (OPD): This is the "secret sauce." A frozen "teacher" model—which has access to the full, uncompressed textual memory—scores the student's generated tokens.
  4. Confidence-Gated Optimization: The authors introduce a token-level confidence gate. If the teacher is significantly more confident in a token than the student, that token receives a higher weight in the update. This provides a dense, per-token signal that complements the sparse, sequence-level task reward.
Figure 2: ❶On-policy rollout: The student generates responses conditioned on the query and K com- pressed soft memory tokens. ❷On-policy distillation: A frozen textual-memory teacher scores the student’s tokens, and a detached teacher–student confidence gate ¯gi,t weights the student’s own tokens. ❸ Policy optimization: GRPO task rewards and the gated distillation term jointly update the student, while the teacher and compressor remain frozen.

The final objective combines Group Relative Policy Optimization (GRPO) for task-level rewards with the OPD loss for fine-grained behavioral alignment.

Datasets

The authors evaluated MemFold across several challenging benchmarks:

  • PersonaMem-32K & 128K: Benchmarks for tracking dynamic user preferences over long conversational histories.
  • PrefEval: Used to test cross-dataset generalization of implicit persona recognition.
  • LoCoMo & LongMemEval: Used to assess long-term memory reasoning, including multi-session logic and knowledge updates.

Key Insights and Ideas

  • Behavior-Centric Compression: The most important finding is that optimizing for task performance (how the model acts) is more effective for personalization than optimizing for reconstruction (how well the model remembers the words).
  • The Power of the Gate: The confidence gate prevents the teacher from being an "accuracy oracle." It only pulls the student toward the teacher's distribution when the student is clearly under-performing due to compression. If the teacher is also uncertain, the gate approaches zero, preventing noisy updates.
  • Scaling to the Extreme: While many models see performance degrade as context grows (the "lost in the middle" phenomenon), MemFold's performance gap over baselines actually widens at 128K tokens. The fixed-budget interface helps the model stay focused on relevant signals.
  • Sample Efficiency: Because OPD reuses the student's own rollouts and doesn't require additional autoregressive decoding from the teacher, it is highly sample-efficient.
Figure 1: Using Qwen2.5-3B-Instruct on PersonaMem-32K, MemFold improves test accuracy more rapidly during training and achieves higher final performance than the baselines (left), while reaching comparable test accuracy with fewer student rollouts (right), demonstrating both effective optimization and greater sample efficiency. Experimental settings are provided in Appendix B.1.

Key Results

  • State-of-the-Art Performance: MemFold achieved the highest accuracy across three different Qwen backbones (2.5-3B, 2.5-7B, and Qwen3-4B) on both PersonaMem variants.
  • Robust Generalization: Without any target-domain training, MemFold transferred successfully to PrefEval and LongMemEval, significantly outperforming other latent-memory methods like xRAG and MemGen.
  • Memory Dependency: Through "shuffled" and "null" memory interventions, the authors proved the model isn't just relying on task priors; it is actively and specifically using the content stored in its $K$ soft vectors to make decisions.

Limitations and Future Work

  • Initial Extraction Dependency: The memory writer is currently initialized using memories extracted by a stronger external model (GLM-5.2). While not needed at inference, the system's quality is currently tethered to this initial supervision.
  • Backbone Scaling: The experiments were limited to models up to 7B parameters. Testing whether these gains hold for 70B+ parameter models remains an open question.
  • First-Pass Cost: While the soft memory makes the reader efficient, the system still needs to process the full history once to build the textual memory. Reducing this initial overhead is a potential area for future research.

Summary updated

BibTeX
@misc{wu2026memfold,
  author = {Jingxuan Wu and Yuzhe Yang and Yiqiao Huang and Chengzhi Liu and Qingni Wang and Chengxuan Qian and Shutong Wu and Jiawei Zhang and Xin Eric Wang},
  title = {{MemFold: Learning Compact Soft Memory for Long-Context Personalization via On-Policy Optimization}},
  year = {2026},
  eprint = {2609.36435},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2609.36435},
}
Figure