Skip to content

fix: label grounding none when rare share and margin are both low - #66

Merged
hmbanan666 merged 1 commit into
mainfrom
cursor/grounding-none-rule-8c3c
Nov 15, 2026
Merged

hmbanan666 merged 1 commit into
mainfrom
cursor/grounding-none-rule-8c3c

Conversation

@hmbanan666

Copy link
Copy Markdown
Owner

Summary

With embeddings, grounding is none when the uncommon share is below CONTEXT_GROUNDING_LEXICAL_NONE (default 0.30) and the margin is below CONTEXT_GROUNDING_MARGIN_WEAK, even if a rare term matched. Otherwise weak and strong are unchanged. MARGIN_WEAK default is now 0.024 (was 0.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. cosineSource is vector when that cosine or a search hit was used, and missing when 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 stays missing.

context grounding explain prints rule and cosineSource.

No deploy.

Tests

  • pnpm run check — lint, typecheck, 271 tests passed
  • pnpm run eval:grounding with Xenova/multilingual-e5-small in .output/models (q8 ONNX 118,308,185 bytes):
    • curated lexical 10/10 on, 10/10 off none
    • curated semantic 10/10 on, 10/10 off none (on margin min 0.014, off margin about −0.8)
    • mixed lexical 10/10 on, 10/10 off not-strong (none 10)
    • mixed semantic 10/10 on, 10/10 off not-strong (none 3, weak 7, strong 0)
  • pnpm run eval:projects — recall 1, pack-hit 1, exit 0
  • pnpm run eval:retrieval — exit 0. semantic: unavailable because that command loads models/, not .output/models. Required lexical questions passed. Paraphrase questions still fail lexically, as before.

Friction

  1. Nothing took abnormally long. pnpm run check was 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 from dist/.
  2. Node 24 had to be put on PATH ahead of /exec-daemon/node (v22), or node and pnpm were the wrong runtime. The branch is cursor/grounding-none-rule-8c3c because this runner appends -8c3c; the requested name was cursor/grounding-none-rule.
  3. node --experimental-strip-types scripts/download-search-model.ts fails: Node resolves the .ts import to src/embedding-model.js. The documented command is node dist/scripts/download-search-model.js after tsc (docs/search.md). eval:grounding looks in models/ and .output/models (test/evaluate-grounding.ts); eval:retrieval uses localEmbedder() and only models/ (src/embedding-model.ts). Weights in models/ also make pnpm run check load the model (docs/search.md). check, eval:grounding, eval:projects, and eval:retrieval each run a full tsc.
  4. Put Node 24.22.1 ahead of /exec-daemon/node on the default PATH. Build once, then run the three eval entrypoints. Point localEmbedder() at .output/models as well as models/, so one download covers semantic retrieval without putting weights where pnpm run check will load them.
Open in Web Open in Cursor 

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>
@hmbanan666
hmbanan666 merged commit 104f1dc into main Nov 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants