Allow to disable reranking by having an empty provider
This commit is contained in:
parent
5103e6c2d7
commit
ffe867f7bb
2 changed files with 10 additions and 6 deletions
|
|
@ -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:
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue