1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//! Sparse Retrieval Module
//!
//! Provides sparse (keyword-based) retrieval using BM25 algorithm.
//! Used in hybrid search to combine with dense vector retrieval.
//!
//! # Algorithm
//!
//! BM25 (Best Matching 25) is a probabilistic relevance function:
//!
//! score(D, Q) = Σ IDF(qi) × (f(qi, D) × (k1 + 1)) / (f(qi, D) + k1 × (1 - b + b × |D|/avgdl))
//!
//! Where:
//! - f(qi, D) = frequency of term qi in document D
//! - |D| = document length
//! - avgdl = average document length
//! - k1, b = tuning parameters (typically k1=1.2-2.0, b=0.75)
//! - IDF(qi) = log((N - n(qi) + 0.5) / (n(qi) + 0.5) + 1)
//!
//! # Architecture
//!
//! ```text
//! ┌─────────────────────────────────────────────┐
//! │ BM25Index │
//! ├─────────────────────────────────────────────┤
//! │ + add(id, text) │
//! │ + search(query, k) -> Vec<SparseResult> │
//! │ + update_doc_stats() │
//! └─────────────────────────────────────────────┘
//! ```
pub use ;
pub use ;
pub use ;