WOLBΛRG

Hybrid Search

Combine semantic vectors with BM25 keyword scores for more robust recall.

What is it?

Hybrid search fuses semantic similarity with BM25 keyword scores so recall works for both meaning and exact tokens (IDs, product names, error codes).

Why does it exist?

Pure vector search can miss rare tokens. Pure keyword search misses paraphrase. Fusion covers both modes.

How does it work?

Setup

import { bm25 } from "wolbarg";

new Wolbarg({
  /* organization, storage, embedding */
  keywordSearch: bm25(),
});

Usage

await ctx.recall({
  query: "quick brown fox",
  hybrid: true,
  // or
  hybrid: { semanticWeight: 0.7, keywordWeight: 0.3 },
});

Scores are normalized then fused. Tune weights for keyword-heavy vs semantic-heavy corpora.

Fallback

If keywordSearch is not configured, hybrid quietly falls back to semantic-only search.

When should it be used?

Enable hybrid when queries contain proprietary names, codes, or short literal strings mixed with natural language.

Performance notes

  • Requires FTS indexing on SQLite (schema v2) or equivalent keyword path
  • Keyword index updates happen with remember/ingest/forget
  • Slightly higher recall-time cost than semantic-only