/** * hybrid.ts — Lexical scoring and score-fusion for logosdb hybrid search (#85). * * Two fusion strategies: * "rrf" — Reciprocal Rank Fusion (rank-based, distribution-free) * "weighted" — Linear interpolation combined = (1-w)*ann + w*lexical * * Lexical scoring uses a BM25-lite implementation (BM25 without IDF, i.e. purely * based on term frequency within each document relative to average document length). * This runs entirely in the MCP process over the ANN result set — no core changes. */ import type { SearchHit } from 'logosdb'; export type FusionStrategy = 'rrf' | 'weighted'; export interface HybridOptions { /** Fusion strategy (default: "rrf") */ fusion?: FusionStrategy; /** * Weight of the lexical score in "weighted" mode (0 = pure ANN, 1 = pure lexical). * Default: 0.5 */ lexical_weight?: number; /** * RRF rank constant k (default: 60). * Score = 1/(k + rank). Higher k dampens rank differences. */ rrf_k?: number; } export interface HybridHit extends SearchHit { ann_score: number; lexical_score: number; hybrid_score: number; } /** * Re-rank `hits` (already ordered by ANN score desc) using hybrid scoring. * Returns a new array sorted by hybrid_score desc, trimmed to `topK`. */ export declare function hybridRerank(hits: SearchHit[], query: string, topK: number, opts?: HybridOptions): HybridHit[]; //# sourceMappingURL=hybrid.d.ts.map