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.
Glossary
Long Document Re-Ranking

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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
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.
Related Terms
Core concepts and techniques for applying Cross-Encoder precision to documents that exceed the model's maximum sequence length.
Sliding Window Scoring
The primary strategy for scoring documents longer than the Cross-Encoder's maximum sequence length (typically 512 tokens). The document is segmented into overlapping or contiguous windows of fixed token length. Each window is independently scored against the query using a Cross-Encoder, producing a set of passage-level relevance scores. The final document score is derived by aggregating these window scores, most commonly via max-pooling to capture the highest relevance signal anywhere in the document. Window overlap ensures critical context spanning segment boundaries is not lost.
Max-Pooling Aggregation
A score aggregation function that selects the maximum relevance score from all sliding window passages as the single document-level score. The intuition is that a document's relevance to a query is determined by its most relevant passage. Mathematically: score(doc) = max(score(window_1), score(window_2), ..., score(window_n)). This method is robust to documents where the answer is concentrated in one section but risks over-weighting documents with a single highly-scored but out-of-context snippet.
Hierarchical Segment Aggregation
A multi-stage approach that first scores individual passages, then feeds the top-k passage representations into a secondary aggregation model. This can be implemented as:
- Mean-pooling of top-k passage embeddings before a final linear layer
- A lightweight Transformer aggregator that attends over passage [CLS] tokens
- Weighted sum where weights are learned based on passage position This method captures the document's global relevance distribution rather than relying on a single passage, improving precision for queries requiring synthesis across sections.
First-Passage Bias Mitigation
A systematic failure mode where a Cross-Encoder assigns disproportionately high scores to the document's opening passage regardless of query relevance. This occurs because pre-training corpora often position key information at the beginning. Mitigation strategies include:
- Random window shuffling during training to decorrelate position from relevance
- Position-aware scoring heads that learn to down-weight opening passage bias
- Calibration on passage position using a held-out validation set to normalize scores by segment location
Token Budget Optimization
The engineering discipline of maximizing relevance signal within the Cross-Encoder's fixed 512 or 4096 token context window. Techniques include:
- Query compression via extractive summarization to reserve tokens for document content
- Document truncation strategies that prioritize sections with high BM25 or Bi-Encoder alignment
- Dynamic window sizing where passage length adapts based on document structure (e.g., respecting paragraph boundaries)
- Stride length tuning to balance overlap redundancy against computational cost
Late Interaction for Long Documents
An alternative to sliding window Cross-Encoders that uses ColBERT-style MaxSim scoring across the full document. The document is encoded as a large set of token-level embeddings (potentially thousands of tokens), and the query tokens interact with all document tokens via maximum similarity. This avoids the window boundary problem entirely and enables fine-grained token matching across the entire document length. The trade-off is increased storage for per-token document embeddings and higher retrieval latency compared to single-vector Bi-Encoders.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us