← All notes

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

Claims

Sources

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.

License: CC-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.

Cite this

Permanent ID: iil:note:mfjxdqjw

iinventedlight. 2026. "Rerank pairs with a Sentence Transformers CrossEncoder." iinventedlight Library, iil:note:mfjxdqjw, version of 2026-11-19. https://iinventedlight.com/library/notes/sentence-transformers-cross-encoder/. License: CC-BY-4.0.

@misc{iil_note_mfjxdqjw,
  author = {{iinventedlight}},
  title = {{Rerank pairs with a Sentence Transformers CrossEncoder}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/sentence-transformers-cross-encoder/},
  note = {Permanent ID iil:note:mfjxdqjw. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/sentence-transformers-cross-encoder.md.