Repository navigation
Hybrid search and reranking behind switches (spec 019) - #19
Merged
Merged
Conversation
…(spec 021) dotnet run on an AppHost with AspireUseCliBundle starts bin/Debug whatever configuration is passed, so the Release-only build gave the first nightly run nothing to start. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s (specs 018, 021) From the first passing nightly run (39445089883, qwen3:1.7b, 87 cases): - the threshold sweep moves Documents:Retrieval:ConfidentScore from 0.60 to 0.55 (behaviour 0.71 -> 0.83, refusals and recall unchanged); MinScore 0.55 and DuplicateOverlap 0.8 stay. The low-confidence tier is empty by default as a result, which spec 018's Calibration records. - qwen3:1.7b follows the injected passage of i-en-01; ministral-3:8b and llama3.2:3b resist the same prompt when sent by hand. - spec 021's Verification records both dispatches and the Debug-build fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Hybrid search (Documents): passages get search_config (english, documents.french_unaccent or simple, from the document language, kept in step by database triggers on insert and on a language change) and a generated, GIN-indexed search_vector. In hybrid mode a keyword pool (websearch_to_tsquery in the question's language, ts_rank_cd, same filters and ReadableBy as the vector pool, fetched while the query is embedded) is fused with the vector pool by reciprocal rank fusion. Reranking: IPassageReranker in the shared kernel, implemented by the API with Text Embeddings Inference serving bge-reranker-v2-m3 (ADR 0010). The best candidates go in one call with their own timeout; reranked results are ordered and gated by the rerank score, and any failure falls back to cosine gating as "rerank: skipped". The AppHost starts TEI only with the https-rerank launch profile. Diagnostics: every passage carries PassageStages (vector and keyword ranks, cosine, ts_rank_cd, fused and rerank scores, admittedBy). The search endpoint takes mode, rerank and queryLanguage overrides; the SSE stream, request trace (migration RetrievalStages), admin inspector, activity, configuration and Chat metrics record mode and rerank status. Harness: run --variants measures retrieval for vector, hybrid and hybrid + rerank on the same queries; reports record the stage settings, a run mixing retrieval modes is invalid, and sweep calibrates rerank thresholds on their own grid. Both stages stay off until the calibration in spec 019 decides. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Vector against hybrid on the same queries every night; without a reranker on the runner the rerank variant is skipped at no cost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements spec 019. Both stages ship switched off: the evaluation gate (AC-20 to AC-22) is deferred until after spec 020.
Hybrid search (Documents)
HybridSearch:unaccentextension and thedocuments.french_unaccenttext search configuration;passages.search_config(english,documents.french_unaccentorsimple) and a generated, GIN-indexedsearch_vector.websearch_to_tsqueryin the question's language (SearchFilters.QueryLanguage, detected question language, never the requested answer language), ranked withts_rank_cd. It uses the same filters andReadableByas the vector pool and is fetched while the query is embedded.Documents:Retrieval:Hybrid:RrfK, default 60). Without reranking, cosine still gates, so a keyword-only hit needs cosine ≥MinScore.Reranking
IPassageRerankerinSharedKernel/Contracts/Retrieval. The API implements it with a typedHttpClientagainst Text Embeddings Inference servingBAAI/bge-reranker-v2-m3(ADR 0010, imagecpu-1.9.4).Candidates(30) go in one call with a 2 s timeout. They are then reordered and gated by the rerank score (Reranking:MinScore/ConfidentScore), and near-duplicate reduction and topK apply after.rerank: skippedand cosine gating, plus adocuments.rerank.skippedcounter. A question never fails because of the reranker.rerankercontainer exists only with the newhttps-reranklaunch profile, or--Parameters:reranking=true.Diagnostics
ts_rank_cd, fused and rerank scores,admittedBy.RetrievalStages) and the admin request inspector. The activity panel and the SSEretrieval.completedevent showmode,rerankandadmittedByonly.mode,rerankandqueryLanguage.documents.rerank.duration,documents.rerank.skipped,documents.search.keyword_hits, and the Chat metrics taggedretrieval.mode.Harness
run --variantsmeasures retrieval for vector, hybrid and hybrid + rerank on the same queries.sweepcalibrates rerank thresholds on their own grid.--variants; without TEI on the runner, the rerank variant is skipped.Docs
ADR 0010, CLAUDE.md (module table, stack, commands) and the
rag-pipelineskill.Measured so far (not the gate)
cpu-1.9.4on the reference machine: 18–24 s to rerank 30 corpus-length passages, against the 800 ms budget. Relevant passages scored 0.99, unrelated ones 0.0000. With the 2 s default timeout, reranking is skipped on a CPU.unaccentships with the pinnedpgvector/pgvector:0.8.7-pg18-trixieimage, as the spec required.Test plan
dotnet buildwith 0 warnings, anddotnet format --verify-no-changescleanChatMetricsTestsfor the new low-cardinalityretrieval.modelabelHybridRankingTests(AC-9, ordering, stages, rerank order);HybridSearchTests(AC-1 to AC-8, AC-15, AC-16);RerankingTests(AC-10, AC-12 to AC-14);RetrievalStagesTests(AC-11, AC-12 trace, AC-17, keyword configuration of the question's language);TeiPassageRerankerTests.https-rerank(API and Keycloak ready), but whether TEI came up and the API reached it was not checked before the run was stoppedHybrid:EnabledandReranking:Enabledstayfalse🤖 Generated with Claude Code