Memorilla 用 16 个记忆 token 替代长上下文

原标题:Memorilla: Latent Semantic Memory for LLMs
74AI 研判分

Memorilla 提出一种面向冻结 LLM 的潜空间语义记忆系统:先将文档一次性编码为可复用嵌入,再学习把与查询相关的信息写入模型输入嵌入空间的固定数量“记忆 token”。仅用 16 个记忆 token,它在个性化、长文档与知识密集问答等 8 个基准中的 5 个上优于 Mem0、MemoRAG 等基线;在 FactKG 上以约 1/108 的 token 量取得 84.33% 准确率,高于全上下文推理的 80.43%。

报道正文

Abstract:Memory enables large language models (LLMs) to use information beyond their parameters, such as past user conversations, long documents, or an agent's earlier actions. For a frozen LLM, access to this accumulated knowledge is limited to what a memory system places in its context window. However, gathering and combining relevant information needed for each query while keeping the model's context short remains challenging for existing systems. Here we introduce Memorilla, a memory system that gathers information from an entire document collection into a fixed number of query-dependent 'memory tokens' for a frozen LLM. Memorilla encodes documents (such as user chats, book chapters) once into reusable embeddings, then learns to retrieve and place query-specific information in the LLM's input embedding space. Using only 16 memory tokens, Memorilla achieves the best performance against baselines including Mem0 and MemoRAG on five of eight benchmarks spanning personalization, long-document and knowledge-intensive question answering. Notably, on FactKG, it reaches 84.33% accuracy versus 80.43% with full-context inference, while using 108x fewer tokens to represent the source documents. Furthermore, Memorilla can facilitate continual learning in agentic systems where the document count (the agent's past turns) increases throughout the trajectory. In a TextWorld environment, we show that Memorilla reduces the agent's tendency to wander between rooms it has already explored, and improves its average success rate from 18.6% with full-history in-context learning to 24.2%. Overall, Memorilla aids frozen LLMs in accumulating and using knowledge effectively across long-context interactions and takes a step towards building continually learning AI systems.