Team Ai
Datasetpublic

Angshul/SparseGeometricRAG

SparseGeometricRAG CPU-first sparse geometric retrieval for practical top-10 RAG No transformer inference at retrieval time. No retrieval GPU requirement. No dense document-vector dot products. No external API. SparseGeometricRAG is a retrieval system built around one systems objective: make the retrieval layer cheap enough to run on ordinary multicore CPU hardware without turning the corpus into a dense embedding database. It uses sparse TF-IDF geometry, fuzzy… See the full description on the dataset page: https://huggingface.co/datasets/Angshul/SparseGeometricRAG.

sourceHugging Facefair-noncommercial-research-licenseupdated 2mo agoView on Hugging Face
0likes323downloads
Dataset Card

SparseGeometricRAG

CPU-first sparse geometric retrieval for practical top-10 RAG

No transformer inference at retrieval time. No retrieval GPU requirement. No dense document-vector dot products. No external API.

SparseGeometricRAG is a retrieval system built around one systems objective: make the retrieval layer cheap enough to run on ordinary multicore CPU hardware without turning the corpus into a dense embedding database. It uses sparse TF-IDF geometry, fuzzy branch localization, and a tiny signed local residual code. The richer chunk-level evidence is delayed until after routing and shortlist reduction.

The project is not positioned as an accuracy-at-any-cost replacement for the strongest neural retrievers. Its selling point is the quality / latency / hardware tradeoff: useful top-10 retrieval with small structured state, bounded local computation, no retrieval-time transformer stack, and no requirement for a GPU or hosted inference service.

At a glance

PropertyFrozen design
Query representationsparse TF-IDF
Fuzzy memberships per chunkF = 4
Sparse branch-center supportB = 64 coordinates
Signed residual supportS = 16 coordinates per membership
Weak routing expansionbounded sparse neighborhood
Large-route shortlistP = 100 for the frozen six-dataset row
Final RAG outputtop 10 chunks
Retrieval-time transformernone
Retrieval-time GPUnot required
Dense vector per documentnot required

1. Why this design exists

Most modern retrieval systems optimize a learned representation and then optimize the search engine around that representation. SparseGeometricRAG changes the question: can the representation itself be made sufficiently small and local that the retrieval engine no longer needs heavyweight dense-vector machinery?

<p align="center"> <img src="figures/fig01_positioning.png" width="900" alt="SparseGeometricRAG positioning against dense and learned sparse retrieval"> </p> <p align="center"><em>Figure 1. SparseGeometricRAG changes the cost structure of retrieval. Dense and learned-sparse stacks retain a neural representation stage; the proposed stack remains sparse and CPU-native at retrieval time.</em></p>

The key design choice is to store a coarse sparse location plus a tiny local directional code, rather than a dense vector for every chunk. The query remains sparse and real-valued, so it supplies fine amplitude information at runtime while the database stores only coarse branch position and signed local deviations.

This gives three practical consequences:

  1. 1.the stored geometric state per chunk is controlled by small fixed handles;
  2. 2.the decisive local comparison is bounded by only 16 residual coordinates per routed membership; and
  3. 3.detailed lexical, semantic-support, and diversity calculations are postponed until the candidate set has already collapsed.

2. Architecture

2.1 Offline indexing

<p align="center"> <img src="figures/fig02offlineindexing.png" width="900" alt="SparseGeometricRAG offline indexing architecture"> </p> <p align="center"><em>Figure 2. Offline indexing converts each chunk into sparse lexical support, four fuzzy branch memberships, and a 16-sign local residual code. Branch centers and sparse term graphs are shared structures.</em></p>

The index is constructed from sparse normalized TF-IDF. A chunk is assigned to its strongest fuzzy branches, each branch is represented by a sparse center, and the chunk's deviation from that center is compressed to a small signed residual code. A bounded sparse term graph provides weak second-order routing support. The result is a compact index consisting of branch postings, membership weights, local sign codes, binary term support, and shared sparse structures.

The frozen structural handles are:

HandleFrozen valueRole
F4fuzzy branch memberships per chunk
B64sparse coordinates retained in each branch center
S16signed residual coordinates per chunk-branch membership
L12sparse chunk terms retained in the frozen geometry path
P100large-route shortlist for the final six-dataset row

2.2 Query-time retrieval

<p align="center"> <img src="figures/fig03querytimeretrieval.png" width="900" alt="SparseGeometricRAG query-time retrieval architecture"> </p> <p align="center"><em>Figure 3. Query-time computation is staged. Sparse routing finds candidate branch memberships; the local geometric comparison touches only 16 coordinates; detailed chunk evidence is evaluated only after shortlist reduction.</em></p>

