Spaces:
Sleeping
Sleeping
Commit History
-
Harden FlashRank reranking (review-driven) and wire it into the image
Aissugur Kurganbekov +1: Claude Opus 4.8Adversarial multi-agent review follow-up to the second-stage reranker: - answering.py: pool_k = max(TOP_K, RERANK_CANDIDATES) so a mis-set RERANK_CANDIDATES can never shrink the abstention gate's top-K (the abstention decision stays provably on the TF-IDF top-K). - reranking.py: guard the one-time, network-bound ranker construction with a double-checked threading.Lock — concurrent first /ask requests no longer race into two parallel model downloads; bounds-check the result->chunk remap so a changed flashrank result schema can't IndexError. - Dockerfile: flashrank ships via requirements.txt; keep the optional LLM SDKs (openai/anthropic) explicit. Verified: 28 tests pass; golden eval unchanged (7/7, 100% citation coverage, 0 unsupported, evidence-match 1.0); proved enabled-without-flashrank cites the identical set as a no-rerank build, so abstention and eval are preserved. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1b671d1 -
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