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. 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 (Default)
Ollama reranking uses LLMs with structured output to rank documents by relevance: 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.config import Config
from haiku.rag.reranking.base import RerankerBase from haiku.rag.reranking.base import RerankerBase
try:
from haiku.rag.reranking.cohere import CohereReranker
except ImportError:
pass
_reranker: RerankerBase | None = None _reranker: RerankerBase | None = None
def get_reranker() -> RerankerBase | None: def get_reranker() -> RerankerBase | None:
""" """
Factory function to get the appropriate reranker based on the configuration. 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 global _reranker
if _reranker is not None: if _reranker is not None:
return _reranker return _reranker
if Config.RERANK_PROVIDER == "mxbai": if Config.RERANK_PROVIDER == "mxbai":
try: try:
from haiku.rag.reranking.mxbai import MxBAIReranker from haiku.rag.reranking.mxbai import MxBAIReranker