A query is converted to sparse TF-IDF amplitudes. Weak second-order expansion is used only for routing; it is not a dense semantic representation. Routed branch postings produce candidate memberships. Each candidate is compared locally using the 16 retained signed residual coordinates, then aggregated at the document level. Cheap whole-chunk support provides an early lexical rescue/pre-score. Only a small shortlist proceeds to the richer final evidence calculation.

The final relevance score combines the geometric tail with whole-chunk lexical evidence, sparse semantic support, rare-term coverage, and coordination. Branch quality is estimated from the strongest branch-specific evidences; only high-quality branches are eligible for the small diversity bonus used for ranks 2-10. Rank 1 remains pure relevance.

2.3 What one chunk actually stores

<p align="center"> <img src="figures/fig04representationanatomy.png" width="900" alt="SparseGeometricRAG per-chunk representation anatomy"> </p> <p align="center"><em>Figure 4. The chunk-local geometric state is deliberately tiny: four fuzzy memberships and sixteen signed residual positions per membership. Branch centers and term-neighbor graphs are shared across chunks.</em></p>

The asymmetry between document and query representations is intentional. Document residual amplitudes are discarded after their signs and reliability structure have been retained; query amplitudes remain real-valued. The database therefore carries direction, while the query supplies magnitude at runtime.

This differs from dense retrieval, where every chunk generally contributes a full dense vector to the search object. Here, the local geometry is explicitly bounded by F and S, with sparse lexical support retained separately for the rescue and final evidence stages.


3. Complexity and why the method is fast

3.1 Query-time computation

Let:

  • —Q be the number of nonzero query terms;
  • —K_r be the retained routing neighbors per query term;
  • —C be the number of routed branch-membership hits;
  • —U be the number of unique routed documents;
  • —S = 16 be the residual support;
  • —P be the final shortlist size; and
  • —L_d be the average binary-support length of a shortlisted chunk.

The main query-time stages are:

StageWork
Sparse query constructionO(query tokens)
Weak routing expansionO(Q K_r)
Posting traversalO(C)
Local geometric scoring`O(C S) = O(16 C)`
Candidate aggregationO(C log C) in the frozen reference path; O(C) in the preserved stamp-aggregation optimization
Cheap lexical rescueproportional to routed/gated binary support
Shortlist selectionapproximately linear partial selection in U
Final evidence extractionperformed only on the shortlist P
Top-10 constructionsmall overhead after shortlist features are available

<p align="center"> <img src="figures/fig05computationfunnel.png" width="900" alt="SparseGeometricRAG computation funnel"> </p> <p align="center"><em>Figure 5. Corpus scale does not imply corpus-wide expensive scoring. Each stage reduces the active set before the next, richer computation is permitted to run.</em></p>

The decisive bounded term is the local geometric score: only 16 coordinates are consulted for each routed membership. Rich chunk-level evidence is deliberately positioned after routing and shortlist reduction. This is the main reason the system can stay CPU-native without replacing one expensive dense-search primitive by another.

3.2 Storage complexity

Ignoring implementation dtypes and small metadata, the structured state scales conceptually as

text
O(N F S)
+ O(M B)
+ O(M (K_assoc + K_route))
+ O(total binary term support)

where N is the number of chunks and M is the vocabulary size. The first term is the chunk-local geometric state; the second and third are shared sparse structures; the final term is the whole-chunk binary lexical support.

With the frozen F = 4 and S = 16, the local residual layer retains only 64 residual positions across the four memberships of a chunk. This is the structural reason the method does not require an N x d dense document matrix.

3.3 Preserved post-benchmark optimizations

The repository also preserves a later optimization branch that was developed after the frozen six-dataset benchmark. It introduces:

  • —stamp-based O(C) candidate aggregation instead of sort-based deduplication; and
  • —a gate before whole-chunk lexical scanning.

These optimizations are kept separate from the canonical benchmark implementation so that the reported frozen results are not silently changed after the fact.


4. Hardware and deployment requirements

<p align="center"> <img src="figures/fig06lowcost_deployment.png" width="900" alt="SparseGeometricRAG low-cost deployment architecture"> </p> <p align="center"><em>Figure 6. Retrieval needs only CPU, system RAM, and local corpus/index storage. A GPU may still be used by the generator, but it is not a dependency of the retriever.</em></p>

The low-cost hardware story is central, not incidental. SparseGeometricRAG is designed for environments where a dedicated retrieval GPU is undesirable or unavailable: inexpensive servers, lab workstations, teaching machines, air-gapped systems, and deployments where accelerator memory is reserved for generation.

