Sixteen Tokens for the Whole Shelf
Memorilla trains a module of 194,123,776 parameters to read a document collection and hand a frozen Qwen3-8B sixteen query-dependent memory tokens, while the Qwen3-Embedding-4B encoder stays frozen. On FactKG it reaches 84.33 percent against 80.43 percent for full context, using 108 times fewer document tokens. A 512-document test on one H100 reports about 0.74 seconds against 19.9 for full context, and the authors still say the module can drop exact names.
Sixteen Tokens for the Whole Shelf
A frozen language model can use a document only by spending context on it. Full-context prompting spends that budget on the whole collection. Retrieval spends it on a few passages, and those passages still arrive as text. Memorilla, from Adibvafa Fallahpour, Parsa Idehpour, and Vignesh Kothapalli, with Nikita Mounier, Shirley Wu, Shayan Pardis, and Jure Leskovec, writes a fixed number of soft tokens into the input embedding space of a frozen Qwen3-8B. In the supervised experiments that number is sixteen. Paired with Qwen3-8B, the module has 194,123,776 trainable parameters. The Qwen3-Embedding-4B encoder stays frozen, and so does the decoder. The preprint was submitted on 15 October 2026 and revised on 3 November. The code is in the Stanford SNAP repository under Apache 2.0, the project page is public, and the checkpoints are on Hugging Face. An optional cache for the module's keys and values landed in that repository on 14 November [Source 1][Source 2][Source 3][Source 4].
Encode once, then read with the question
Each document chunk is embedded once. The matrix does not depend on a later question, so only a new or edited document has to be encoded again. The question is embedded for the current request and is not stored as long-term memory. The module starts from K learned slots, shared across collections. The slots attend to the question vector, and a residual connection keeps them distinct. They then cross-attend to every document embedding, Perceiver-style: each slot can see the whole store, and the question decides what is kept. There is no top-k cut. A projection lands the slots in the decoder's embedding dimension, and they are prepended to the question. Rotary positions run over that combined sequence. No decoder layer changes. The loss is the answer's negative log-likelihood, applied only to the memory parameters [Source 1].
A retriever can share the embeddings and the decoder, then put selected text in the window. Memorilla's document budget stays at K tokens as the collection grows. Supervised runs fix K at 16. The released configs use that budget and turn document self-attention off, matching the paper: the slots are conditioned on the question and then read the store, without self-attention among themselves [Source 1][Source 4].
The curriculum has three stages. Stage 1 is 1.98 million English Wikipedia paraphrase reconstructions, so sixteen slots must preserve enough for the frozen model to rewrite a passage. Stage 2 continues on 1.34 million examples from ten reading, question-answering, and summarization sets. Stage 3 fine-tunes on the eight benchmarks' training splits. One checkpoint covers FactKG, TriviaQA, NarrativeQA, PubMedQA, LaMP-4, and LaMP-7. PersonaMem-v2 and the authors' synthetic PersonalizationV4 get more task-specific training, because their validation losses needed further epochs. Each Hugging Face folder is a bfloat16 checkpoint plus that config [Source 1][Source 4].
A relation across the shelf, or a name in one passage
Every system the authors ran answers with the same frozen Qwen3-8B. Memorilla's mean across eight benchmarks is 49.68, against 41.92 for xRAG, 40.75 for LLMLingua-2, and 38.02 for Mem0. It leads on five and is second on NarrativeQA and PersonalizationV4. In geometric mean it uses 394 times fewer document tokens than full context, 113 times fewer than a fifty-passage retriever, and 49 times fewer than MemoRAG. Counts omit the question and shared instructions [Source 1][Source 2].
FactKG asks the model to judge a claim against knowledge-graph triples. Memorilla reaches 84.33 percent. Full context, which sees every triple, reaches 80.43 percent, and Memorilla uses 108 times fewer document tokens. MemoRAG reaches 80.38 percent with 36 times more document tokens. As claims compose more facts, the fifty-passage retriever falls from 78.73 percent to 51.75 percent, while Memorilla stays in the 80 to 89 range. Some of that drop is missing evidence: 73.5 percent of claims have more than fifty chunks. Full context still trails on the full test, so the margin is not only triples the retriever skipped. Over 9,041 claims the project page rounds the headline to 84.3 against 80.4. The misses differ. Memorilla alone solves 15.9 percent of claims, the retriever alone 10.0 percent. Their union is an oracle bound, not a trained hybrid [Source 1][Source 2].
NarrativeQA repeats the split. Memorilla leads the fifty-passage retriever by 4.91 ROUGE-L on "why" and by 7.02 on "how," and trails by 3.45 on "who" and 2.93 on "which." MemoRAG, still reading passages, leads the benchmark, 20.51 ROUGE-L against 19.31, with fifty times more document tokens. TriviaQA goes the other way: exact match 57.00, against 56.60 for MemoRAG and 52.60 for full context, at 19 times fewer document tokens than MemoRAG and 743 times fewer than the full prompt. On PersonaMem-v2, short-answer accuracy is 44.60 percent against 30.90 for xRAG. Full context is 27.92 and uses 1,974 times more document tokens. On LaMP-7, Memorilla moves ROUGE-L from a closed-book 43.13 to 48.37. PubMedQA is the marked loss. Four abstracts, 324 tokens, and LLMLingua-2 reaches 69.00 percent, four other baselines 67.00, Memorilla 59.00. Short text still wants to be read [Source 1][Source 2].
Flat at 512 documents, measured past that only in the module
On one H100-80GB, batch size one, greedy decoding, and 32 new tokens, documents are 250 tokens each. At one document, end-to-end medians are 740 milliseconds for Memorilla and 749 for full context. At 512 documents the prompt is 128,064 tokens, past a 32,768-token cap, so full context uses YaRN with factor four and takes 19,932 milliseconds. Memorilla stays at 739 milliseconds, still on sixteen tokens. The project page and README round this to 0.74 seconds against 19.9, a 27-fold gap, and the paper says the timings use Hugging Face generation without a paged cache, so the full-context number depends on the stack. The memory forward pass in that table is 2.01 milliseconds, then 1.96. Encoding is a one-time write, shared with building a dense index [Source 1][Source 2][Source 3].
Larger stores are timed at the module, not end to end. On one B200, rereading every embedding takes 74 milliseconds at one million documents. A cache of cross-attention keys and values, off by default, drops a question to 8.1 milliseconds at one million documents and 33 milliseconds at four million, about a billion tokens at 250 tokens each. Compiling brings the one-million case to 5.0 milliseconds. The cache needs four times the embedding memory, 80 GiB at four million documents. Tokens match up to bfloat16 rounding, and FactKG stays within 0.06 points. Decoding still dominates, so the paper locates the latency gain at large collections [Source 1][Source 3].
The module can lose exact names. The authors tie that to an encoder never trained for compression. Experiments stay inside one Qwen encoder and one Qwen decoder, and they do not cover code. The readout is trained for a specific open-weight model. A user's embeddings can be deleted without touching the language model, and the ethics note says they can still hold sensitive text [Source 1][Source 2].
Eight tokens next to the history
TextWorld uses eight tokens, not sixteen, and does not replace the text. A frozen Qwen3-4B-Instruct-2507 explores up to 65 rooms in at most 50 turns. Each completed turn joins the store. A module trained from scratch with GRPO on the game reward compresses it into eight tokens in front of the prompt. Both conditions see the full history, under 16,000 tokens in training and 4,096 at evaluation. Held-out average success rises from 18.6 percent to 24.2 percent, and games finished in at least one of three attempts rise from 25.0 percent to 37.5 percent. Untrained memory falls to 15.3 and 22.5 percent. Full-history runs exhaust the 4,096-token budget on 71 percent of rollouts, against 58 percent with trained memory. The project page's complement, episodes that finish by the game or the turn limit before that budget, is 29 percent against 42 percent. The median rollout ends at turn 33, and 5 of 40 reach turn 50. One game family, one frozen decoder. The gain is a learned read of a history the agent already has [Source 1][Source 2].
Sixteen supervised tokens are a query-conditioned read of a growing embedding store, handed to weights that do not move. They can beat a prompt that already contains every fact, on tasks where the answer is how the collection fits together. They give up the string a passage would have quoted. The 27-fold latency figure is 512 documents on one stack. Beyond that, the published times belong to the memory module.