Skip to content

Hybrid search and the similar-notes advisory return weak vector matches #1718

Open

Description

@phernandez

Found during the v0.24.0 acceptance test.

Default (hybrid) search returns unrelated notes for a gibberish query. In a 3-note project, search_notes(query="zzqxnonexistent") returned two notes with vector scores of 0.58 and 0.57, just above semantic_min_similarity (0.55, bge-small-en-v1.5). Text mode returns nothing. Since #1696 semantic search is always on, so this is the default experience. v0.23.2 had the same defaults, so it is not a regression.

The similar-notes advisory on write_note shows the same problem. In a project with one other, unrelated note, it suggested that note as a possible duplicate.

Investigate: for hybrid, require some lexical support or a higher vector floor when FTS finds nothing. For the advisory, use a higher threshold. Base the numbers on measurements; see the #1259 experiment.

Activity

  1. added this to the v0.24.x milestone on Oct 10, 2026
  2. claude commented on Oct 10, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 19s —— View job


    Triage

    • Type: bug (labeled bug). Hybrid search and the write_note similar-notes advisory return unrelated notes. It is not a regression, since v0.23.2 had the same defaults. Since feat(core): remove semantic_search_enabled; semantic search is always on #1696 it is the default experience.

    • Component: MCP tools (search and write_note advisory) plus the search and semantic layer. No Cloud involvement, so the component label is none.

    • Priority: Medium. The result is wrong but there is no data loss. It shows up in a basic default search path, and most visibly in small projects.

    • Complexity: Medium. The fix needs measurement, not just a code change. Two separate thresholds are involved:

      1. Hybrid search: require lexical (FTS) support, or use a higher vector floor when FTS returns nothing.
      2. Similar-notes advisory: use a higher threshold than search.

      The numbers should come from the feat: upsert_note tool — semantic dedup before write using existing embeddings #1259 experiment. Measuring them against bge-small-en-v1.5 on gibberish queries and on true near-duplicates would be the first step.

    Duplicates

    I found no exact duplicate. #1685 (closed) is related: "Default hybrid search and grep return unrelated notes instead of no results". It is worth checking whether it covered the same ground, or whether this issue is the follow-up for the vector-floor case.

    Triage only. I made no code changes.

  3. added
    bug
    on Oct 10, 2026
  4. FBISiri commented on Oct 13, 2026

    @FBISiri
    Contributor

    Saw #1722 land for the advisory half — gating the 0.70 floor on the exact embedding identity, and falling back to semantic_min_similarity elsewhere, is a careful way to keep a model-specific number from leaking onto text-embedding-3-small users.

    A question on the hybrid half, before anyone picks it up. The issue lists two options for the case where FTS finds nothing: (a) require some lexical support, or (b) raise the vector floor. Reading search_reader.py, vector-only rows currently pass straight through fuse() with their raw cosine, and the floor is applied once on the vector leg before fusion. So the two options fail differently:

    • (a) is clean for gibberish like zzqxnonexistent, but it also drops the queries where vector-only recall is the point: paraphrases that share no tokens with the note, and CJK queries — unspaced CJK compounds already get zero FTS rows (that's what tests/api/v2/test_cjk_search_guidance.py from CJK: unspaced multi-word queries miss silently (no token split, relaxed fallback not triggered) #1533 covers), so hybrid is effectively vector-only there. Under (a), those return nothing in the default mode, even though search_type="vector" would still find them.
    • (b) keeps those queries alive, but the floor is model-specific in the same way the advisory one was. The 0.58/0.57 reported for gibberish against a 0.55 floor on bge-small doesn't say anything about where noise sits on another model. And if (b) is done in _resolve_rows, it tightens pure vector mode too, not just the FTS-empty case.

    So: is the plan for (b) to reuse the same identity gating as similar_notes_min_similarity? Or is a relative criterion on the table, e.g. when FTS is empty, keep vector hits only if they clear the floor by some margin, or only if the top hit separates from the rest? A relative criterion would sidestep per-model calibration. I'm asking because we hit the same drift in our own memory store's dedup and ended up with per-type absolute thresholds, and I'm not sure that was the right call either.

    Happy to run the gibberish / paraphrase / CJK probe set against bge-small and post the score distributions here if that would help pick the number.

  5. phernandez commented on Oct 23, 2026

    @phernandez
    MemberAuthor

    Another data point from live testing of main at 0276799 (2026-10-22): in a ~15-note project, search_notes(query="zxqvnonexistentterm") (hybrid) returned 3 unrelated notes at 0.554-0.574; text mode returned none. The similar-notes advisory on write_note suggested an empty-body note (Empty Note) as similar to a long unrelated test report. Empty or near-empty notes probably embed close to everything; the advisory could skip them, like it skips generated notes (91d83d6).

  6. FBISiri commented on Oct 23, 2026

    @FBISiri
    Contributor

    Thanks, that's a useful reading. 0.554–0.574 for zxqvnonexistentterm sits just above the 0.55 floor, and text mode returning nothing means FTS contributed zero rows. So all three hits are vector-only rows that went through fuse() on raw cosine with no lexical support. That's the case the (a)/(b) split above is about, and it shows the margin over the floor is only about 0.02. That points away from an absolute floor bump and toward either (a) or a relative check for the FTS-empty case.

    The empty-body advisory hit looks like a separate mechanism. A note with almost no body embeds near the generic center of the space, so it scores "similar" to everything. Skipping empty/near-empty notes the way 91d83d6 skips generated notes seems right to me.

    I'd like to take the hybrid half: gating vector-only rows when FTS returns nothing. Before writing anything, which direction do you prefer? Lexical support required, or a relative criterion (margin over the floor, or top-hit separation)? I can post the gibberish / paraphrase / CJK score distributions on bge-small first if that would help decide.

  7. Flynn-Kawolsky commented on Nov 26, 2026

    @Flynn-Kawolsky

    Sharing a real-world CJK/English measurement directly relevant to @FBISiri's (a) vs (b) point above — strongly cautioning against option (a) (requiring lexical/FTS support when FTS returns 0 rows).

    Setup: ~574-note knowledge base (predominantly Traditional Chinese + mixed English identifiers), SQLite + sqlite-vec (measured on basic-memory 0.24.1 with script_ngrams enabled; the same word-only FTS relaxation holds on 1.0.0 and main 9d13a666), pre-registered 1,126-query eval (574 keyword-style queries embedded in sentences + 552 semantic paraphrases, single ground-truth target note per query). Tested two embedding architectures (embeddinggemma-300m and voyage-4-large, both with voyage/rerank-3 over top 20 candidates) plus 574 exact-title lookups.

    Key observation:

    • On the 1,126 natural-language queries, FTS returned 0 candidates on 1,078 / 1,126 queries (95.7%) in both architectures (because multi-clause or unspaced CJK sentences rarely match strict AND across all tokens, and hybrid relaxed retry currently relaxes only word_text, not all-CJK script_text).
    • Despite 95.7% zero-FTS rate, hybrid search achieved HR@5 = 92.18% (1,038/1,126) and MRR@5 = 0.8792 with voyage-4-large + rerank-3 (88.22% HR@5 on the 552 pure semantic paraphrases).
    • On the 574 exact-title lookups, FTS matched 574/574 and HR@5 was 99.13–99.48%.

    If option (a) gated or dropped vector-only rows whenever FTS returns nothing, 95.7% of natural-language CJK queries in default hybrid mode would silently return empty results even though the semantic + reranker leg finds the right note >92% of the time.

    If gating gibberish like zzqxnonexistent is needed, keeping any floor strictly model-identity-scoped (like #1722 did for the bge-small-en-v1.5 advisory) or letting a reranker score gate weak vector-only results avoids breaking non-English/CJK and paraphrase-heavy vaults using external embeddings (where cosine distributions differ substantially from bge-small-en-v1.5).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions