Allow to disable reranking by having an empty provider

This commit is contained in:
Yiorgis Gozadinos 2025-08-10 21:02:17 +02:00
parent 5103e6c2d7
commit ffe867f7bb
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View file

@ -109,6 +109,14 @@ Reranking improves search quality by re-ordering the initial search results usin
Reranking is **automatically enabled** by default using Ollama, or if you install the appropriate reranking provider package.
### Disabling Reranking
To disable reranking completely for faster searches:
```bash
RERANK_PROVIDER=""
```
### Ollama (Default)
Ollama reranking uses LLMs with structured output to rank documents by relevance:

View file

@ -1,22 +1,18 @@
from haiku.rag.config import Config
from haiku.rag.reranking.base import RerankerBase
try:
from haiku.rag.reranking.cohere import CohereReranker
except ImportError:
pass
_reranker: RerankerBase | None = None
def get_reranker() -> RerankerBase | None:
"""
Factory function to get the appropriate reranker based on the configuration.
Returns None if the required package is not available.
Returns None if if reranking is disabled.
"""
global _reranker
if _reranker is not None:
return _reranker
if Config.RERANK_PROVIDER == "mxbai":
try:
from haiku.rag.reranking.mxbai import MxBAIReranker