RankFuse
Hybrid retrieval (dense + sparse + RRF fusion + optional reranking) for RAG pipelines.
Plug it in with two method calls — ingest() and search() — and your pipeline gets keyword-aware hybrid search with Reciprocal Rank Fusion on top of your existing dense embeddings.
Install
pip install rankfuse
Lightweight install (~20MB): pulls in chromadb, rank-bm25, google-genai, and pydantic. No PyTorch or GPU binaries. Uses Gemini for embeddings and the optional LLM-judge reranker.
To use the local cross-encoder reranker (adds sentence-transformers + PyTorch, ~1-2GB on first use):
pip install rankfuse[cross-encoder]
Requires Python 3.10+. You'll need a Gemini API key for embeddings.
Quickstart
from rankfuse import Retriever, RetrieverConfig
config = RetrieverConfig(
embedder_provider="gemini",
api_key="your-gemini-api-key", # or set GEMINI_API_KEY env var
persist_dir="./my_index",
reranker_type="cross_encoder", # or "llm_judge", or "none"
)
retriever = Retriever(config)
retriever.ingest([
{"id": "doc1", "text": "Refunds are processed within 5-7 business days.", "metadata": {"source": "faq"}},
{"id": "doc2", "text": "To reset your password, go to Settings > Security.", "metadata": {"source": "faq"}},
{"id": "doc3", "text": "Check order status by logging into your dashboard.", "metadata": {"source": "faq"}},
])
results = retriever.search("what is the refund policy?", top_k=5)
for r in results:
print(r.doc_id, r.score, r.text[:80])
Run the full working example:
GEMINI_API_KEY=your-key python examples/quickstart.py
What it does
Standard RAG pipelines search with dense embeddings only. Dense embeddings are good at semantic similarity but miss exact keyword matches — a query for "RFC 7231" won't reliably surface a document that only contains the literal text "RFC 7231" unless the embedding space happens to capture it.
RankFuse adds a BM25 sparse index alongside the dense index, runs both in parallel, and merges the results using Reciprocal Rank Fusion (RRF). RRF works on rank position rather than raw scores, so it doesn't require normalization between the two score scales — it's simple and robust.
Optionally, a reranker (local cross-encoder or Gemini LLM-judge) does a precision pass over the fused top-N candidates before returning the final results.
Reranker options
reranker_type |
What it uses | Cost |
|---|---|---|
"cross_encoder" |
ms-marco-MiniLM-L-12-v2 (local, no API) |
Free, ~200MB model download on first use |
"llm_judge" |
Gemini (API call per candidate) | API quota cost |
"none" |
No reranking, returns RRF-fused results directly | Free |
Benchmark
Evaluated on 30 queries over the full FastAPI documentation corpus (154 documents). Hybrid search with stopword-filtered BM25 closes the candidate recall gap versus dense-only search — hybrid RRF-only matches dense-only at Recall@5 (0.90) while also providing exact-term coverage dense alone misses.
The standard equal-weight RRF configuration doesn't improve Recall@1 on this particular corpus — the release notes document causes keyword concentration that inflates BM25 scores for non-tutorial results. See benchmarks/results.md for the full methodology, diagnostic breakdown, and honest discussion of where hybrid search helps and where it doesn't.
Swap in your own embedder or store
from rankfuse.embeddings.base import Embedder
class MyEmbedder(Embedder):
def embed(self, texts: list[str]) -> list[list[float]]:
# your embedding logic here
...
retriever = Retriever(config, embedder=MyEmbedder())
See examples/custom_embedder.py for a full working example.
Docs
- Architecture — how the components connect
- API Reference — full config fields and method signatures
- Benchmark Results — methodology and findings
- FastAPI integration example
License
MIT
Metadata
Release files for rankfuse 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| rankfuse-0.1.1.tar.gz | 15.3 kB | With provenance | Details for rankfuse-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| rankfuse-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for rankfuse-0.1.1-py3-none-any.whl |
Total release size: 33.4 kB
Release files / rankfuse-0.1.1.tar.gz
| Download URL | rankfuse-0.1.1.tar.gz |
|---|---|
| Size | 15.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
009cee133640462087c8e9b95b92b58f1d2a540359e5e26f25b72179e1ddf9f5
|
|
BLAKE2b-256 checksum How to use checksums |
a5465d867f3a32d8797b0af3a57392f73d06632203b736f6d02ff9c5a4d60109
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.
Transparency logRelease files / rankfuse-0.1.1-py3-none-any.whl
| Download URL | rankfuse-0.1.1-py3-none-any.whl |
|---|---|
| Size | 18.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6a3bd551098572c6c8e804fc3384c39b074e050de531155f425e7c8ede7984db
|
|
BLAKE2b-256 checksum How to use checksums |
688cdafd2c5d07be55802a5aa244721468e763f563975f0c0b60eda156081aa7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.
Transparency logSecurity for rankfuse 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for rankfuse-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 21, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.