All models

dpr

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

Language · 304 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 (33 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
108.9M
Operations
304
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
m4375
Graph hash
b9f35d6aa59d25f72ece8e8918abf9141634a56f6c95ec2c3bacf01af4180adf
Skeleton hash
df0a941b8550b42829b6ac345b13a9ec906f1e76c08cf1f1ae2084bac6184c8e
Architecture hash
0559e19675b449bbae209e6dcb9486a0f1a8fbfdcd38be455e698ce257b59e84
Diagram SHA-256
43bd37bbad304c7aea63892290134d100cfba6bc2862f0711c30b29e581078fb
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

The DPR encoder itself, an independent BERT base uncased network whose [CLS] representation is the 768-dimensional output vector.

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}, 
}