Inferensys

Glossary

Long Document Re-Ranking

Long document re-ranking is the set of strategies for applying Cross-Encoder models to documents that exceed the transformer's maximum input sequence length, using techniques like sliding window scoring with max-pooling or hierarchical segment aggregation to produce a single, document-level relevance score.
Stylish WeWork-like workspace with hot desks and document wall, professional searching through enterprise knowledge base on a mounted ultrawide display, warm industrial pendants overhead.
DOCUMENT CHUNKING STRATEGIES

What is Long Document Re-Ranking?

Long document re-ranking refers to the set of techniques used to apply computationally intensive Cross-Encoder models to documents that exceed the model's maximum input sequence length, typically 512 tokens.

Long Document Re-Ranking is a strategy for scoring documents whose length exceeds a transformer's fixed context window. Since a Cross-Encoder cannot process an entire 10,000-word report in a single pass, the document is segmented into overlapping or contiguous chunks, each scored independently against the query, and the resulting scores are aggregated into a single document-level relevance signal.

The dominant aggregation method is max-pooling, where the document's final score is the maximum relevance score across all its chunks, operating on the assumption that the most relevant passage defines the document's utility. A more nuanced approach is hierarchical aggregation, where chunk scores are first summarized by a lightweight model before final scoring, mitigating the noise introduced by irrelevant sections.

SCORING STRATEGIES

Key Characteristics of Long Document Re-Ranking

When documents exceed the typical 512-token Cross-Encoder limit, specialized aggregation strategies are required to produce a single, coherent relevance score without truncating critical context.

01

Sliding Window Scoring

A technique that segments a long document into overlapping passages of fixed length (e.g., 512 tokens with a 256-token stride). Each passage is scored independently against the query using a Cross-Encoder, and the final document score is derived by aggregating these passage-level scores, typically via max-pooling or mean-pooling. This ensures no contextual boundary artificially splits a relevant answer across two chunks.

512 tokens
Typical Window Size
50% overlap
Common Stride
02

Max-Pooling Aggregation

A passage score aggregation function where the final document relevance score is the maximum score among all its constituent sliding window passages. This strategy operates on the assumption that a document is as relevant as its most relevant passage. It is highly effective for factoid queries where the answer is localized to a single paragraph, preventing dilution from irrelevant sections.

03

Hierarchical Segment Aggregation

A two-stage approach designed for very long documents (e.g., legal contracts or research papers). The document is first divided into large structural segments (chapters, sections). A lightweight Bi-Encoder or sparse retriever selects the top-k most relevant segments, and only these segments are passed through the computationally expensive Cross-Encoder for fine-grained scoring. This drastically reduces the number of inference calls compared to exhaustive sliding windows.

04

First-in, Last-out Token Truncation

A simple baseline strategy that fits a long document into the Cross-Encoder's maximum sequence length by retaining the first N tokens and the last M tokens, discarding the middle. This leverages the common structure of documents where introductions and conclusions contain dense summaries of the content. While computationally cheap, it risks missing critical evidence buried in the body of the text.

05

Query-Aware Sparse Passage Selection

A pre-filtering step that uses a sparse lexical model like BM25 to score individual sentences or passages within a long document against the query before invoking the Cross-Encoder. Only the top-k BM25 passages are concatenated and fed to the Cross-Encoder. This combines the exact-match precision of sparse retrieval with the semantic understanding of a neural re-ranker, optimizing for both latency and relevance.

06

Mean-Pooling Aggregation

An alternative to max-pooling where the final document score is the arithmetic mean of all passage-level Cross-Encoder scores. This strategy is more suitable for broad, topical queries where overall document relevance matters more than a single localized answer. It penalizes documents that are only partially relevant, favoring those with consistently high semantic alignment across all sections.

LONG DOCUMENT RE-RANKING

Frequently Asked Questions

Practical answers to common questions about applying Cross-Encoder precision to documents that exceed standard transformer sequence length limits.

Long document re-ranking is the process of applying a Cross-Encoder relevance model to documents that exceed the model's maximum sequence length—typically 512 tokens for BERT-based architectures. Standard Cross-Encoders require concatenating the full query and document text into a single input, but when a document spans thousands of tokens, truncation discards potentially relevant passages. This creates a precision-recall tradeoff where the most relevant section may be omitted entirely. Long document re-ranking strategies—such as sliding window scoring, segment-level aggregation, or hierarchical pooling—partition the document into manageable chunks, score each independently, and synthesize a single document-level relevance score. This is critical for enterprise search over legal contracts, technical documentation, and research papers where the relevant passage may appear deep within a lengthy text.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.