Open Source Published here Reported by GitHub on

Memorilla compresses a document collection into 16 memory tokens and beats full context on FactKG — 84.33% vs 80.43%

Stanford open-sourced Memorilla, a latent memory module for frozen LLMs, from Adibvafa Fallahpour, Parsa Idehpour, Vignesh Kothapalli, Nikita Mounier, Shirley Wu, Shayan Pardis, and Jure Leskovec, with collaborators at Toronto, Penn, and MIT. The model's weights never change; only the memory module is trained. Documents are encoded once into reusable embeddings, and a learned module retrieves query-specific information and writes it as a fixed set of memory tokens directly into the LLM's input embedding space. The released configuration uses 16 memory tokens, a Qwen3-8B decoder, and a Qwen3-Embedding-4B encoder. It beats baselines including Mem0 and MemoRAG on 5 of 8 benchmarks spanning personalization, long-document QA, and knowledge-intensive QA. On FactKG it reaches 84.33% against 80.43% for full-context inference while using 108× fewer tokens to represent the source documents, and reports more than 4,000× compression on NarrativeQA. In the TextWorld agent environment it lifts success from 18.6% to 24.2%. Code is Apache 2.0 at snap-stanford/memorilla, with stage-wise checkpoints and task-specific variants on Hugging Face under memorilla/Memorilla-Qwen3-8B.

Why it matters

Beating full context is the result that should make you re-read the paper, because it means the long-context baseline is not an upper bound — stuffing 100K tokens of retrieved documents into a window actively hurts, and a learned 16-token summary of the right facts does better. That reframes "agent memory" from a retrieval-plumbing problem into a learned-compression problem. The frozen-decoder design is what makes it deployable: you are training a small adapter against a model you do not own, which is a very different budget from fine-tuning. Caveats are real though — 16 tokens is query-dependent, so the module has to see the query, and the released checkpoints are built on an 8B decoder.

What to do

If your RAG pipeline is pushing large chunk sets into a long window, treat full-context as a baseline to beat rather than the target, and measure accuracy against token count instead of assuming more retrieved text is better. Memorilla is worth benchmarking directly on your own corpus since the code and checkpoints are Apache 2.0 and the decoder stays frozen — the comparison to run is against your current retriever plus Mem0-style memory, on your queries, not theirs. The TextWorld number is the one to watch for agent work: memory that survives a multi-turn episode is exactly where the ToolTurns-style conversation decay comes from.

Tags: Open Source Memory RAG Context Engineering

More from November 16, 2026

All AI news