Skip to main content

rerank

Function rerank 

Source
pub fn rerank(
    hits: &[Hit],
    idx: &Index,
    prompt: &str,
    cfg: &Config,
) -> Option<Vec<Hit>>
Expand description

Rerank the top-cfg.rerank_top_k stage-1 candidates with the cross-encoder, returning them rescored on the reranker’s (logit) scale and sorted descending. Some only with the fastembed feature and a usable model; None otherwise, so the caller falls back to the stage-1 ordering.

cosine/keyword on each returned Hit are preserved for display; score is replaced by the reranker logit. Callers must gate the result with the reranker thresholds (Config::rerank_min / Config::rerank_margin), not the bi-encoder ones — the scales differ.