Repository navigation
fix: label grounding none when rare share and margin are both low - #66
Merged
Merged
Conversation
A matched rare term could never be none. With embeddings, none now also applies when the uncommon share is below CONTEXT_GROUNDING_LEXICAL_NONE (default 0.30) and the margin is below CONTEXT_GROUNDING_MARGIN_WEAK. The weak default is 0.024 because the public curated and mixed evals, lexical and semantic, stayed green. The lexical-only path uses the same share floor. A rare passage dropped by the 0.80 vector list uses its stored chunk cosine, and grounding explain prints the rule and cosineSource. Co-authored-by: Nick Kosarev <nick@kosarev.space>
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
With embeddings, grounding is
nonewhen the uncommon share is belowCONTEXT_GROUNDING_LEXICAL_NONE(default0.30) and the margin is belowCONTEXT_GROUNDING_MARGIN_WEAK, even if a rare term matched. Otherwise weak and strong are unchanged.MARGIN_WEAKdefault is now0.024(was0.03) because the public curated and mixed evals stayed green on both the lexical and semantic paths. The lexical-only path uses the same share floor; those evals stayed green too.A rare-term passage that missed the 0.80 / top-20 vector list no longer counts as cosine 0. Search already has the query vector, so grounding reads that passage's stored chunk and dots it.
cosineSourceisvectorwhen that cosine or a search hit was used, andmissingwhen the chunk has no stored vector (cosine counts as 0, margin about minus the centroid). The passage is not embedded again. A rendered profile section has no chunk row and staysmissing.context grounding explainprintsruleandcosineSource.No deploy.
Tests
pnpm run check— lint, typecheck, 271 tests passedpnpm run eval:groundingwithXenova/multilingual-e5-smallin.output/models(q8 ONNX 118,308,185 bytes):nonenone(on margin min 0.014, off margin about −0.8)pnpm run eval:projects— recall 1, pack-hit 1, exit 0pnpm run eval:retrieval— exit 0.semantic: unavailablebecause that command loadsmodels/, not.output/models. Required lexical questions passed. Paraphrase questions still fail lexically, as before.Friction
pnpm run checkwas 25s,eval:grounding(including the semantic reindex) was 14s, projects plus retrieval was 5s. The model download was 1.5s after the script was run fromdist/.PATHahead of/exec-daemon/node(v22), ornodeandpnpmwere the wrong runtime. The branch iscursor/grounding-none-rule-8c3cbecause this runner appends-8c3c; the requested name wascursor/grounding-none-rule.node --experimental-strip-types scripts/download-search-model.tsfails: Node resolves the.tsimport tosrc/embedding-model.js. The documented command isnode dist/scripts/download-search-model.jsaftertsc(docs/search.md).eval:groundinglooks inmodels/and.output/models(test/evaluate-grounding.ts);eval:retrievaluseslocalEmbedder()and onlymodels/(src/embedding-model.ts). Weights inmodels/also makepnpm run checkload the model (docs/search.md).check,eval:grounding,eval:projects, andeval:retrievaleach run a fulltsc./exec-daemon/nodeon the default PATH. Build once, then run the three eval entrypoints. PointlocalEmbedder()at.output/modelsas well asmodels/, so one download covers semantic retrieval without putting weights wherepnpm run checkwill load them.