liveBook · Manning

Cross-encoder

As explained in AI-Powered Search

A cross-encoder is a neural ranking model that jointly encodes two inputs, such as a query and document, to score their relevance using shared representations.

A cross-encoder is a neural ranking model that jointly encodes a query and document, then returns a relevance or similarity score. A Transformer combines both inputs into one representation, allowing the document to be interpreted within the query’s shared semantic context. Cross-encoders are commonly pretrained and can often be used without additional training. section 10.6.2 section 13.8

Unlike a bi-encoder, which embeds queries and documents separately before comparing them, a cross-encoder concatenates the pair and processes it together. This enables more nuanced matching, but requires substantially more computation for every scored pair. section 13.8 section 13.9

Reranking a semantic-search result set

For the query "mountain hike," first retrieve a manageable candidate set with semantic search. Build query-document pairs from the candidates, score them with a cross-encoder, and rerank by those scores. The model can distinguish a document about beginner snow hiking from one specifically relevant to mountain hiking, even though both concern hiking. section 13.8

A practical pipeline uses the cross-encoder after lexical or dense retrieval rather than against the entire index. This preserves its stronger contextual scoring while limiting latency and computation; adding more complex ranking features likewise increases evaluation cost and response time. section 13.9 section 10.6.2

How AI-Powered Search covers it

How deep it goes
Explains joint Transformer encoding, contextual scoring, bi-encoder contrast, and query-time computation without detailing model training internals.
Examples
Uses the mountain hike query, beginner snow-hiking comparison, and a Python reranking pipeline over retrieved titles.
What it assumes
Assumes familiarity with queries, documents, search results, and embeddings while contrasting separate and joint encoding.
What you can do after
Apply it via sentence-transformers to score query-document pairs and rerank a limited search-result set.
How it connects
Connects Transformer architecture, bi-encoders, semantic search, dense vector retrieval, lexical search, reranking, and learning to rank.

Also explained in

Compare how 2 books explain cross-encoder →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of AI-Powered Search. The section links point to the parts of the book it draws on.