RAG & Retrieval·Question 6 of 100BasicAI-75

How does a bi-encoder embedding model work at retrieval time, and what's the key limitation of that architecture?

Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.

Model answer: the part to lead with

A bi-encoder runs query and document through the same (or paired) transformer encoders independently, pooling each into a single fixed-size vector (typically 384-4096 dims). Training is contrastive: positive query-document pairs are pulled together, negatives (especially hard negatives) pushed apart, usually with an InfoNCE-style loss, so that semantic relevance ≈ cosine similarity / dot product in the shared space.

Full worked answer with diagram

A bi-encoder runs query and document through the same (or paired) transformer encoders independently, pooling each into a single fixed-size vector (typically 384-4096 dims). Training is contrastive: positive query-document pairs are pulled together, negatives (especially hard negatives) pushed apart, usually with an InfoNCE-style loss, so that semantic relevance ≈ cosine similarity / dot product in the shared space.

The independence is the entire point operationally: document vectors are computed once at index time, and at query time you embed only the query (one forward pass, ~10-50ms) and run nearest-neighbour search over millions of precomputed vectors. That's what makes retrieval scale.

The key limitation is the same independence: the document is compressed to one vector before knowing the query. A 512-token chunk gets squeezed into ~1000 floats that must anticipate every question anyone might ask of it - necessarily lossy. There is no token-level interaction: the model can't notice that the query's "it" refers to the document's "the API key", can't weigh a rare exact term heavily, and struggles with negation ("flights not through Frankfurt" embeds close to "flights through Frankfurt"). This is why cosine scores are useful for ranking but are not calibrated relevance probabilities - a 0.83 doesn't mean 83% relevant, and thresholds don't transfer across models or domains.

The standard fix is architectural layering: bi-encoder for cheap recall over millions of candidates, then a cross-encoder (full query-document attention) to rerank the top ~100 where per-pair compute is affordable. Late-interaction models (ColBERT) sit between: per-token vectors precomputed, token-level MaxSim scoring at query time.

Worth sketching. The frozen document vector is where negation and rare terms get lost, and the sketch puts that moment in front of the interviewer.

flowchart LR
    C["Chunk text"] --> DE["Encoder,<br/>index time"]
    DE --> V["One frozen vector,<br/>query not yet known"]
    V --> I["ANN index"]
    Q["Query text"] --> QE["Encoder,<br/>query time"]
    QE --> QV["Query vector"]
    QV --> M["Dot product<br/>over millions"]
    I --> M
    M --> R["Ranked chunks"]

What a good answer covers

  • A bi-encoder runs query and document through the same (or paired) transformer encoders independently,…
  • Training is contrastive: positive query-document pairs are pulled together, negatives (especially hard…
  • The independence is the entire point operationally
  • The key limitation is the same independence
  • A 512-token chunk gets squeezed into ~1000 floats that must anticipate every question anyone might ask…

Key terms: independently · once at index time · before knowing the query · cross-encoder

Interviewer follow-ups to expect

  1. Why can't you just use a cross-encoder for first-stage retrieval over 10M documents?

  2. What are hard negatives and why do they matter in training?

  3. Why do embedding models handle negation badly?

Worked answer from AI-Engineer-Interview-Questions by Om (MIT), reformatted for LLM Prep · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep