This walkthrough runs a compact teaching implementation of the method on a 12-chunk corpus, so that every step fits on screen. Its parameter values (budget, core size, selection weights, α) are chosen for that corpus and differ from the package defaults. Each step names the package function that does the same job.

SpectraFuse, step by step

The pipeline from the SpectRAG paper, run on a 12-chunk toy corpus. Every number below comes from an actual run of a compact teaching version of the method. Click a step, a chunk, or an edge to see what the method is doing and why.

Answering it needs two chunks: c4 says who does the research, c6 says where that lab is.

Offline indexing, once per corpus

Online retrieval, per query

Same budget, two different contexts

Dense top-k fills the token budget in similarity order. SpectraFuse fills it with the set-level utility from Eq. 21. Move the sliders to see how each term changes what reaches the generator.

B in Eq. 19
(1−α)·relevance + α·proximity
max cosine to chunks already chosen
reward for an unseen spectral community

Which part does the work?

An ablation on this query, computed live in your browser with the same selector, at the default budget of 70 tokens.

Run it yourself

The pip package runs the same stages; each step above names the function that does it. Its chunker keeps headings in the chunk text, and its entity rules and default settings differ from the teaching version, so on this toy corpus it picks different chunks. Start from the quick start.

from spectrafuse import SpectRAGIngestion, SpectRAGRetrieval

SpectRAGIngestion("my_index").ingest("docs/")             # Table 1: chunk, embed, graph, spectral

search = SpectRAGRetrieval("my_index")
result = search.search(QUESTION, token_budget=4000)        # Table 2: seeds, expand, re-score, select
print(result["prompt"])

# plug in any LLM for the last stage: a function prompt -> text
out = search.answer(QUESTION, llm_fn=my_llm, token_budget=4000)
print(out["answer"])