Repository navigation
corpus: lexical_support, an absolute measure of how well a query is c… - #2
Merged
Merged
Conversation
…overed Nothing in a search result says whether the corpus can answer the query at all. The fused score is min-max normalized per query, so the top hit sits near 1 for any query, answerable or not; a host that gates on it can only pick a cut-off inside that narrow band, and the band moves with fusion settings and with the dense retriever on or off. lexical_support(query) divides the best live chunk's BM25 score by the most this query could score (Bm25Index::ceiling: each distinct term at saturation, idf * (k1 + 1); a term the corpus lacks counts at full idf). The result is in [0, 1) on any corpus, and the top hit is not 1 by construction. It also returns how many distinct analyzed terms the query had, so a host can refuse to trust a two-word query that matched by luck. Measured on agentty's docs (50 labelled answerable questions) and its source tree (100), each against 36 questions the corpus cannot answer, it separates them with ROC AUC 0.89 on both, where the raw BM25 score, the next best, needs a different cut-off per corpus (11.1 vs 12.6).
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.
corpus: lexical_support, an absolute measure of how well a query is covered
Problem
A search result doesn't say whether the corpus can answer the query at all. The fused score is min-max normalised per query (
convex_combination, after Bruch et al.), so the top hit scores near 1 for any query. A host deciding whether to use the results, for example to inject them into a prompt unasked, can only pick a cut-off inside that narrow band. The band also moves with fusion settings and with the dense retriever on or off.In agentty, which gates proactive retrieval on that score with a bar of 0.35, all 160 injections in one user's history scored between 0.90 and 0.96, so the bar never rejected anything. Re-scored with this measure, 157 of those 160 injections would have been rejected. In the sample read by hand, the injected memory facts were unrelated to the question.
Change
Bm25Index::ceiling(terms): the most any document could score for those terms, which is every distinct term at saturation: Σ idf(nₜ) · (k1 + 1). A term the corpus lacks counts at its full idf, so a query about something the corpus never mentions has a high ceiling that no document approaches.Corpus::lexical_support(query): the best live chunk's BM25 score divided by that ceiling, together with the number of distinct analysed query terms.lexical_search.Nothing existing changes.
Evidence
The real engine indexed agentty's docs (50 labelled answerable questions from its retrieval eval) and its source tree (100 labelled), with 36 questions neither corpus answers (20 general knowledge, 16 tasks for tools). ROC AUC measures how well each score separates answerable from unanswerable questions:
Raw BM25 separates comparably, but its best cut-off was 11.1 on one corpus and 12.6 on the other.
lexical_supportworked with one cut-off on both: at 0.35 it keeps 86% / 80% of the answerable questions and lets none of the 20 general-knowledge questions through.Tasks whose words appear in the corpus ("show me the git log") can't be separated by any corpus-side score. agentty filters those by wording before it retrieves.
Tests
lexical_support_is_low_for_queries_the_corpus_does_not_answer:Only syntax-checked here. Please run
ctest.