TECHNOLOGY

Cross-encoders let a query and document interact before scoring

In this article
THE QUICK TAKE

Joint pair encoding lets document states depend on the current query, so the final score cannot generally be reproduced by one precomputed document vector.

A cross-encoder receives a query and document together and produces a score from their joint representation. Its defining property is interaction before the final comparison. This makes it different from a dual encoder that compares separately produced vectors, and explains why cross-encoders are commonly used on a selected candidate set.

Build a joint pair representation

The pair is serialized according to the model’s tokenizer and architecture, with the appropriate boundary markers and masks. Within a typical bidirectional encoder setup, permitted query and document positions can attend across the pair. Hidden document states can therefore change when the query changes, even if the document text stays fixed. The scoring head then consumes the model’s designated representation. Exact pooling and head details belong to the checkpoint; the broad cross-encoder label does not specify every possible relevance objective or output scale.

Interaction can resolve query-dependent distinctions

Imagine a document stating that a server supports a device but not a particular driver. A query about device availability and a query about driver compatibility need different relevance judgments over the same text. Joint encoding can represent query-dependent token relationships before the score is computed. This describes capacity, not a promise that the trained model handles negation correctly. A deliberately contrasting fixture can test the behavior. The useful distinction from a dual encoder is where interaction occurs, rather than an assumption that one architecture always wins every retrieval task.

Precomputation has a different limit

A separately encoded document vector can be reused across many queries in a dual-encoder index. In a joint cross-encoder, the document’s intermediate states generally depend on the current query, so a universal cached vector does not replace the full pair computation. This motivates a pipeline that first retrieves candidates cheaply and then scores a smaller set jointly. The candidate stage still bounds recall: a relevant document absent from that set cannot be promoted by the reranker. Evaluate candidate selection and reranking separately before attributing an end-to-end failure.

Verify input boundaries and score interpretation

A small test should show the serialized pair, truncation policy, eligible attention positions and raw scoring output. Truncation can remove precisely the passage needed to judge relevance. A scalar logit or ranking score is not automatically a calibrated relevance probability, even when a sigmoid is available. Preserve the training objective and documented interpretation of the head. This produces a concrete reranking contract and lets the reader distinguish pair-format errors, missing evidence, candidate omissions and genuine model mistakes rather than folding every issue into the word accuracy.

Primary research and implementation references

Reproducible inference stacks: preserving a GPU pilot’s result; A GPU inference benchmark you can trust.

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles