Spaces:
Sleeping
Sleeping
Commit History
-
Add two-stage retrieval: TF-IDF -> optional FlashRank reranking
Aissugur Kurganbekov +1: Claude Opus 4.8Adapts the hybrid-search RAG pattern from awesome-llm-apps (Apache-2.0) as a second retrieval stage. A small cross-encoder (FlashRank, ms-marco-TinyBERT, ~3 MB CPU) reorders the TF-IDF candidates so the most relevant evidence is cited first and fed to the LLM first. - reranking.py: lazy, cached ranker with graceful fallback — if flashrank or the model is unavailable it returns the TF-IDF order, so the app never breaks and still runs fully offline. - answering.py: pull a larger TF-IDF candidate pool when reranking is on, but keep the abstention DECISION on the original top-K, so behaviour and the golden eval are unchanged whether or not the reranker is present. - config: RERANK_ENABLED / RERANK_CANDIDATES / RERANK_MODEL (env-tunable). - Tests for the disabled/unavailable fallbacks and the reorder path (28 pass, golden eval still 100% citation coverage / 0 unsupported). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>ba9f2db