Enterprise knowledge · Research feature

M-RAG Improves RAG Systems by Separating Retrieval and Generation Tasks

A new method uses semantic key-value indexing to improve how external documents are retrieved and used in AI generation systems under token budget constraints.

Adapted from research by Xu Sun, Tongkai Xu, Baiheng Xie and colleagues.

arXiv preprint revision · 2026-07-21 · Attribution & reuse
In this article
Editorial illustration of linked workflow.

Editor’s introduction

The study focuses on retrieval-augmented generation (RAG) systems, examining how document indexing affects both retrieval efficiency and generation accuracy. Researchers compare chunk-based indexing—where text is split and used for both lookup and context—with a new approach, M-RAG, which separates retrieval and generation by creating semantic key-value records. Each record includes a retrieval key, a value containing the actual content, and provenance pointers for traceability. The system retrieves keys efficiently using dense or sparse methods, then assembles the corresponding values as context under token limits. Results show M-RAG matches or exceeds chunk-based methods in accuracy, especially when token budgets are tight, with improved coverage and robustness across larger document sets.

Introduction

Retrieval-augmented generation (RAG) has become a common interface between large language models (LLMs) and external data. In data-intensive settings, such as enterprise knowledge bases, scientific literature search, legal analysis, and financial reporting, a RAG system depends on the relevance, completeness, and organization of the evidence it presents to the generator. This makes RAG not only a generation problem, but also a data management problem: how should evidence be represented, indexed, retrieved, and assembled before an LLM reads it?

From this perspective, RAG is an indexing and query processing problem under a token budget. Given a document collection and a user query, the system must support selective lookup, low-latency retrieval, compact context assembly, and traceability to the source data. The retrieved records are not the final output. They are intermediate evidence consumed by an LLM, whose context window is limited and whose generation can be affected by irrelevant or poorly organized context. A RAG access method therefore has to balance retrieval accuracy, evidence fidelity, provenance, and online efficiency.

Most RAG systems instantiate this access method with text chunks. A document is split into fixed-size windows, overlapping windows, semantic segments, or structure-aware spans. At query time, the retriever selects several chunks, and the selected chunks are inserted into the LLM context. This design is simple, scalable, and compatible with standard vector indexes. It also makes a strong physical-design choice: the object used as the index entry is the same object returned as the generation payload.

Recent work has made chunking more adaptive. Semantic chunking groups adjacent text by similarity. PIC uses document summaries as pseudo-instructions for adaptive grouping. MoC learns mixtures of chunking strategies. DOS RAG shows that preserving the original document structure can be a strong baseline. These methods improve segmentation quality and demonstrate that the retrieval unit matters. However, they still retain the same access interface: retrieve a text span, then use that span as generation context. Long-context LLMs do not remove this design question. Although longer context windows reduce the need to use retrieval only as external memory, they still require systems to decide which evidence should enter the context, and they remain sensitive to irrelevant or distracting information. Recent chunk-free retrieval work, such as CFIC, further suggests that raw chunks need not be the basic retrieval object.

M-RAG indexes keys and returns values. At query time, retrieval operates over the key field rather than the value field. The key can be embedded for dense retrieval or indexed as text for sparse retrieval, such as BM25. Once a key is retrieved, its paired value is assembled into the generation context under a token budget. This separates the lookup representation from the returned payload. The key can be optimized for precise matching, while the value can be optimized for evidence fidelity. The provenance pointers support coverage validation and position-aware context ordering. In this sense, M-RAG applies a familiar database principle to RAG: keep the index lightweight, and keep the payload faithful to the data needed by downstream operators.

M-RAG is designed as a modular indexing layer. Offline, an off-the-shelf LLM extracts meta-markers from tagged documents. A coverage validation step checks whether the extracted records cover the source document and creates conservative fallback records for uncovered units. Online, the system retrieves relevant keys through a dense or sparse index, selects paired values under a token budget, and orders the selected values by source position or similarity before generation. Retrieval operates over compact semantic keys; generation reads contextual evidence values.

Retrieval-augmented generation (RAG) connects language models with external corpora by retrieving evidence before generation. The basic interface has since evolved into dense retrieval pipelines, modular RAG systems, graph-based retrieval, and agentic workflows. Despite these architectural differences, RAG systems share a core data-management question: what representation should be indexed, and what evidence should be returned to the generator?

