Tutorials

SpectRAG uses weighted chunk graphs to select context within token budgets for multi-hop question answering.

SpectRAG is a retrieval framework that turns a corpus into a weighted chunk graph and selects evidence sets under a token budget. Instead of ranking passages independently, it uses spectral graph theory to balance relevance, diversity, and connectivity. This helps multi-hop questions where bridge evidence may rank poorly and near-duplicate chunks can fill the context window. The paper reports a 46 MB benchmark index versus 274 MB for LightRAG and 91.8 percent recovery of gold evidence, offering a compact, graph-aware option for retrieval-augmented generation builders.

SpectRAG uses weighted chunk graphs to select context within token budgets for multi-hop question answering.

Key Takeaways

  • SpectRAG is a retrieval framework for multi-hop question answering that models documents as a weighted chunk graph instead of treating passages as independently ranked text chunks.
  • It targets common RAG failures where single-passage retrieval returns near-duplicates, misses bridge evidence, and ignores corpus structure such as document order, shared entities, and citations.
  • The system combines multiple edge signals, spectral graph coordinates, and relevance diffusion to select context sets that are relevant, diverse, and connected.
  • SpectRAG fills a token budget rather than returning a fixed number of chunks, using a protected core, diversity-oriented tail, and backfill step to assemble the final context.
  • Reported results show strong evidence recovery and much smaller index size: 91.8% of gold evidence recovered, with a 46 MB MultiHopRAG index compared with LightRAG’s 274 MB.

SpectRAG, a retrieval framework described in the paper "SpectRAG: Weighted Chunk Graphs for Token-Budgeted Context Selection in Multi-Hop Retrieval-Augmented Generation" by Zafer Sahinoglu, Abdulazeez Mohammed, Buse Yaren Kazangirler and Cahit Berkay Kazangirler, converts a document corpus into a weighted chunk graph and selects evidence sets rather than independently ranked passages. It uses spectral graph theory to find evidence that is relevant, diverse and connected. The reported MultiHopRAG index is 46 MB, while LightRAG's is 274 MB, and the framework recovers 91.8 percent of gold evidence overall. The result matters for builders of retrieval-augmented generation systems because answers that depend on several chunks can fail when the retriever returns near-duplicates and misses connecting text.

When single-passage ranking misses the bridge

Retrieval-augmented generation systems improve large language models by adding external evidence to the prompt. The retriever embeds the question and returns the closest matches. That approach is adequate for simple lookups, such as a boiling point. It becomes fragile when an answer requires facts spread over three passages. In the paper's example, a six-chunk budget can fill the context window with near-duplicates from one paragraph-sized section of one document and locate only 1 of 3 gold passages. The linking passage may look unrelated to the query, so it is not retrieved. The model then receives repeated evidence and may guess correctly or fail.

The authors identify three failure modes. First, neighboring or overlapping chunks can be similar in embedding space, so top-ranked results repeat one another. Second, bridge evidence, such as a definition, shared entity or reference that links two facts, may rank poorly because it does not resemble the question. Third, ordinary ranking ignores corpus structure, including document order, section hierarchy, shared entities and citations, treating stored text as independent vectors.

SpectRAG's response is to optimize a context set, not a list. The objective weighs relevance to the question, a redundancy penalty, coverage of question aspects, and connectivity through the graph. If the redundancy, coverage and connectivity weights are zero, the method reduces to ordinary top-k selection. Because the target function is defined over sets, the authors approximate it with a graph pipeline instead of sorting scores.

A weighted graph gives chunks two coordinates

The pipeline has an offline corpus stage and an online query stage. The full pipeline is described in the official arXiv preprint. Offline, documents are split into roughly 1,200-token chunks. The splitter follows headings when they exist, inserts semantic breakpoints when they do not, avoids cutting mid-sentence and keeps tables intact. Each chunk is embedded with nomic-embed-text.

Chunks are then connected using six complementary evidence signals. Unlike a plain nearest-neighbor embedding graph, SpectRAG draws edges from multiple signals rather than only vector similarity. The paper describes one signal explicitly: a language model generates utility questions that each chunk can answer, and chunks answering similar questions are treated as functionally related even when their wording differs. It also notes that chunks from five documents are linked signal by signal before the edges settle into one weighted graph. Each signal contributes a weighted score, and the combined edge weight is formed by summing those signal-specific values. Weak edges are pruned to keep the graph sparse.

Next, SpectRAG computes the symmetric normalized Laplacian of the graph, expressed as L_sym = I - D^(-1/2) W D^(-1/2). This gives each chunk two geometries: a dense embedding, which captures what the text says, and a spectral coordinate, which captures its position in the corpus's community structure. The paper argues that embedding space can mix topics and leave some chunks far from their neighbors, while spectral space, through Laplacian eigenvectors, pulls graph communities together regardless of wording.