DeploymentRetrieval requirementTypical reason to use it
Laptop / teaching machineordinary CPU + modest RAMdevelopment, instruction, small corpora
Commodity workstation/servermulticore CPU + more RAMlarger corpora and batch evaluation
Air-gapped / cost-constrainedCPU + local storageno hosted model/API dependency
GPU-equipped RAG systemGPU optional for generatorretrieval does not compete for accelerator memory

The claim is not that GPUs are undesirable. The claim is that the retriever is designed so they are optional rather than mandatory.


5. Why the objective is top-10 RAG

A practical generator usually consumes only a small number of retrieved chunks. For that reason, this repository treats shortlist size as a RAG operating parameter rather than assuming that the setting that maximizes deep recall must also be best for top-10 context selection.

<p align="center"> <img src="figures/fig07shortlistsweep.png" width="900" alt="SparseGeometricRAG shortlist sweep on TREC-COVID and SciFact"> </p> <p align="center"><em>Figure 7. TREC-COVID and SciFact expose opposite regimes. On the large TREC-COVID route, P = 100 is a useful denoising operating point. On the tiny SciFact route, quality continues improving as aggressive pruning is relaxed.</em></p>

This is why the final benchmark emphasizes nDCG@10, MRR@10, P@10, R@10, Hit@10, and query latency. Deep recall remains useful as a diagnostic, but it is not allowed to determine the final RAG shortlist by itself.


6. Frozen six-dataset CPU results

<p align="center"> <img src="figures/fig08frozenresults.png" width="900" alt="SparseGeometricRAG frozen six-dataset CPU benchmark heatmap"> </p> <p align="center"><em>Figure 8. Frozen 100 -> 10 effectiveness across six datasets, with representative median latencies. The result should be read as a quality/cost tradeoff rather than an accuracy-at-any-cost claim.</em></p>

6.1 OURS: concise benchmark row

DatasetnDCG@10MRR@10P@10R@10Hit@10Median latency (ms)p95 latency (ms)
SciFact0.56850.54520.07370.66630.68330.9471.031
TREC-COVID0.59900.82520.65200.01631.00001.0511.193
Quora0.73660.72870.11240.84070.8904120.301175.494
MS MARCO / DL190.34000.51890.26740.09160.720965.195142.647
HotpotQA0.46700.62550.09640.48200.750728.94442.568
NQ0.25790.22620.04620.39830.434233.68644.161

The strongest neural systems remain ahead in pure effectiveness on many datasets. SparseGeometricRAG instead targets the low-cost corner of the design space: CPU-first retrieval with bounded sparse computation and no retrieval-time neural inference.


7. Full benchmark suite

The full suite is intentionally retained. Missing entries are shown as NR; baselines are not removed merely because a compatible value is unavailable.

7.2.1 nDCG@10

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF0.57800.3738NRNRNRNR
BM250.66500.65600.78900.22800.60300.3290
MiniLM + FAISS Flat0.64510.47250.87560.36540.46510.4387
BGE-base + FAISS Flat0.74040.78070.88900.41350.72600.5415
BGE-base + FAISS HNSW0.74040.7807†0.8890†0.4135†0.7260†0.5415†
BGE-base + FAISS IVF-Flat0.72550.7807†0.8890†0.4135†0.7260†0.5415†
BGE-base + FAISS IVF-PQ0.69790.7807†0.8890†0.4135†0.7260†0.5415†
BGE-base + hnswlib HNSW0.74040.7807†0.8890†0.4135†0.7260†0.5415†
BGE-base + ScaNN0.67830.7807†0.8890†0.4135†0.7260†0.5415†
Contriever-MS MARCO + FAISS0.67700.59600.86500.40700.63800.4980
SPLADE++0.70400.72700.83400.43300.68700.5370
Modern ColBERT0.76450.83410.87540.44990.76670.6169
OURS — CPU, 100→100.56850.59900.73660.34000.46700.2579

7.2.2 MRR@10

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF0.54370.5915NRNRNRNR
BM250.64600.85300.77900.18000.80300.2630
MiniLM + FAISS Flat0.61100.7244NRNR0.4446NR
BGE-base + FAISS Flat0.70340.91800.88230.35020.86110.4924
BGE-base + FAISS HNSW0.70340.9180†0.8823†0.3502†0.8611†0.4924†
BGE-base + FAISS IVF-Flat0.68790.9180†0.8823†0.3502†0.8611†0.4924†
BGE-base + FAISS IVF-PQ0.66150.9180†0.8823†0.3502†0.8611†0.4924†
BGE-base + hnswlib HNSW0.70340.9180†0.8823†0.3502†0.8611†0.4924†
BGE-base + ScaNN0.64940.9180†0.8823†0.3502†0.8611†0.4924†
Contriever-MS MARCO + FAISS0.6207NRNRNRNRNR
SPLADE++0.6699NRNR0.3830NRNR
Modern ColBERT0.73900.95330.86710.38490.91880.5655
OURS — CPU, 100→100.54520.82520.72870.51890.62550.2262