Indexing and access methods for semantic data. Data systems typically separate logical records from physical access paths. In semantic search, dense-vector indexes such as HNSW and sparse lexical indexes provide alternative lookup paths over a collection. This view is useful for RAG because chunking is not only preprocessing; it determines the physical record exposed to the access path. M-RAG follows this access-method perspective by materializing a record layout in which the field used for lookup is different from the payload returned to the downstream operator.

Retrieval units in RAG. Most RAG systems instantiate this choice with text spans. Fixed-size, overlapping, semantic, and structure-aware chunking methods differ in how they determine document boundaries, but they largely preserve the same access interface: a query is matched against a text unit, and the selected unit is inserted into the generation context. Prior work has shown that segmentation quality affects retrieval and downstream QA, and that the choice of granularity creates a tension between noise and coherence. PIC uses document summaries as pseudo-instructions for adaptive grouping, while MoC learns mixtures of chunking learners and applies the learned chunkers to extract text spans. Proposition-level dense retrieval studies a finer granularity by indexing concise factual propositions rather than passages or sentences. These methods show that retrieval-unit design is important, but they mainly optimize the boundary or granularity of the text object being retrieved.

Structure-aware and graph-enhanced RAG. Beyond segmentation, recent work has emphasized the organization of evidence. DOS RAG preserves the original document structure and passage order as a simple retrieve-then-read baseline for long-context language models. Graph-augmented methods construct entity-relation or community structures over indexed text to support retrieval beyond flat chunk collections. LightRAG, for example, incorporates graph structures into text indexing and retrieval and combines them with vector representations. AGRAG further improves graph-based RAG by using statistics-based entity extraction and retrieving minimum-cost maximum-influence reasoning subgraphs. These methods model structural dependencies in the evidence space. They are complementary to M-RAG: rather than proposing a new graph retriever or generator, M-RAG changes the logical record layout exposed to retrieval. The resulting records can still be searched with dense, sparse, or graph-enhanced backends.

Decoupled and chunk-free representations. The closest line of work relaxes the assumption that raw chunks must be the basic retrieval object. CFIC proposes chunking-free in-context retrieval by using encoded document hidden states and decoding strategies to identify evidence text for a query. HeteRAG studies decoupled knowledge representations, using short chunks for generation and context-enriched multi-granular views for retrieval. These studies are closely related because they also separate, to different degrees, the representation used for retrieval from the evidence consumed by generation. M-RAG takes a database access-method perspective on this design space. It materializes a persistent semantic key-value record layout: a compact query-facing key is indexed for lookup, a richer value is returned for generation, and provenance pointers keep the record traceable to source units. This layout explicitly separates query matching from evidence delivery while preserving the standard RAG generator interface.

Offline Index Construction

The extractor is constrained to produce records with a query-facing key, a self-contained evidence value, and bounded provenance pointers. The prompt is used only to specify this output schema and the extraction constraints; the complete prompt and implementation details are provided in the accompanying artifact. Table I summarizes the prompt structure used by M-RAG.

Budget-Constrained Query Processing

The selected values can then be assembled by similarity order, which preserves the retrieval ranking, or by source order, which uses the provenance pointers to recover the document order. The assembled values form the context consumed by the generator. The retrieved keys are not inserted into the generation context unless they are also part of the stored value.

Design Analysis

The design changes the physical access interface of RAG. In chunk-based systems, a text span must be selective enough to match a query and complete enough to support generation. These requirements are often in tension: shorter spans improve specificity but can fragment evidence, while longer spans preserve context but mix topics and spend more of the token budget. M-RAG assigns these requirements to different fields. The key provides a compact lookup representation, while the value carries the evidence consumed downstream.

The provenance field does not participate in ranking, but it makes the semantic index auditable. Before indexing, provenance pointers support a coverage check over the source units and allow fallback repair for uncovered units. After retrieval, the same pointers support source-order assembly, which is useful when answer evidence depends on document structure rather than only on local similarity.

The main cost of this design is moved to the offline construction phase. Marker extraction materializes semantic records before queries arrive, while online processing only matches keys and fetches paired payloads. This division is suitable for read-heavy RAG workloads, where a constructed index is reused across many queries. It also keeps the retrieval backend modular: dense, sparse, or hybrid retrievers can operate over the same key field without changing the generator interface.

