arXiv:2611.00450cs.CLOct 2026

Manuscript Offprint

arXiv:2611.00450

From Lookups to Lessons: Turning Retrieved Knowledge into Parametric Memory

Changjiang Han, Bowei He, Ye Yuan, Weixu Zhang, Haolun Wu, Xue Liu, Jikun Kang

ABSTRACT

Retrieval-augmented generation (RAG) helps large language models (LLMs) answer factual questions beyond their training data, but it adds storage and inference costs. Distilling previously retrieved information into parametric memories enables reuse without online retrieval. However, training the memory to mimic a retriever rewards accurate independent predictions, which do not necessarily improve the final output quality when combined with the LLM's existing predictions. To address this, we introduce ResMem, in which the LLM reads retrieved text offline to generate teacher targets. This design avoids storing massive token representations, unlike existing parametric memory approaches such as MLP Memory, which relies on k-nearest neighbor (kNN) datastores. Furthermore, by using the LLM as an offline teacher that reads privileged retrieved evidence alongside the input, we train a parametric memory to learn an additive logit residual. This residual aligns the predictions of a student sharing the same backbone with the teacher distribution, while self-distillation updates remain confined to the parametric memory. On a Wikipedia subset, ResMem reduces the storage retained for teacher construction by 94.7% compared with the evaluated kNN pipeline. Across five question answering datasets, ResMem raises mean token F1 from 32.83% for the frozen LLM to 34.48%. It also breaks 21% fewer of the LLM's correct answers than a kNN-trained memory. These findings validate our motivation of treating retrieval as a learning resource, with parametric memory shaped by how retrieved knowledge is used to inform the model's future predictions. Code and model weights are available at https://github.com/SSRand/From-Lookups-to-Lessons and https://huggingface.co/RandHan/ResMem-Mistral-7B-v0.3.

1 INTRODUCTION

Nowadays, many LLM applications need information beyond the current prompt, such as knowledge from external corpora and facts introduced in earlier interactions (Park et al., 2023; Zhang et al., 2025). One option is to keep such information in the model's active context. However, longer context windows do not ensure reliable use of information at every position (Liu et al., 2024b), and growing histories still require managing a finite active context (Packer et al., 2023). Retrieval-augmented generation (RAG) is a widely used way to recover relevant evidence from external storage (Lewis et al., 2020). This access requires maintaining a corpus and its index, while retrieving and reading the evidence adds inference latency. At corpus scale, these costs motivate storing knowledge for use without online retrieval.

Retriever-pretrained parametric memories offer such retrieval-free storage: they learn what a retriever would return and keep it in network weights, so inference needs no index or search. Building on kNN language models (Khandelwal et al., 2020), MLP Memory and Memory Decoder train a memory to reproduce a retriever's next-token distribution, then interpolate its prediction with a frozen base model (Wei et al., 2025; Cao et al., 2025). MLP Memory reports storage compression and faster inference, while Memory Decoder enables reuse across compatible base models. Both memories, however, learn to match the retriever alone and meet the base model only at inference. Their training loss never sees the base prediction (Figure 1a). A memory that reproduces the re-

∗^{*}Corresponding author.

Figure

Figure 1: Training pipelines. (a) MLP Memory fits a memory alone to kNN targets; the base enters only at inference (Eq. 5). (b) ResMem fits a logit residual so that base plus residual matches an evidence-reading teacher; inference drops the teacher and scales the residual by γ\gamma (Eq. 3).

triever well can therefore still change the combined prediction in unhelpful ways. For example, it can override a correct base answer.

We introduce ResMem, which trains the memory through the base prediction it will later modify (Figure 1b). The frozen base model serves as its own teacher by reading the query together with retrieved evidence, while the student sees only the query. The memory adds a logit residual to the student's logits, and the distillation and next-token losses are computed on this sum. Because the loss is computed on the base prediction plus the residual, positions where the base already matches the training target give little gradient. The memory thus learns a correction to the base, not a second copy of the retriever. This builds on context distillation and retrieval-free dialogue distillation (Snell et al., 2022; Zhu et al., 2024). Inference then needs only the frozen base and the trained memory, with a coefficient γ\gamma setting how strongly the residual adjusts the base (Eq. 3).

Because retriever-pretrained memories draw their supervision from a kNN datastore of corpus representations, they also pay a construction cost. Memory Decoder names the neighbor search over this datastore as a training bottleneck (Cao et al., 2025, Sec. 9), and later work scales the search with compression and sharding (Wei et al., 2026). An evidence-reading teacher needs no such datastore. ResMem retrieves passages with BM25 and caches only the teacher's top-64 targets, which cuts retained construction storage from 602.0 to 32.0 GiB on a subset of English Wikipedia, a 94.7% (18.8×) reduction (Section 5.2).

On five knowledge-QA datasets, ResMem improves exact match (EM) and token F1 over the base model on every dataset and raises mean F1 from 32.83 to 34.48. Compared with MLP Memory, it corrects 11% more base errors and breaks 21% fewer correct base answers, so most of its advantage comes from avoided harms. Under a shared teacher, the residual objective mainly preserves correct answers, and its extra repairs come with the evidence-reading teacher. Memory Decoder falls below both memories under the same teacher.

Our main contributions are: (i) We introduce residual self-distillation, which trains an additive logit residual through the joint base-plus-memory prediction and keeps it at inference. (ii) We replace the kNN datastore with text retrieval and an evidence-reading teacher. This cuts retained construction storage by 94.7% (18.8×). The teacher's targets also keep the shape of the base prediction. The kNN targets are much sharper. (iii) We evaluate the recipe and its parts on knowledge QA, answer-level corrections and harms, and shared-teacher ablations.

References (67)