7.2.3 Precision@10

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF0.07970.4020NRNRNRNR
BM250.08630.6360~0.1200NRNRNR
MiniLM + FAISS Flat0.08830.50400.13370.05910.09740.0770
BGE-base + FAISS Flat0.09870.83000.13460.06560.15150.0884
BGE-base + FAISS HNSW0.09870.8300†0.1346†0.0656†0.1515†0.0884†
BGE-base + FAISS IVF-Flat0.09730.8300†0.1346†0.0656†0.1515†0.0884†
BGE-base + FAISS IVF-PQ0.09500.8300†0.1346†0.0656†0.1515†0.0884†
BGE-base + hnswlib HNSW0.09870.8300†0.1346†0.0656†0.1515†0.0884†
BGE-base + ScaNN0.08870.8300†0.1346†0.0656†0.1515†0.0884†
Contriever-MS MARCO + FAISS0.0883NRNRNRNRNR
SPLADE++0.0937NRNRNRNRNR
Modern ColBERT0.09770.88200.13270.07010.15480.0979
OURS — CPU, 100→100.07370.65200.11240.26740.09640.0462

7.2.4 Recall@10

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF0.71350.0105NRNRNRNR
BM250.78090.01580.8854NR0.6531NR
MiniLM + FAISS Flat0.78330.01280.95030.56760.48700.6471
BGE-base + FAISS Flat0.87420.02210.95740.62770.75740.7469
BGE-base + FAISS HNSW0.87420.0221†0.9574†0.6277†0.7574†0.7469†
BGE-base + FAISS IVF-Flat0.86090.0221†0.9574†0.6277†0.7574†0.7469†
BGE-base + FAISS IVF-PQ0.84410.0221†0.9574†0.6277†0.7574†0.7469†
BGE-base + hnswlib HNSW0.87420.0221†0.9574†0.6277†0.7574†0.7469†
BGE-base + ScaNN0.78140.0221†0.9574†0.6277†0.7574†0.7469†
Contriever-MS MARCO + FAISS0.7868NRNRNRNRNR
SPLADE++0.8230NRNRNRNRNR
Modern ColBERT0.86470.02300.95160.67100.77390.8239
OURS — CPU, 100→100.66630.01630.84070.09160.48200.3983

7.2.5 Hit@10

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF0.73330.8600NRNRNRNR
BM250.80331.00000.9286NRNRNR
MiniLM + FAISS FlatNRNRNRNRNRNR
BGE-base + FAISS Flat0.8833NRNRNRNRNR
BGE-base + FAISS HNSW0.8833NRNRNRNRNR
BGE-base + FAISS IVF-Flat0.8700NRNRNRNRNR
BGE-base + FAISS IVF-PQ0.8567NRNRNRNRNR
BGE-base + hnswlib HNSW0.8833NRNRNRNRNR
BGE-base + ScaNN0.7900NRNRNRNRNR
Contriever-MS MARCO + FAISS0.7967NRNRNRNRNR
SPLADE++0.8333NRNRNRNRNR
Modern ColBERT0.8100NRNRNRNRNR
OURS — CPU, 100→100.68331.00000.89040.72090.75070.4342

7.2.6 Median query latency (ms)

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF6.19750.185NRNRNRNR
BM250.5614.912NRNRNRNR
MiniLM + FAISS FlatNRNRNRNRNRNR
BGE-base + FAISS Flat10.013NRNRNRNRNR
BGE-base + FAISS HNSW10.369NRNRNRNRNR
BGE-base + FAISS IVF-Flat10.050NRNRNRNRNR
BGE-base + FAISS IVF-PQ13.910NRNRNRNRNR
BGE-base + hnswlib HNSW10.594NRNRNRNRNR
BGE-base + ScaNN9.947NRNRNRNRNR
Contriever-MS MARCO + FAISS7.472NRNRNRNRNR
SPLADE++13.493NRNRNRNRNR
Modern ColBERT62.671NRNRNRNRNR
OURS — CPU, 100→100.9471.051120.30165.19528.94433.686

7.2.7 p95 query latency (ms)

