Full-attention scoring is the mechanism where every token in a query attends to every token in a candidate document simultaneously through a transformer's self-attention layers. Unlike Bi-Encoders that produce isolated vector representations, this joint encoding allows the model to compute token-level interaction weights, capturing exact match signals, lexical overlap, and fine-grained semantic alignment in a single forward pass.
Glossary
Full-Attention Scoring

What is Full-Attention Scoring?
Full-attention scoring is the core computational mechanism within a Cross-Encoder that enables rich, token-level interaction between a query and a candidate document.
This exhaustive pairwise attention generates a highly expressive joint representation, typically pooled via the [CLS] token, to produce a precise relevance score. While computationally expensive—requiring O(n*m) attention computations for a query of length n and document of length m—this mechanism provides the highest re-ranking precision, making it the standard final stage in multi-stage retrieval architectures where latency budgets permit.
Key Characteristics of Full-Attention Scoring
Full-Attention Scoring is the defining computational mechanism of Cross-Encoder architectures. Unlike Bi-Encoders that compress text into isolated vectors, this process allows every token in the query to attend directly to every token in the candidate document, enabling rich, granular semantic interaction.
Joint Input Encoding
The query and candidate document are concatenated into a single sequence: [CLS] query [SEP] document [SEP]. This unified input is fed through the transformer simultaneously. Because the model processes both strings as one contiguous context, the self-attention mechanism can establish direct token-to-token relationships across the query-document boundary from the very first layer.
Token-Level Interaction Matrix
The core of full-attention scoring is the attention matrix. For a query of length m and a document of length n, the model computes an (m+n) x (m+n) attention grid. This allows the model to weigh specific alignments, such as matching the query token 'Python' against document tokens 'snake' (low weight) versus 'programming' (high weight), capturing exact match signals and lexical overlap that Bi-Encoders miss.
Contextualized Cross-Matching
Unlike static embedding comparisons, full-attention scoring is context-dependent. The representation of a document token shifts based on the query it is paired with. For example, the word 'bank' in a document will be contextualized differently when the query is 'financial institutions' versus 'river erosion'. This dynamic adaptation is impossible in Bi-Encoder architectures where document vectors are pre-computed and frozen.
Relevance Score Aggregation
After the final transformer layer, the model must produce a single scalar relevance score. The most common method uses the [CLS] token representation, which has aggregated information from the entire sequence. This vector is passed through a linear classification head to output a logit, which is then converted to a probability via a sigmoid function, representing the likelihood of relevance.
Computational Complexity
The expressiveness of full-attention scoring comes at a significant cost. The self-attention operation scales quadratically with the combined sequence length: O((m+n)²). This makes it computationally prohibitive to apply against millions of documents in real-time. Consequently, it is strictly reserved for a re-ranking phase, applied only to the top-k candidates (e.g., top 100) retrieved by a fast Bi-Encoder or lexical system.
Pairwise vs. Pointwise Scoring
Full-attention scoring can be applied in two modes:
- Pointwise: A single query-document pair is scored independently, producing an absolute relevance probability.
- Pairwise: Two documents are scored simultaneously against the same query to predict which is more relevant. This is exemplified by DuoBERT, which uses a
[CLS] query [SEP] docA [SEP] docB [SEP]input format to learn fine-grained comparative distinctions.
Full-Attention vs. Bi-Encoder vs. Late Interaction
A technical comparison of the three primary neural ranking paradigms, contrasting their interaction mechanisms, computational profiles, and optimal deployment stages in a multi-stage retrieval pipeline.
| Feature | Full-Attention (Cross-Encoder) | Bi-Encoder (Dual-Tower) | Late Interaction (ColBERT) |
|---|---|---|---|
Interaction Mechanism | Every query token attends to every document token simultaneously via full self-attention | Query and document are encoded independently; interaction occurs only via final dot-product | Token-level interaction is delayed until the final MaxSim scoring step |
Query-Document Coupling | Joint encoding; query and document must be processed together at inference time | Decoupled encoding; documents can be pre-indexed offline | Decoupled encoding; document token embeddings are pre-computable and indexable |
Exact Match Sensitivity | |||
Pre-Computable Document Representations | |||
Inference Latency (per candidate) | 10-50 ms | < 1 ms | 1-5 ms |
Typical Retrieval Stage | Final re-ranking of top-k candidates (k < 100) | First-stage retrieval over millions of documents | Second-stage re-ranking of top-k candidates (k < 1000) |
Scoring Granularity | Holistic pair-level relevance score via [CLS] token | Single vector-level cosine similarity | Sum of token-level maximum cosine similarities (MaxSim) |
Memory Footprint for Indexing | N/A (no pre-indexing possible) | Low: single dense vector per document | High: set of token embeddings per document |
Frequently Asked Questions
Clear answers to the most common questions about the Cross-Encoder's core mechanism for joint query-document processing.
Full-attention scoring is the core mechanism of a Cross-Encoder where every token in the query attends to every token in the candidate document simultaneously through the transformer's self-attention layers. Unlike a Bi-Encoder that produces independent vector representations, the Cross-Encoder concatenates the query and document into a single input sequence: [CLS] query tokens [SEP] document tokens [SEP]. The multi-head self-attention mechanism then computes pairwise attention weights between all token positions, allowing the model to capture rich token-level semantic interactions, exact match signals, and lexical overlap. The final [CLS] token representation is passed through a linear classification head to produce a fine-grained relevance score. This exhaustive token-level interaction is what gives Cross-Encoders their superior precision over dot-product Bi-Encoder scoring.
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.
Related Terms
Explore the architectural components, training methodologies, and evaluation frameworks that surround the full-attention scoring mechanism in Cross-Encoder re-ranking pipelines.
Token-Level Interaction
The granular semantic matching enabled by the Cross-Encoder's self-attention mechanism. Unlike Bi-Encoders that compress text into a single vector, full-attention scoring allows the model to weigh specific term alignments between query and document tokens.
- Captures exact match signals and synonym detection simultaneously
- Enables the model to learn that 'car' attending to 'automobile' is a strong match
- Identifies negation patterns where 'not good' reverses sentiment
- Computationally expensive: O(n²) complexity relative to combined sequence length
Query-Document Pair Scoring
The fundamental operation where a query string and a candidate passage are concatenated into a single input sequence and passed through a transformer. The model processes the joint representation through multiple layers of self-attention.
- Input format:
[CLS] query [SEP] document [SEP] - The [CLS] token aggregates the full cross-attention signal into a single relevance embedding
- A linear classification head projects this embedding to a scalar relevance score
- Enables the model to condition document understanding directly on query context
Cascade Ranking Architecture
A multi-stage retrieval design where full-attention scoring is the final precision filter. The pipeline progressively narrows candidates from millions to a final ranked list.
- Stage 1: Sparse retrieval (BM25) or dense vector search retrieves top-1000 candidates
- Stage 2: Lightweight Bi-Encoder reranks to top-100
- Stage 3: Cross-Encoder with full-attention scoring produces the final top-10 ranking
- Balances the latency-relevance trade-off by reserving expensive full-attention for only the most promising candidates
Inference Latency Optimization
Techniques to reduce the computational cost of full-attention scoring to meet real-time search latency budgets. Cross-Encoders are inherently slower than Bi-Encoders due to the inability to pre-compute document representations.
- INT8 quantization reduces model precision with minimal accuracy loss
- ONNX Runtime with graph optimizations and operator fusion accelerates transformer inference
- Dynamic batching groups multiple query-document pairs for parallel GPU processing
- Knowledge distillation transfers full-attention scoring patterns to a faster student Bi-Encoder
Hard Negative Mining
A training data strategy that selects challenging negative samples to teach the full-attention mechanism fine-grained discrimination. Standard random negatives are too easy and fail to push the model to learn subtle distinctions.
- Retrieves top-scoring documents from a BM25 or dense retriever that are not relevant
- Forces the Cross-Encoder to distinguish between lexically similar but semantically irrelevant passages
- Critical for learning to detect false exact matches where keywords overlap but meaning diverges
- Often combined with in-batch negatives for computational efficiency during contrastive training
Score Calibration
The process of adjusting raw Cross-Encoder logits so that scores reflect true empirical relevance probabilities. Raw transformer outputs are often overconfident and poorly calibrated.
- Platt scaling fits a logistic regression model on validation set scores to map logits to probabilities
- Temperature scaling divides logits by a learned scalar parameter to soften the softmax distribution
- Calibrated scores enable meaningful score thresholds across different queries and domains
- Essential for downstream systems that fuse Cross-Encoder scores with other relevance signals

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