ColbertReranker<T>
Models & Types · AiDotNet.RetrievalAugmentedGeneration.Rerankers
A ColBERT-style late-interaction reranker (Khattab & Zaharia 2020) that scores each (query, document) pair with the “MaxSim” rule and reorders candidates by descending score.
Inheritance: RerankerBase<T> → ColbertReranker<T>
For Beginners
This is a careful, word-by-word second pass over search results. For every word in your query it finds the single best-matching word in each candidate document and adds up those best matches. A document that has a strong match for every part of your query scores highest and floats to the top.
How It Works
The reranker embeds the query and every candidate document into per-token vectors using an
ITokenEmbeddingModel, then computes
Score(Q, D) = Σ_q max_d (E_q · E_d) — for each query token, take the maximum dot product
against any document token, then sum over query tokens. Token embeddings are L2-normalised before
scoring, so the dot product equals cosine similarity. Document token embeddings are cached per
Rerank call so a
document appearing more than once (by id) is embedded only once.
By default a deterministic offline HashingTokenEmbeddingModel<T> is used, which
makes the reranker fully testable without downloading any model. Supply a real contextual token
embedder via the constructor for production semantics.
Constructors
| Constructor | Summary |
|---|---|
ColbertReranker(IEmbeddingModel<T> embeddingModel) |
Creates a reranker whose token embeddings come from a real single-vector IEmbeddingModel, adapted to per-token output via EmbeddingModelTokenAdapter. |
ColbertReranker(ITokenEmbeddingModel<T> tokenEmbeddingModel) |
Creates a reranker whose token embeddings come from a real single-vector IEmbeddingModel, adapted to per-token output via EmbeddingModelTokenAdapter. |
Properties
| Property | Summary |
|---|---|
bool ModifiesScores { get; } |
Gets a value indicating whether this reranker modifies relevance scores. |