Skip to main content

Module cross_encoder

Module cross_encoder 

Source
Expand description

Cross-encoder re-ranker for embedding search results.

Implements a lightweight simulation of cross-encoder scoring using token-overlap (Jaccard) similarity. In a production system the score function would call a transformer model; here it is kept deterministic and dependency-free for testing purposes.

Structsยง

CandidatePair
A (query, document) pair submitted for re-ranking, together with the initial retrieval score produced by an upstream embedding model.
CrossEncoder
Stateful cross-encoder that tracks the total number of pairs scored.
CrossEncoderConfig
Configuration for a CrossEncoder instance.
RerankResult
The outcome of re-ranking a single candidate document.