/** * Hybrid Search * * Combines vector search (semantic) with keyword search (lexical) * using Reciprocal Rank Fusion (RRF) for reranking */ import { IHybridSearch } from '@massa-th0th/shared'; import { SearchResult, RetrievalOptions } from '@massa-th0th/shared'; /** * Hybrid Search implementation */ export declare class HybridSearch implements IHybridSearch { private vectorStore; private keywordSearch; constructor(); /** * Search using both vector and keyword search */ search(query: string, options: RetrievalOptions): Promise; /** * Rerank results using Reciprocal Rank Fusion (RRF) * * RRF formula: score(d) = Σ 1 / (k + rank(d)) * where k is a constant (typically 60) and rank is the position in each list */ rerank(resultSets: SearchResult[][]): SearchResult[]; /** * Normalize RRF scores to 0-1 range using the actual max in the result set. * * The theoretical max per result per list is 1/(k+1). With N lists the * absolute ceiling is N/(k+1). But actual maxima vary, so we use the * observed max to give the best-ranked result a score of 1 and scale * everything else relative to it. Falls back to the theoretical ceiling * when all scores are equal (e.g. single-result sets). */ private normalizeRRFScores; /** * @deprecated Use normalizeRRFScores (batch) instead */ private normalizeRRFScore; /** * Calculate average score */ private calculateAvgScore; /** * Search with custom weights for vector vs keyword */ searchWeighted(query: string, options: RetrievalOptions, weights?: { vector: number; keyword: number; }): Promise; /** * Search with boost for specific sources */ searchWithBoost(query: string, options: RetrievalOptions, boosts?: { recency?: number; popularity?: number; }): Promise; /** * Diversify results to reduce redundancy */ diversifyResults(results: SearchResult[], maxSimilarityThreshold?: number): SearchResult[]; /** * Calculate simple content similarity (Jaccard similarity of words) */ private calculateContentSimilarity; } //# sourceMappingURL=hybrid-search.d.ts.map