Module rerank
Expand description
Query-time rerank machinery for recalled memory candidates.
Structs§
- Rerank
Config - Rerank stage configuration, materialized from canonical memory config.
Copyso the engine’s injection config (which embeds one) staysCopy.
Enums§
- Rerank
Strategy - Advanced rerank strategy.
Constants§
- MAX_
CANDIDATE_ POOL - Absolute ceiling on the query-time candidate pool, enforced in
runregardless of the configured multiplier or how many entries a backend returns. Bounds the O(n^2) duplicate-collapse and MMR scans against a mis-sized config or a backend that ignores the requested recall limit (for example a no-embedding fallback that returns its whole list).
Functions§
- bounded_
final_ limit - bounded_
pool_ cap - collapse_
exact_ and_ near_ duplicates - Collapse exact and near-duplicate entries, preserving the highest score.
- run
- Run blend, eligibility filtering, duplicate collapse, optional advanced
rerank, threshold, and trim.
is_eligibleis the caller’s render-eligibility predicate; it is applied before duplicate collapse so an ineligible row cannot shadow an eligible fact with the same content, and before the final trim so it cannot consume a selection slot.