Stanford's Memorilla shrinks document archives to 16 tokens, still beats full context
Built by Stanford's SNAP lab, the open-source tool compresses document collections into 16 vectors for a frozen language model, scoring 84.33% on FactKG versus 80.43% for full context, using 108 times fewer tokens.
Stanford researchers have open-sourced Memorilla, a memory system for large language models that are frozen, meaning their internal weights are never updated. Instead of pasting whole documents into a model’s context window, Memorilla squeezes an entire document collection into just 16 memory tokens, no matter how large that collection is.
The system works in three steps. A frozen embedding model, Qwen3-Embedding-4B, encodes each document once, so adding new files never requires re-encoding old ones. A separate 194-million-parameter trainable module, built from 16 learned slots and two cross-attention layers, then reads the question against the full stored collection. Those 16 slots are projected into the input space of a frozen Qwen3-8B decoder and placed in front of the question. Only this middle module is trained; the encoder and decoder never change.
According to the research team’s own benchmark results, a frozen Qwen3-8B using Memorilla scored 84.33% on the FactKG fact-checking benchmark, ahead of 80.43% when the model saw every document in full, and did so with 108 times fewer document tokens. Across eight benchmarks total, Memorilla posted the highest average score, 49.68, and led on five of them. Its biggest edge came on PersonaMem-v2, where it reached 44.60% against 27.92% for full-context prompting. At the extreme, on NarrativeQA, 16 tokens stood in for 67,385 document tokens, a cut of more than 4,000 times.
The method is not uniformly ahead. On PubMedQA, where source abstracts run to only a few hundred tokens, Memorilla scored 59.00%, well behind LLMLingua-2’s 69.00%. The paper also reports losses to a rival method called MemoRAG on two other benchmarks, though MemoRAG used far more document tokens to get there, by the paper’s own count roughly 690 times more on one of them.
The researchers, from Jure Leskovec’s SNAP group with co-authors at Toronto, Penn and MIT, released code, training recipes and checkpoints under an Apache 2.0 license on Hugging Face. Running it requires a Linux machine with an 80-gigabyte CUDA GPU, and no smaller or quantized versions have been released. The team also published PersonalizationV4, a dataset of 149 synthetic users with 200 conversations each, under a CC BY 4.0 license.
What this means
For anyone building AI agents or tools that need to search large, growing document stores, Memorilla points to a cheaper alternative to stuffing everything into a model’s context window or relying on retrieval systems that paste in text chunks. The speed gain is real on paper: the researchers report that answering a question over roughly 128,000 tokens of documents takes well under a second with Memorilla, against nearly 20 seconds for full context on the same hardware.
What remains unverified is how the method performs outside the eight benchmarks the team selected, since all the figures above are self-reported by the researchers rather than confirmed by outside testing. The 80-gigabyte GPU requirement and the absence of smaller checkpoints also mean the approach, for now, is out of reach for anyone without high-end hardware.
Sources
MarkTechPost