All models

realm

Two BERT encoders and a dot product: dense retrieval that beat BM25 for open-domain question answering.

Language · 455 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (19 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Family
DPR
Parameters
133.6M
Operations
455
Framework
PyTorch
Recurrent
No
Published
EMNLP 2020
Cited by
3,510 (as of 18 October 2026)
Authors
Vladimir Karpukhin, Barlas Oğuz, Sewon Min and others
License
Apache-2.0
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m8582
Graph hash
9e194310c35058913a2b9da63067e62743523c12dc090f0760c91bd29d8e6ce8
Skeleton hash
1819a4f144f648f027a62d661fd6cf2f9f20749c0f4aa32c47bf42fbd916ea4b
Architecture hash
7efcfccd4896832a262b8abf284bfb496f5a3b57129624ebb6deffacbdce127f
Diagram SHA-256
2f230aa4991a02364c5e4f3ab57b3942799931987f5d4bce8c6d108ecc39a681
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

REALM's embedder, a separate retriever trained without passage supervision at the cost of an expensive Inverse Cloze Task pre-training step.

About this model's family

DPR, the Dense Passage Retriever, finds candidate passages for open-domain question answering with dense vectors alone, learned by a simple dual-encoder framework, instead of the traditional sparse TF-IDF or BM25 matching. The question encoder and passage encoder are two independent BERT networks (base, uncased), each taking the representation at the [CLS] token as its output, so the vectors have 768 dimensions. Similarity is just the dot product of the two vectors, chosen because the function has to be decomposable so passage representations can be precomputed.

The surprise of the paper is how simple the recipe is: the embedding is optimized for maximizing inner products of question and relevant passage vectors, with an objective comparing all pairs of questions and passages in a batch. With in-batch negatives, each batch of B questions yields B training instances with B minus 1 negative passages per question at no extra cost. The best model mixes gold passages from the same mini-batch with one BM25 negative passage. No extra pretraining is needed, since simply fine-tuning the question and passage encoders on existing question-passage pairs is sufficient to greatly outperform BM25. At inference the passage encoder runs over all passages offline and FAISS indexes the vectors. DPR beats BM25 by a large margin, 65.2% versus 42.9% in Top-5 accuracy, and lifts end-to-end QA accuracy over ORQA, 41.5% versus 33.3%, on open Natural Questions.

This family also holds two retrievers that are not DPR but share the idea of maximizing the dot product between a query vector and Wikipedia passage vectors. REALM is trained without passage supervision but needs an expensive pre-training step with an Inverse Cloze Task, 100,000 steps at batch size 4096, and re-computes the embeddings of all Wikipedia passages during training. RetriBERT came out of the ELI5 long-form question answering write-up, trained on batches of 512 question-answer pairs. It uses a single BERT-style model for both questions and answers, with separate projection matrices bringing both representations down to dimension 128. The official DPR code is CC-BY-NC 4.0 licensed as of now. A March 2021 release added a new bi-encoder checkpoint trained on NQ with hard negatives mined using the DPR index itself. That lifted top-20 retrieval accuracy on the NQ test set from 79.97 to 81.33.

Key idea. DPR shows that a plain BERT dual encoder, fine-tuned on existing question-passage pairs with in-batch negatives and no extra pretraining, retrieves passages far better than BM25 and raises end-to-end open-domain QA accuracy.

  • DPR
  • dense passage retrieval
  • dense passage retriever
  • DPRQuestionEncoder
  • question encoder
  • passage encoder
  • REALM
  • RetriBERT
  • retribert-base-uncased
  • open-domain question answering
  • passage retrieval
  • bi-encoder
  • dual encoder
  • ELI5

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{karpukhin2020densepassageretrievalopendomain,
      title={Dense Passage Retrieval for Open-Domain Question Answering}, 
      author={Vladimir Karpukhin and Barlas Oğuz and Sewon Min and Patrick Lewis and Ledell Wu and Sergey Edunov and Danqi Chen and Wen-tau Yih},
      year={2020},
      eprint={2004.04906},
      archivePrefix={arXiv},
      primaryClass={cs.CL},
      url={https://arxiv.org/abs/2004.04906}, 
}