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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//! Reranking functionality for improved retrieval quality.
//!
//! This module provides reranking capabilities to improve search result relevance
//! by scoring documents against a query using specialized reranking models.
//!
//! # Architecture
//!
//! ```ascii
//! ┌─────────────────────────────┐
//! │ Query + Documents │
//! └──────────────┬──────────────┘
//! │
//! ▼
//! ┌─────────────────────────────────────────────────────┐
//! │ Reranker Trait │
//! │ rerank(query, docs, top_n) → Vec<RerankResult> │
//! └──────────────────────────┬──────────────────────────┘
//! │
//! ┌───────────────────────┼───────────────────────┐
//! ▼ ▼ ▼
//! ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
//! │ HttpReranker │ │ BM25Reranker │ │HybridReranker│
//! │ (Jina,Cohere)│ │ (Local) │ │ (Combined) │
//! └──────────────┘ └──────────────┘ └──────────────┘
//! ```
//!
//! # Module Structure (OODA-02)
//!
//! ```ascii
//! reranker/
//! ├── mod.rs ─► This file (re-exports)
//! ├── config.rs ─► RerankConfig, ScoreAggregation
//! ├── result.rs ─► RerankResult
//! ├── traits.rs ─► Reranker trait
//! ├── http.rs ─► HttpReranker (Jina, Cohere, Aliyun)
//! ├── term_overlap.rs─► TermOverlapReranker, MockReranker
//! ├── bm25.rs ─► BM25Reranker, TokenizerConfig
//! ├── rrf.rs ─► RRFReranker
//! └── hybrid.rs ─► HybridReranker
//! ```
//!
//! # Implements
//!
//! - **FEAT0774**: Reranking for improved retrieval
//! - **FEAT0775**: Multi-provider reranker support
//! - **FEAT0776**: BM25 keyword fallback scoring
//!
//! # Enforces
//!
//! - **BR0774**: Top-k results after reranking
//! - **BR0775**: Fallback to BM25 if reranker unavailable
//!
//! # Providers
//!
//! | Provider | Type | Notes |
//! |----------|------|-------|
//! | Jina AI | HTTP | Production multilingual |
//! | Cohere | HTTP | Production rerank-v3.5 |
//! | Aliyun | HTTP | DashScope gte-rerank-v2 |
//! | BM25 | Local | No API key needed |
//! | TermOverlap | Local | Fast testing fallback |
//! | Hybrid | Combined | BM25 + Neural fusion |
//!
//! # Example
//!
//! ```ignore
//! use edgequake_llm::reranker::{BM25Reranker, Reranker};
//!
//! let reranker = BM25Reranker::new();
//! let results = reranker.rerank("rust async", &docs, Some(10)).await?;
//! ```
// Sub-modules (SRP: each module has a single responsibility)
// Re-export public types - maintains backward compatibility with existing API
pub use ;
pub use ;
pub use HttpReranker;
pub use HybridReranker;
pub use RerankResult;
pub use RRFReranker;
pub use ;
pub use Reranker;