MethodSciFactTREC-COVIDQuoraMS MARCO / DL19HotpotQANQ
Exact TF-IDF14.60556.716NRNRNRNR
BM255.6457.336NRNRNRNR
MiniLM + FAISS FlatNRNRNRNRNRNR
BGE-base + FAISS Flat15.398NRNRNRNRNR
BGE-base + FAISS HNSW12.925NRNRNRNRNR
BGE-base + FAISS IVF-Flat16.303NRNRNRNRNR
BGE-base + FAISS IVF-PQ18.496NRNRNRNRNR
BGE-base + hnswlib HNSW13.293NRNRNRNRNR
BGE-base + ScaNN11.858NRNRNRNRNR
Contriever-MS MARCO + FAISS9.628NRNRNRNRNR
SPLADE++19.156NRNRNRNRNR
Modern ColBERT70.994NRNRNRNRNR
OURS — CPU, 100→101.0311.193175.494142.64742.56844.161

Notes. NR means “not reported under a compatible metric / protocol in the current ledger.” † indicates that, outside SciFact, the BGE ANN-backend rows mirror the BGE-base representation-level effectiveness reference rather than a separately rerun backend-specific effectiveness experiment.


8. Interpreting the latency numbers

Speed comparisons in retrieval are easy to misstate. ANN papers frequently report search-only latency after a dense query embedding already exists, whereas a deployed RAG request pays for query representation, retrieval, shortlist scoring, and final selection.

This repository therefore follows two rules:

  1. 1.do not silently compare ANN-only latency with end-to-end retrieval latency; and
  2. 2.do not fill missing latency cells using measurements from incompatible hardware or protocols.

The full provenance policy is documented in docs/BASELINE_SUITE.md and docs/LITERATURE_AND_SPEED.md. The frozen OURS timings include the retrieval path used by the reported experiment. For the MS MARCO column, OURS is the 43-query TREC-DL19 run on the full 8.84M-passage corpus; published model-reference values in that column may use MS MARCO dev where applicable.


9. Repository organization

The repository is deliberately split between reusable retrieval code, clean benchmark runners, the full-scale experimental campaign, and frozen outputs.

PathPurpose
geomretrieval/reusable sparse geometric retriever
experiments/beir/BEIR runners and pool-sweep experiments
experiments/msmarco_scale/full MS MARCO scale campaign
experiments/postbenchmark_optimizations/preserved later optimization branch
results/frozen JSON outputs and benchmark artifacts
configs/reproduction handles
baselines/baseline utilities
scripts/runnable helpers
docs/method, RAG protocol, baseline, speed, and reproducibility notes
tests/smoke tests
manifests/corpus / run manifests

The final six-dataset artifacts are under results/final_100_to_10/. The later stamp-aggregation and lexical-gating optimization results are preserved separately and are not used to rewrite the frozen benchmark row.


10. Reproducibility

The repository contains the exact frozen result JSONs, benchmark scripts, configuration handles, and tests used to reconstruct the final evaluation. The reference package was checked with the project smoke tests before release.

For a clean reproduction path, start with:

  1. 1.docs/METHOD.md - algorithmic description;
  2. 2.docs/RAG_PROTOCOL.md - top-10 evaluation protocol;
  3. 3.docs/REPRODUCIBILITY.md - environment and run guidance;
  4. 4.docs/BASELINE_SUITE.md - baseline/provenance policy; and
  5. 5.results/final_100_to_10/ - frozen final outputs.

The code is intentionally CPU-first. Baseline packages that depend on neural encoders or ANN libraries are listed separately from the core requirements.


11. Scope of the claim

What this repository claims

  • —a CPU-first retrieval architecture with no retrieval-time transformer inference;
  • —no requirement for a dense vector per document or a GPU-based retrieval service;
  • —fixed small structural handles (F = 4, B = 64, S = 16) controlling local geometry;
  • —local geometric scoring bounded by O(CS) with S = 16 fixed;
  • —deliberate postponement of richer chunk-level computation until after routing and shortlist reduction;
  • —a practical top-10 RAG operating point validated across six datasets;
  • —complete benchmark tables rather than selective reporting of only OURS.

What it does not claim

  • —dominance over the strongest neural retrievers in pure effectiveness;
  • —that every latency cell in the literature is directly comparable across hardware and protocol;
  • —that one shortlist size is mathematically optimal for every dataset or route size;
  • —that deep recall is irrelevant. It is retained as a diagnostic, but it is not the sole deployment objective.

12. License

This repository is released under the Fair Noncommercial Research License selected on the Hugging Face repository. Check the repository license metadata and license text before redistribution or commercial use.