---
source: https://iinventedlight.com/library/notes/sentence-transformers-cross-encoder.md
title: "Rerank pairs with a Sentence Transformers CrossEncoder"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Sentence Transformers); Apache-2.0 (huggingface/sentence-transformers (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Sentence Transformers, Quickstart; huggingface/sentence-transformers (GitHub), Cross Encoder usage. Apache-2.0; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-ai: Sentence Transformers Cross Encoder reranking"
tags: [sentence-transformers, cross-encoder, rerank, predict]
client: Librarian
sources:
  - id: S1
    title: "Quickstart"
    publisher: Sentence Transformers
    url: https://www.sbert.net/docs/quickstart.html
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "Cross Encoder usage"
    publisher: huggingface/sentence-transformers (GitHub)
    url: https://github.com/huggingface/sentence-transformers/blob/main/docs/cross_encoder/usage/usage.rst
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# Rerank pairs with a Sentence Transformers CrossEncoder
**Answer:** Cross Encoder models, also called reranker models, calculate a similarity score given pairs of inputs. They generally provide superior performance compared to a Sentence Transformer bi-encoder model, and they are often slower.

## Characteristics

A Cross Encoder requires computation for each pair rather than each text. Due to those characteristics, Cross Encoders are often used to re-rank also the top-k results from a Sentence Transformer model. Pairs are typically text pairs, but also image-text or other modalities.

## predict and rank

Load a pre-trained CrossEncoder model such as cross-encoder/ms-marco-MiniLM-L6-v2. Predict scores for a pair of sentences with predict. Rank a list of passages for a query with rank. rank returns a score and a corpus_id.

MS Marco models return logits rather than scores between 0 and 1. Load the CrossEncoder with activation_fn set to a sigmoid to get scores between 0 and 1. This does not affect the ranking.

Some Cross Encoder models support multimodal pairs, such still as a text query and an image document. Use modalities and supports() to check modality support.

| predict | rank |
|---|---|
| CrossEncoder | Load a pre-trained reranker model |
| predict | Predict scores for sentence pairs |
| rank | Rank passages for a query |
| corpus_id | A score and a corpus_id |
| activation_fn | Optional sigmoid for MS Marco logits |

## See also

- [sentence-transformers-encode](https://iinventedlight.com/library/notes/sentence-transformers-encode/)
- [1908-10084-sentence-bert](https://iinventedlight.com/library/notes/1908-10084-sentence-bert/)
- [genai-rag-embeddings-vector-search](https://iinventedlight.com/library/notes/genai-rag-embeddings-vector-search/)

## Claims

- id: C1
  claim: A Cross Encoder calculates a similarity score for pairs of inputs and is often used to rerank bi-encoder results.
  source: S1
  evidence: "Calculates a similarity score given pairs of inputs"

- id: C2
  claim: Cross Encoders are often slower than bi-encoders because they compute a score for each pair.
  source: S1
  evidence: "requires computation for each pair rather than each text"

- id: C3
  claim: MS Marco Cross Encoder models return logits, and a sigmoid activation can map those scores between 0 and 1 without changing rank order.
  source: S2
  evidence: "MS Marco models return logits rather than scores"

## Sources

- [S1] Quickstart. Sentence Transformers. https://www.sbert.net/docs/quickstart.html . License: Apache-2.0. Accessed 2026-11-19.

- [S2] Cross Encoder usage. huggingface/sentence-transformers (GitHub). https://github.com/huggingface/sentence-transformers/blob/main/docs/cross_encoder/usage/usage.rst . License: Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Sentence Transformers, Quickstart; huggingface/sentence-transformers (GitHub), Cross Encoder usage. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
