Bi-encoder encodes query and document independently and scores by dot product; cross-encoder concatenates them into one sequence and runs full self-attention across the boundary.
Imagine matching job applicants to job postings. A bi-encoder is like having an interviewer write a one-paragraph summary of each applicant and each job, then matching them by comparing summaries side by side, fast, because you only need to write each summary once. A cross-encoder is like making the interviewer sit down with each applicant-job pair, read both together, and write a fresh assessment for that specific pair, slow, because every pair needs its own assessment, but the assessments are far more accurate. Production search stacks use both: the fast bi-encoder narrows millions of jobs down to a hundred, then the slow cross-encoder picks the best ten.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Concept explanation~2 min read
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Bi-encoders and cross-encoders are the two foundational architectures for neural retrieval, and the distinction between them is one of the most consequential design choices in any RAG or search system. The split is purely structural, where attention crosses (or does not cross) the boundary between query and document, and it determines whether documents can be precomputed and indexed or whether every query-document pair requires a fresh forward pass.
This card walks the two architectures, the cost model each implies, why production stacks combine them in a two-stage pipeline, and the modern variants (ColBERT, hybrid sparse-dense, LLM-as-reranker) that fill the cost-accuracy spectrum between pure bi-encoder and pure cross-encoder. By the end you should be able to design a retrieval stack from scratch and reason about which component runs at which scale.
The structural split
Both architectures use the same transformer encoder backbone (BERT, RoBERTa, ModernBERT, or a modern embedding LLM like E5-Mistral). The split is where attention runs.
Bi-encoder
Query -> [CLS] q1 q2 ... qm [SEP] -> Encoder -> pool -> e_q (768 dim)
Document -> [CLS] d1 d2 ... dn [SEP] -> Encoder -> pool -> e_d (768 dim)
Score = e_q . e_d
Two independent forward passes through the same encoder weights. No attention ever crosses between query tokens and document tokens because they never share a sequence. The relevance score is a dot product (or cosine, after L2 normalization).
Cross-encoder
Input -> [CLS] q1 q2 ... qm [SEP] d1 d2 ... dn [SEP]
-> Encoder (full self-attention) -> pool -> [CLS] hidden state
Score = classification_head([CLS] hidden state)
One sequence containing query and document tokens, separated by [SEP]. Full self-attention runs over the entire sequence, so every query token can attend to every document token and vice versa. The relevance score comes from a classification (or regression) head on the [CLS] hidden state.
The boundary visibility
The word 'boundary' is the key. In the bi-encoder, there is no shared sequence, so there is no boundary for attention to cross. In the cross-encoder, the boundary is the [SEP] token in the middle of the sequence, and attention crosses it freely just as it would cross any other position. The bi-encoder structurally CANNOT model query-document token interactions because the two halves are never in the same forward pass.
Situations where this technique stops working.
2–4 min · Everything important, quickly.
| Property | Bi-encoder | Cross-encoder |
|---|---|---|
| Input structure | Query and document encoded separately | Concatenated into one sequence |
| Cross-modal attention | None | Full self-attention across the boundary |
| Scoring | Dot product of pooled embeddings | Classification head on [CLS] |
| Document precomputation | Yes (one forward pass per document offline) | No (every query-document pair needs fresh pass) |
| Inference cost per query | 1 forward pass + N dot products | N forward passes |
| Scalability | Billions of documents with ANN index | Thousands at most |
| Accuracy | Lower (pooled embeddings lose token-level signal) | Higher (full token-level interaction) |
| Typical role | First-stage recall | Second-stage rerank |
Real products, models, and research that use this idea.
- OpenAI text-embedding-3-large and Cohere embed-v4 are bi-encoder embedding models powering first-stage retrieval in 2026 production RAG stacks.
- bge-reranker-v2.5 and Cohere rerank-v3 are cross-encoder rerankers used for second-stage precision over top-100 candidates from bi-encoder recall.
What an interviewer would ask next. Try answering before peeking at the approach.
QHow does ColBERT's late-interaction architecture sit between bi-encoder and cross-encoder?
ColBERT encodes query and document into per-token embeddings (not pooled), so storage is more expensive than bi-encoder. Scoring uses MaxSim: for each query token, find the max similarity to any document token, then sum. This captures some cross attention like interaction without rerunning the model per pair. Documents can be precomputed (storing per-token embeddings) and queries score against them with MaxSim, sub-quadratic cost. Accuracy lands between bi-encoder and cross-encoder, latency lands closer to bi-encoder.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Red flags & common mistakes
The phrases that signal junior thinking. Click to expand.
Mistaking the bi-encoder for using cross-attention between query and document. Bi-encoders run independent forward passes with zero cross-modal attention; the dot product between pooled embeddings is what couples them at scoring time.
60 second bullets to scan on the way to the call.
Describe the bi-encoder architecture and how it produces a score
Describe the cross-encoder architecture and what it concatenates
Primary sources. Browse if you want the original framing.
Same topic, related formats. Practice these next.