Manuscript Offprint

arXiv:2610.13314

NEAR: Neighborhood-Aware Residuals for Memory Retrieval

Han Luo, Zhan Zhuang, Xu He, Jujia Zhao, Yu Li, Suqin Yuan, Dong Li, Lei Feng

ABSTRACT

Memory retrieval aims to identify evidence from stored records to answer a query. Stored records with different factual details may share topics, entities, or events. Such shared contents would make records without the required evidence more likely to receive high similarity scores and outrank the correct evidence. In this paper, we use the information shared by these records to construct local references for query-memory matching. We propose NEighborhood-Aware Residuals (NEAR), a training-free framework that uses these references to construct residual representations that complement the original embeddings. Specifically, each memory derives a reference direction from its neighbors, and each query obtains its reference from a precomputed table. Using these references, NEAR constructs projection residuals for both queries and memories. These residuals are combined with the original embeddings for a single approximate nearest-neighbor search over a fixed memory index. Experiments on eight long-context retrieval benchmarks show consistent improvements across nine embedding models. Downstream evaluations show that NEAR improves question-answering performance.

1 INTRODUCTION

Memory retrieval enables intelligent assistants to find evidence in past conversations and stored documents to answer current queries (Maharana et al., 2024; Wu et al., 2025). A common approach is embedding-based retrieval, which encodes queries and memories separately and ranks memories by vector similarity (Morris & Rush, 2025). Memory embeddings can be computed and indexed in advance, allowing new queries to search the memory bank without re-encoding its records (Ashok et al., 2026). This design separates offline memory processing from online query retrieval.

In a memory bank, records with different factual details may share topics, entities, or events (Zhang et al., 2026). When ranking relies only on query–memory similarity, such overlap would make records that do not provide the required evidence more likely to outrank correct evidence (Ashok et al., 2026). However, these similar records are not only competing candidates. We argue that they also provide a local neighborhood that can serve as a reference for each memory. We turn this potential source of confusion into useful matching information by constructing memory-specific local references from the relationships among similar memories, as illustrated in Figure 1.

In this paper, we propose NEighborhood-Aware Residuals (NEAR), a training-free framework that uses these local references for query-memory matching. Figure 2 gives an overview of NEAR. For each memory, NEAR builds a reference from its nearest neighbors and removes the embedding component along this direction. A small precomputed table provides references for new queries without an initial search over the memory bank. The same projection yields a residual representation for each query. NEAR combines the original and residual representations so that the final matching score is a single inner product. Offline indexing enables retrieval through a single approximate nearest-neighbor (ANN) search over the fixed memory index.

We evaluate NEAR on eight long-context retrieval benchmarks using nine frozen embedding models. Across all nine models, NEAR improves mean Recall@10 and NDCG@10 over the original embeddings and the evaluated same-backbone baselines. Downstream evaluations further show that NEAR improves question-answering accuracy by 9.6 percentage points on LoCoMo with Qwen3-

∗^{*}Corresponding author.

References (49)