Experimental Setup

Benchmark. We evaluate M-RAG on QA subtasks from LongBench, a benchmark for long-context understanding. The evaluation uses NarrativeQA and Qasper for single-hop QA, and 2WikiMultihopQA for multi-hop QA. Each subtask contains 200 samples and covers contexts longer than 3K tokens on average, spanning narrative, scientific, and multi-document reasoning workloads.

Baselines. We compare M-RAG with representative retrieval-unit construction methods. The chunk-based baselines include Fixed-Size RAG with 128-token segments, Fixed-Size RAG with overlap, Semantic RAG, PIC RAG, and DOS RAG. These methods address the same physical-design question as M-RAG: how evidence should be organized before retrieval and generation. We also include LightRAG as a graph-enhanced RAG baseline that combines graph structures with text retrieval.

End-to-End QA Performance

The results also show that the benefit is not tied to a single retrieval backend. Dense retrieval benefits from matching queries against compact semantic keys, while BM25 benefits from a concise lexical field that avoids term dilution in long chunks. This consistency supports the main design choice of M-RAG: retrieval should operate over a query-facing representation, while the generation budget should be spent on the paired evidence value.

Semantic Index Analysis

Marker Granularity. Table IV shows that most markers correspond to single-paragraph evidence, indicating alignment with localized discourse units. At the same time, 29.7–36.5% of markers span continuous multi-paragraph regions, which allows a record to aggregate evidence that crosses a paragraph boundary. Non-consecutive markers are rare, suggesting that M-RAG mostly preserves the local structure of the source document while still allowing occasional long-range aggregation.

Retrieval Robustness

To evaluate the robustness of M-RAG under expanding retrieval spaces, we conduct a controlled corpus-size stress test. For each query, we fix the query, answer generation model, retrieval budget, and the corresponding gold document, while progressively increasing the number of candidate indexed documents available to the retriever. The candidate corpus consists of the gold document together with deterministically sampled distractor documents from the same benchmark. Corpus size is varied from 1 to 5, 10, 25, 50, 100, and finally the full corpus.

These results indicate that M-RAG is less sensitive to distractor documents in this stress test. As corpus size grows, the gap between M-RAG and the fixed-size baseline widens, suggesting that compact semantic keys provide a more selective access path when the retriever must search over a larger candidate space. We then examine whether this behavior depends on prompt wording or context assembly order.

Design Sensitivity

Prompt Sensitivity. To check whether marker extraction depends on a particular prompt wording, we evaluate three prompt variants on Qasper under few-shot position sorting. Prompt A is the original extraction prompt, Prompt B swaps the output-format and critical-requirement sections, and Prompt C moves the key-goal section below the critical-requirement section. Table V shows that the results remain close across budgets, suggesting that extraction mainly depends on the record schema and coverage constraints rather than a single prompt ordering.

Similarity sorting is more useful for open-ended narrative queries. On NarrativeQA, zero-shot SS reaches 14.76% at 640 tokens, a 1.2% gain over PS. This suggests that, when evidence is less tied to document order, prioritizing query relevance during assembly can be more effective. The two sorting policies therefore act as alternative execution choices over the same semantic key-value index: PS favors source structure, while SS favors local query relevance.

Conclusion

This paper studies RAG as a data access problem under a token budget. We show that chunking couples two different roles: the record used for lookup and the evidence payload consumed by the generator. M-RAG addresses this coupling by materializing documents into semantic key-value records, where compact retrieval keys support dense or sparse lookup, information values provide faithful generation evidence, and provenance pointers make the index traceable and order-aware. The index is constructed offline with coverage validation and fallback repair, and queried online by retrieving keys and assembling paired values within the context budget. Experiments on LongBench QA subtasks show that M-RAG is especially effective when evidence budgets are tight, while further analyses show high source coverage, robustness to larger candidate corpora, and lower retrieval latency. These results support a simple design principle: the object used for lookup need not be the object returned for generation. Semantic key-value indexing therefore provides a modular access layer for RAG systems, leaving room for stronger key refinement, provenance-aware execution plans, and incremental index maintenance.