Until now, there have been two main ways to put external knowledge into an LLM. Either you rummage through an external store and pull in documents every time you answer (retrieval), or you rework the model weights with the new knowledge. Deep Fusion Memory (DFM), from the LUMIA Lab at Shanghai Jiao Tong University, proposes a third path.
In one line: during training, the knowledge that was retrieved is baked into a separate "memory module" ahead of time, and at answer time the model draws from that module without searching. The moment retrieval disappears is not training but answer time. The training stage still uses retrieval, but because its results have been dissolved into the module, there is no need to hit the store while serving.
The payoff is twofold. First, when building the training data, the number of retrieval queries dropped 32-fold and the number of retrieved items dropped 2048-fold. Second, even after those savings, DFM beat the strongest prior method on the six-benchmark QA average by a relative 12.71% on Mistral-7B-v0.3 and a relative 11.19% on Qwen3-8B-Base.
An LLM only remembers what it saw during pretraining. But giving a trustworthy answer often requires facts that are missing from the parameters, hazy, or already stale. So you need to inject external knowledge into the model — and every existing method came with an obvious price.
Parametric memory speeds up inference but hides two costs. One is the data-construction burden. To build the training targets, you have to run retrieval at every token position in the corpus. For a 4-billion-token corpus, that means 4 billion retrievals. The other is shallow fusion. If memory is blended just once, at the very last output-probability stage, the knowledge only enters after the model has nearly decided its answer. The intermediate layers get no chance to process that knowledge further together with the context.
DFM targets both costs — the data-construction burden and shallow fusion — at the same time. The idea of removing retrieval at inference comes from parametric memory; the idea of injecting knowledge into the decoder via cross-attention comes from RETRO; and the instinct for compressing and handling embeddings comes from xRAG.
The way DFM cuts cost is easiest to see split in two.
Data construction: instead of searching per word, search in batches. Where prior methods ran a retrieval for every single token, DFM cuts the training sequence into chunks of 32 tokens and retrieves just once per chunk. On top of that, it pulls only 16 neighbors per query. Cutting both the number of searches and the amount retrieved is the heart of the savings.
When knowledge gets blended: mid-cook, not just before plating. If shallow fusion is the final seasoning at the end of cooking, DFM adds the ingredients midway through. Knowledge has to enter the model's intermediate processing so that later stages can refine it together with context.
The architecture breaks into two components.
The causal memory predictor. When it is a given chunk's turn to be processed, the predictor looks only at the chunks that precede it and produces, as a vector, "the memory this chunk will need." "Causal" means it only refers to content that comes before it — that is, it does not peek into the future beyond the information available when predicting the next token. The first chunk has no preceding context, so it is processed without memory and is excluded from the training target. During training, the retriever uses each chunk's preceding chunks as a query to find the top-16 neighbors, and the bundle obtained by embedding them with a frozen text encoder serves as the predictor's "answer key" (the target memory).
Fusion that blends memory into the body text. The predicted memory is injected into several layers of the decoder. In terms of how it works: as each word is processed, how much memory to reflect into that word is modulated, and it gets reinterpreted together with context in the subsequent processing stages. The point is that words within the same chunk share the same memory, but each word draws on a different amount to fit its own context. The concrete implementation goes in the box below.
Technical box — the fusion module's implementation The predicted memory is transformed into the decoder's hidden space through a shared projector, then injected into selected layers via cross-attention. What modulates how much is reflected is a learned gate. A sigmoid gate emits one scalar per token, head, and layer to modulate the contribution of the memory branch. Self-attention and memory cross-attention run side by side, merge into the same residual update, and then pass through the original feed-forward layer unchanged. Training is end-to-end, using both next-token cross-entropy and a mean-squared error (MSE) between the predicted and target memory, with the backbone weights frozen. Because the backbone is left untouched, the risk of catastrophic forgetting is structurally reduced, and at inference the predictor draws memory straight from the input — so no store retrieval, no retrieved text, and no external embedding encoder are needed.
For both backbones the six-task average rose, but which method won varied task by task. Start with the averages.
| Backbone | Strongest prior method | Prior score | DFM score | Gap |
|---|---|---|---|---|
| Mistral-7B-v0.3 | xRAG | 24.14 | 27.21 | +3.07 (relative 12.71%) |
| Qwen3-8B-Base | MLP Memory | 23.80 | 26.46 | +2.66 (relative 11.19%) |
Measured against the untouched base, that is +13.59 points on Mistral (all six tasks up) and +3.75 points on Qwen3-8B (five of six up). It's worth being clear that these two comparisons use different baselines: 12.71% and 11.19% are "versus the strongest competing method," while +13.59 and +3.75 points are "versus the base."
Task by task, there are both successes and failures. The poster child for success is Mistral's Bamboogle, which jumped from 3.91 to 22.65. The poster child for failure is Qwen3-8B's WebQA, which actually fell from 41.78 to 39.47 — and on that task MLP Memory was the highest at 43.26. In other words, a higher average alone is a poor predictor of improvement on any individual task. The authors themselves note that memory adaptation is not uniformly beneficial across backbones and tasks. Other notable points:
| Task | Base/comparison | DFM | Note |
|---|---|---|---|
| Mistral · 2Wiki | 5.87 | 25.00 | But RAG is higher at 31.02 |
| Qwen3-8B · NQ | — | 27.46 | Beats RAG by 3.04 points |
| Qwen3-8B · HotpotQA | xRAG 27.74 | 26.46 | Explicit retrieval wins |
(Single-hop = questions answered by one fact lookup (NQ, WebQA); multi-hop = questions that require chaining several pieces of evidence (HotpotQA, 2Wiki, MuSiQue, Bamboogle).)
Domain adaptation is a separate axis, where code, math, and law were each trained and evaluated per domain.
| Backbone | Base average | DFM average | Gap | LawBench (base → DFM) |
|---|---|---|---|---|
| Qwen3-4B-Base | 58.18 | 64.69 | +6.51 | 29.96 → 40.41 |
| Qwen3-8B-Base | 63.14 | 67.52 | +4.38 | 38.45 → 46.61 |
DFM topped the base on all four benchmarks, with the gain in law especially large. That said, on the 8B's HumanEval+ and GSM8K, LoRA was stronger than DFM. Knowledge injection does help even reasoning-type tasks, but whether it beats other adaptation methods varies from benchmark to benchmark.
Efficiency is the clearest set of numbers in the paper. The four items below measure different costs.
| Item | Prior | DFM | Reduction |
|---|---|---|---|
| Construction retrieval queries (4B tokens) | 4 billion | 125 million | 96.88% (~32×) |
| Retrieved items (per query) | 1024 | 16 | 98.44% (~64×) |
| Training time (16×A800) | ~64 hours | ~24 hours | 62.5% |
| Extra parameters (Mistral) | 1.5B | 0.75B | ~50% |
Multiply the number of queries (32×) by the items per query (64×), and the total number of returned items falls from 4.096 trillion to 2 billion — about 2048× (99.95%). In other words, "2048×" is measured against the total return volume, not per query.
The costs this paper directly measures are the construction-time retrieval volume, training time, and extra parameters. The compute at answer time is a design advantage from removing retrieval, but it was not separately measured as a latency figure, and the knowledge-update cost is shifted onto retraining (see the limitations below). So the efficiency gain is read accurately as "the construction and training stages are greatly reduced, and retrieval is dropped at the answer stage" — not "every stage got cheaper."
Ablations show how sensitive the design choices are. For chunk size, 16/32/64 gave averages of 26.51/27.21/27.07, so 32 was best. Pushing to 64 halves the construction queries while the score drops by only 0.14 points. The placement of fusion layers had a large effect. Two to eight fusion layers distributed from layer 9 onward gave 27.09–27.54, but fusing only at the final layer dropped to 21.11, and using only the last four layers dropped to 22.07. The trend confirmed in this setting is "don't crowd memory near the output — distribute it across the middle-to-late layers," which lines up with the principle that memory inserted in the middle can be processed by later layers. Whether the same trend holds on other backbones is an open question.
Reproduction setup. QA was trained on the December 2018 English Wikipedia (~4B tokens), with benchmarks NQ, WebQA, HotpotQA, 2WikiMultiHopQA, MuSiQue, and Bamboogle. Backbones were Mistral-7B-v0.3 and Qwen3-8B-Base. Comparisons spanned non-parametric (RAG, xRAG, RETRO) and parametric (CPT, LoRA, MLP Memory) methods. The configuration: 32-token chunks, top-16 embeddings, and multi-layer fusion from layer 9 onward. Extra modules were 0.75B for the QA backbone and 0.6B for Qwen3-4B. Training ran for 1 epoch with the backbone frozen, on 2,048-token sequences at a global batch of 128, using 16 A800 80GB cards. Domain adaptation was trained on Swallow-Code, Swallow-Math, and DISC-Law-SFT and evaluated on HumanEval, HumanEval+, GSM8K, and LawBench.
The limitations the authors acknowledge are as seen above. Memory adaptation is not uniformly beneficial across backbones and tasks, WebQA fell, and on some tasks explicit retrieval or LoRA is better. A higher average alone is a poor predictor of improvement on any individual deployment.
Three further points are worth thinking about.
First, knowledge updating. The QA evaluation is the result of training on 2018 Wikipedia and then answering using only the predicted memory. Because the knowledge is "baked" into the predictor's parameters, the corpus changing means you have to retrain. The RAG path of swapping only the store to instantly reflect fresh facts is structurally closed off. It saves on answer cost but spends that savings on update cost.
Second, the limits of recall. The premise "look at the context and recall the needed memory" favors problems where the needed knowledge can be gauged from the context alone. How well that recall holds up on wholly unexpected questions, or on rare facts only weakly connected to the preceding context, is hard to read off a benchmark average.
Third, the absolute scores. Mistral's average of 27.21 is double the base (13.63), but this is better read as "lifted this much under a no-retrieval condition" than as "these tasks got solved." DFM's contribution lies not in the performance ceiling itself, but in how close it gets to that ceiling without retrieval.
The job ONTLE is trying to solve is concrete. An AI PM is deployed to a new client, absorbs that company's context — past project history, in-house terminology, decision-making conventions, domain regulations — and puts it to work. The two ways to build this today both come with a price. Pulling internal documents via RAG on every response adds latency per question and keeps sensitive documents continuously exposed to the retrieval pipeline. Fine-tuning on the client's corpus is expensive and can erode general ability.
What DFM changes is the cost structure of that onboarding. The paper's domain-adaptation experiment is a miniature of exactly this scene. Loading only a legal corpus lifted LawBench from 29.96 to 40.41 on the 4B. That corresponds to an AI PM assigned to a legal team absorbing that company's legal context.
The adoption hypothesis splits knowledge in two.
In short, for a "long-residency deployment" model that stays with a client for a long time, the hypothesis is that a two-track strategy fits — stable knowledge in the module, volatile knowledge via retrieval.
Validation means, rather than re-citing the cost multipliers, directly measuring three things in real client work. (1) Answer quality — compared side by side against the base and LoRA on our backbone and our tasks (even in the paper, Qwen3-8B WebQA fell). (2) Update cost — the actual time and money to re-bake the module when client documents change. (3) Response time — whether the benefit of removing retrieval is felt under our service conditions. The finding that fusion layers should be distributed from the middle onward is also a trend confirmed only in this paper's setting, so when porting it, it's something to re-confirm on our backbone first and then decide.
In the QA evaluation, memory is precomputed from the visible prompt and then held fixed while the answer is generated. There is no store retrieval or external encoder call at inference time.
The code is still at the to-be-released stage ("released soon" per the paper). Before planning around an adoption timeline, it's safer to first confirm availability, the license, and how hard it is to reproduce.