# SpectRAG: Weighted Chunk Graphs for Token-Budgeted Context Selection in Multi-Hop…

> Source: <https://pub.towardsai.net/spectrag-weighted-chunk-graphs-for-token-budgeted-context-selection-in-multi-hop-39b91ffa35c4?source=rss----98111c9905da---4>
> Published: 2026-11-05 04:47:01+00:00

🤹🏼Retrieval-augmented generation (RAG) systems enhance large language models (LLMs) by sourcing external evidence and using that retrieved information to inform generation. While dense retrieval works well for local semantic alignment, standalone ranked retrieval may yield redundant passages, overlook dependencies across chunks, and offer insufficient evidence for multi-hop reasoning.

We propose **SpectRAG**, a spectral graph-augmented retrieval framework that combines hybrid candidate seeding, weighted chunk graph construction, graph-based expansion, spectral relevance propagation, and token-budgeted context selection !!

Ask a RAG system a question for which the answer is spread across three passages and see what happens.

The retriever embeds your question and finds the six chunks of text closest to it. These are then handed to the LLM. All six will come from the same paragraph-sized section of one document. They say almost the same thing. The passage that links that section to the rest of the answer never appears because it does not resemble the question.

The model then does its best with a context window full of near-duplicates. Sometimes it guesses right. Often, it does not.

This is the problem we set out to fix with *SpectRAG*. Here is the idea in one sentence:

***Stop ranking chunks one at a time. Select a* set *of chunks that works together as evidence.***

In this post I’ll walk through why top-k retrieval breaks on multi-hop questions, how SpectRAG uses a weighted chunk graph and its Laplacian spectrum to fix it, and what we measured on MultiHopRAG and UltraDomain. That includes the parts where SpectRAG does *not* win.

Dense retrieval scores every chunk on its own: *how similar is this chunk to the query?* That works well for a lookup like “what is the boiling point of X?” When the answer needs several pieces of evidence, it breaks in three ways.

*SpectRAG* treats retrieval as a set selection problem. Rather than maximizing individual scores, our objective is to establish a context set C that is collectively beneficial.

```
F(C, q) =   Σ Rel(c, q)         ← each chunk should be relevant          − λ Σ Red(cᵢ, cⱼ)     ← …but not repeat each other          + γ Cov(C, q)         ← together they cover the question's aspects          + η Conn(C; G)        ← and they form a connected evidence path
```

If the values of λ, γ and η are set to zero, the result will be plain top-k. The remaining three terms each target one of the failure modes above. As this objective is defined over sets, it cannot be optimized by sorting a list. **Instead, SpectRAG uses a graph-based pipeline to approximate it**.

*SpectRAG* has an offline stage that runs once per corpus and an online stage that runs once per query.

Documents are split into roughly 1,200-token chunks. The splitter follows headings when they exist, places semantic breakpoints when they don’t, never cuts mid-sentence and keeps tables intact. Every chunk is embedded with nomic-embed-text.

Then comes the important part. Chunks are connected. Unlike a plain k-NN embedding graph, SpectRAG draws edges from six complementary evidence signals:

For every chunk an LLM generates the questions that chunk can answer. Two chunks that answer similar questions are *functionally* related, even if their wording is completely different.

The signals are fused into one edge weight, w_ij = Σ α_r · w_ij^(r), and weak edges are pruned so the graph stays sparse.

We take the symmetric normalized Laplacian of the graph,

```
L_sym = I − D^(-1/2) · W · D^(-1/2)
```

That gives every chunk two geometries:

1️⃣ **Hybrid seeds:** Three rankings are fused with Reciprocal Rank Fusion: dense FAISS cosine, BM25 and matching the query against the stored utility questions. This gives a high-recall seed set of 20 chunks. We deliberately over-retrieve here, because the rest of the pipeline can only reach what the seeds can reach.

2️⃣ **Graph expansion:** A two-hop breadth-first search from the seeds in Neo4j pulls in up to 200 candidates. These are neighbours that may not match the query at all but are *connected* to chunks that do.

3️⃣ **Proximity re-scoring / relevance diffusion:** This is where the spectral structure earns its keep. Conceptually, query relevance *diffuses* over the graph:

```
s' = exp(−t · L_sym) · s
```

A chunk that never matched the query can still light up if it is strongly connected to chunks that did ⤵️

4️⃣ **Token-budgeted selection:** Most retrievers return a fixed *k*. SpectRAG fills a token budget of **about 12,000 tokens** instead:

We evaluated on **MultiHopRAG** (2,556 gold-answer multi-hop questions) and four **UltraDomain** corpora (Agriculture, CS, Legal, Mix). Baselines were NaiveRAG, Hybrid (BM25 + dense), HyDE and LightRAG. Every system used the same generator, so differences in answers come from retrieval.

LightRAG builds its graph from LLM-extracted *entities*, plus separate vector stores for entities and relations. SpectRAG’s nodes are just your chunks.

➡️ Across all five corpora SpectRAG has **2.8× to 6.6×** **fewer nodes**, and on MultiHopRAG the full persisted index is **46 MB versus 274 MB**. The graph is smaller in *nodes*, not in *edges*. Each chunk has far richer connections: up to ~5.7 edges per node versus about 1 for LightRAG.

🔸On MultiHopRAG, SpectRAG recovers **91.8% of gold evidence overall**, against 76.1% for the next-best system, and leads at **Recall@10 (84.0)**. Against LightRAG it’s ahead at every cutoff and on MRR (70.4 vs 61.5).

SpectRAG has the **highest exact match (71.2), F1 (71.6)** and **answer-containment (71.6)** of the five systems. The gap to Hybrid and LightRAG is under one point. The gap to NaiveRAG and HyDE is 3–6 points.

🎢 On inference questions, the type that most needs evidence assembled across hops, **SpectRAG reaches 95.1% exact match**. Comparison and temporal questions are close to a tie, with LightRAG slightly ahead.

SpectRAG is open source (MIT). It runs with FAISS, BM25, Neo4j and a React + D3 front-end, where you can explore the chunk graph of your own documents.

```
# index a folder of documentspython main.py index papers/# ask a multi-hop questionpython main.py query "What methods improve cross-document reasoning?"
```

It can run **fully local**: Ollama embeddings, a local LLM for utility questions and spaCy NER for entities, with no API key.

If you build RAG systems, I’d love to hear where your retriever breaks. Is it redundancy, missing bridges or something else? Leave a comment, and if this was useful, a clap or a share helps other people find it 👏

*SpectRAG is joint work by Zafer Sahinoglu, Abdulazeez Mohammed, Buse Yaren Kazangirler and Cahit Berkay Kazangirler. All numbers in this post are taken from the paper’s tables. The animations of toy graphs are illustrations of the mechanism, not experimental results.*

[SpectRAG: Weighted Chunk Graphs for Token-Budgeted Context Selection in Multi-Hop…](https://pub.towardsai.net/spectrag-weighted-chunk-graphs-for-token-budgeted-context-selection-in-multi-hop-39b91ffa35c4) was originally published in [Towards AI](https://pub.towardsai.net) on Medium, where people are continuing the conversation by highlighting and responding to this story.