SpectRAG uses weighted chunk graphs to select context within token budgets for multi-hop question answering.

Five query stages select a token budget, not just k

Online retrieval begins with hybrid seeds. Three rankings are fused with Reciprocal Rank Fusion: dense FAISS cosine scores, BM25 scores and matches against stored utility questions. The result is a high-recall seed set of 20 chunks. The system deliberately over-retrieves here because later graph expansion can only reach what the seeds can reach.

A two-hop breadth-first search in Neo4j expands the seeds to up to 200 candidates. Those candidates may not match the query directly, but they sit near chunks that do. Spectral relevance diffusion then re-scores the candidates: relevance can spread along graph connections, so a chunk that never matched the query can still enter the context if it is strongly connected to matching chunks. The paper shows relevance starting from three seed chunks spreading as the diffusion scale t grows, using heat-kernel computation on a synthetic graph.

The final stage fills a token budget of about 12,000 tokens instead of returning a fixed number of chunks. It protects a core of high-confidence chunks that diversity rules cannot remove. It then adds a precision-oriented tail that favors new documents and under-represented spectral clusters while rejecting repeated content, with a precision floor, and uses a backfill step so the budget is not left half-empty. The context window is assembled by token cost and coverage, not by count alone: protected core first, then tail, then backfill.

Benchmarks show lighter storage and stronger evidence recovery

The evaluation uses MultiHopRAG, containing 2,556 gold-answer multi-hop questions, and four UltraDomain corpora: Agriculture, Computer Science, Legal and Mix. The baselines are NaiveRAG, Hybrid, which combines BM25 and dense retrieval, HyDE and LightRAG. All systems use the same generator, so answer differences are attributed to retrieval.

Compared with entity-based GraphRAG approaches, SpectRAG's nodes are chunks rather than extracted entities. LightRAG builds its graph from language-model-extracted entities and maintains separate vector stores for entities and relations. Table 4 shows that across the five corpora, SpectRAG has 2.8x to 6.6x fewer nodes, and its MultiHopRAG full persisted index is 46 MB versus 274 MB for LightRAG. The graph is smaller in nodes, not edges: each chunk has up to about 5.7 edges per node, versus about 1 for LightRAG. The overall index is about six times smaller than LightRAG's.

SpectRAG uses weighted chunk graphs to select context within token budgets for multi-hop question answering.

Table 6 reports evidence recovery. SpectRAG reaches 91.8 percent of gold evidence overall on MultiHopRAG, while the next-best system reaches 76.1 percent. It leads at Recall@10 with 84.0. Against LightRAG, it is ahead at every cutoff and on mean reciprocal rank, 70.4 versus 61.5.

Table 7 shows end-to-end answer quality is highest but narrow. Among the five systems, SpectRAG has the highest exact match at 71.2, and both F1 score and answer containment are 71.6. The margin over Hybrid and LightRAG is under one point, while the gap over NaiveRAG and HyDE is 3-6 points.

Table 8 highlights the largest gain on inference questions, where evidence must be assembled across hops. SpectRAG reaches 95.1 percent exact match there. Comparison and temporal questions are close to a tie, with LightRAG slightly ahead. The paper's tables provide these scores; toy-graph animations are explanatory illustrations, not experimental results.

What builders can do with the release

The original write-up appeared on Towards AI on Medium, and the paper is listed as arXiv:2610.36991. Code is available at github.com/SightAndCite/SpectRAG under the MIT license. The implementation uses FAISS, BM25, Neo4j and a React + D3 front-end that lets users explore the chunk graph of their own documents.

It can run fully local with Ollama embeddings, a local LLM for utility questions and spaCy named entity recognition for entities, without an API key. To index a folder of documents, run python main.py index papers/. To ask a multi-hop question, run python main.py query "What methods improve cross-document reasoning?".

For teams building retrieval systems, the practical takeaway is that multi-hop quality can depend less on a larger fixed chunk count and more on how the selected passages relate. SpectRAG suggests that graph-aware, token-budgeted selection can recover bridge evidence that direct ranking misses, while keeping the stored index smaller than entity-based alternatives. Builders who struggle with redundant chunks, missing connectors or context windows that fill with near-duplicates can test the framework against their own multi-hop questions and compare its evidence path to a standard top-k retriever.

Comments (0)

  1. No comments yet. Be the first to share what worked for you.

Leave a comment

Comments are reviewed before they appear. Your email address is not published.