Skip to content

FB-004: Adaptive search threshold for hash vs ONNX embeddings#17

Merged
sparkling merged 1 commit intomainfrom
patch/FB-004-adaptive
Mar 13, 2026
Merged

FB-004: Adaptive search threshold for hash vs ONNX embeddings#17
sparkling merged 1 commit intomainfrom
patch/FB-004-adaptive

Conversation

@sparkling
Copy link
Copy Markdown
Owner

Fixes #3

Detects embedding model at runtime and applies 0.05 (hash) or 0.3 (ONNX) threshold instead of hardcoded 0.3 that filtered out 90% of results with hash embeddings.

Hash fallback embeddings produce similarity ~0.05-0.28 (not semantic).
The hardcoded 0.3 threshold filtered out 90% of results, causing silent
empty search results when ONNX is unavailable.

Fix: detect embedding model at runtime and apply appropriate threshold:
  - ONNX (MiniLM-L6): 0.3 (meaningful similarity scores)
  - Hash fallback: 0.05 (permissive, ranking is noise)

Changed files:
  - memory-initializer.ts: getAdaptiveThreshold() helper, searchEntries()
  - memory-bridge.ts: _getAdaptiveThreshold() with cached model detection,
    bridgeSearchEntries(), bridgeSemanticSearch(), bridgeSearchPatterns(),
    bridgeLoadSessionPatterns()

Co-Authored-By: claude-flow <ruv@ruv.net>
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.

FB-004: Lower search threshold for hash embeddings

1 participant