SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2004.04906 · EMNLP · 2020

Dense Passage Retrieval for Open-Domain Question Answering

Patrick Lewis, Vladimir Karpukhin, Wen-Tau Yih, Sewon Min, Danqi Chen, Barlas Oguz, Sergey Edunov, Ledell Wu

arXiv · PDF · Open in the Atlas

Code that ran

11 of 14 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (6 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 10 have no contract verdict; 1 failure of our instrument; 3 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2004.04906.json · badge: /api/ran/2004.04906.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
hongyuntw/DPR community
Papers with Code archive
2 ran · 1 no recorded run
luyug/GC-DPR community
Papers with Code archive
2 ran · 0 no recorded run
oriram/spider community
Papers with Code archive
1 ran · 1 no recorded run
AkariAsai/XORQA community
Papers with Code archive
1 ran · 0 no recorded run
alexlimh/DPR_MUF community
Papers with Code archive
1 ran · 0 no recorded run
nidhikamal-emb/DPR_repo community
Papers with Code archive
1 ran · 0 no recorded run
Hannibal046/nanoDPR community
Papers with Code archive
1 ran · 0 no recorded run
amzn/refuel-open-domain-qa community
Papers with Code archive
1 ran · 0 no recorded run
Ankur3107/dpr-tf community (classifier label)
classifier basis not recorded on the link
1 ran · 0 no recorded run
facebookresearch/DPR marked official in Papers with Code
Papers with Code archive
0 ran · 1 no recorded run
FunctionStatusWhere it lives
BiEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
hongyuntw/DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("0c54070c4beb2fe8")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, hongyuntw/DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BiEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
oriram/spider/dpr/models/biencoder.py
code served (permissive licence) · get_code("e07f372e147c2a51")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, BiEncoder: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
import collections
import numpy as np

torch.manual_seed(0)

# Create a minimal sub-model that satisfies how it's used in BiEncoder.get_representation
class DummySubModel(nn.Module):
    def __init__(self, hidden_size=4):
        super(DummySubModel, self).__init__()
        self.hidden_size = hidden_size
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, input_ids, segments, attn_mask):
        # Simulate BERT-like output: (sequence_output, pooled_output, hidden_states)
        batch_size = input_ids.shape[0]
        seq_len = input_ids.shape[1]
        
        # Create dummy embeddings
        sequence_output = torch.randn(batch_size, seq_len, self.hidden_size)
        pooled_output = torch.randn(batch_size, self.hidden_size)
        hidden_states = [torch.randn(batch_size, seq_len, self.hidden_size)]
        
        return sequence_output, pooled_output, hidden_states

# Create question and context models
question_model = DummySubModel(hidden_size=4)
ctx_model = DummySubModel(hidden_size=4)

ARGS = {
    'question_model': question_model,
    'ctx_model': ctx_model,
    'fix_q_encoder': False,
    'fix_ctx_encoder': False,
    'return_pooled_ctx_repr': True,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BiEncoder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BiEncoder output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BiEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
AkariAsai/XORQA/baselines/DPR/dpr/models/biencoder.py
code served (permissive licence) · get_code("49b5e44493f56195")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, BiEncoder: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
import torch.nn as nn
from torch import Tensor as T
import numpy as np

torch.manual_seed(0)

class DummySubModel(nn.Module):
    """Minimal sub-model that returns sequence_output, pooled_output, hidden_states"""
    def __init__(self, hidden_size=4):
        super().__init__()
        self.hidden_size = hidden_size
        self.linear = nn.Linear(hidden_size, hidden_size)
    
    def forward(self, ids: T, segments: T, attn_mask: T):
        # ids shape: (batch_size, seq_len)
        batch_size = ids.shape[0]
        seq_len = ids.shape[1]
        
        # Return (sequence_output, pooled_output, hidden_states)
        sequence_output = self.linear(torch.randn(batch_size, seq_len, self.hidden_size))
        pooled_output = torch.randn(batch_size, self.hidden_size)
        hidden_states = torch.randn(batch_size, seq_len, self.hidden_size)
        
        return (sequence_output, pooled_output, hidden_states)

question_model = DummySubModel(hidden_size=4)
ctx_model = DummySubModel(hidden_size=4)

ARGS = {
    'question_model': question_model,
    'ctx_model': ctx_model,
    'fix_q_encoder': False,
    'fix_ctx_encoder': False,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type BiEncoder — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a BiEncoder output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
BiEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
luyug/GC-DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("2a7bedc5746a0acb")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, luyug/GC-DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BiEncoder Ran
ran on a synthesized input
alexlimh/DPR_MUF/dpr/models/biencoder.py
pointer only (licence: NONE) · get_code("2636897c847a74e7")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, alexlimh/DPR_MUF when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BiEncoder Ran
ran on a synthesized input
nidhikamal-emb/DPR_repo/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("f395e69cf2723c98")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, nidhikamal-emb/DPR_repo (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BiEncoderBatch Ran
ran on a synthesized input · constructed an object; no result was computed
luyug/GC-DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("1ccc1581e033d222")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, luyug/GC-DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

DualEncoder Ran
ran on a synthesized input · constructed an object; no result was computed
Hannibal046/nanoDPR/train_dpr.py
pointer only (licence: NONE) · get_code("66b0a842536d2529")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, Hannibal046/nanoDPR when it was checked. The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

MyBiEncoder Ran
ran on a synthesized input
amzn/refuel-open-domain-qa/models/biencoder.py
code served (permissive licence) · get_code("74f56feb6089930e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned tuple. The image it ran in was not recorded. The code mentions cuda, and the harness aliases cuda to the CPU for every sample; whether this run needed that is not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import torch
from transformers import BertConfig

INIT_ARGS = {
    'config': BertConfig(
        vocab_size=1000,
        hidden_size=64,
        num_hidden_layers=2,
        num_attention_heads=2,
        intermediate_size=128,
        max_position_embeddings=512,
    )
}

ARGS = {
    'q_input_ids': torch.randint(0, 1000, (2, 8)),
    'q_attention_mask': torch.ones(2, 8, dtype=torch.long),
    'p_input_ids': torch.randint(0, 1000, (2, 3, 8)),
    'p_attention_mask': torch.ones(2, 3, 8, dtype=torch.long),
    'is_training': False,
}
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
torch, transformers — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)
cross_replica_concat Ran
ran on a synthesized input
Ankur3107/dpr-tf/src/dense_passage_retriever.py
code served (permissive licence) · get_code("6daeb2af140c2153")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned EagerTensor, ndim 2, dtype family float, shape (4, 4) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import tensorflow as tf
import numpy as np

# Mock the distributed context for testing
class MockReplicaContext:
    def __init__(self, replica_id=0, num_replicas=2):
        self.replica_id_in_sync_group = replica_id
        self.num_replicas = num_replicas
    
    def all_gather(self, values, axis=0):
        # Simulate gathering from all replicas by concatenating along axis
        # In a real distributed setting, this would gather from all replicas
        # Here we simulate by repeating the tensor num_replicas times
        gathered_list = [values for _ in range(self.num_replicas)]
        return tf.concat(gathered_list, axis=axis)

# Create a small tensor to pass to the function
# Shape: (2, 4) - batch size 2, feature dimension 4
values = tf.constant([[1.0, 2.0, 3.0, 4.0],
                       [5.0, 6.0, 7.0, 8.0]], dtype=tf.float32)

# Patch tf.distribute.get_replica_context to return our mock context
original_get_context = tf.distribute.get_replica_context
tf.distribute.get_replica_context = lambda: MockReplicaContext(replica_id=0, num_replicas=2)

ARGS = {
    "values": values
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EagerTensor, ndim 2, dtype family float, shape (4, 4) — shape (4, 4) as a later run recorded it
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
normalize_question Ran
ran; our contract draft was wrong, not the code
hongyuntw/DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("e34c0cb58f92bbab")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, hongyuntw/DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. A run is recorded.

BiEncoder Not yet run
unverified (harvested, no recorded run)
facebookresearch/DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("ce8859f3bf1c3bff")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, facebookresearch/DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Tensorizer Not yet run
unverified (harvested, no recorded run)
hongyuntw/DPR/dpr/models/biencoder.py
pointer only (licence: NOASSERTION) · get_code("15a8673b02cc06ff")
How it ran

The body of this sample is withheld: GitHub could not classify the licence of this paper's repository, hongyuntw/DPR (NOASSERTION). The setup block that called it is withheld with it, because it is written against that body. source_path and origin say where the code lives, to read under the repository's own terms. No invocation recorded.

Tensorizer Not yet run
unverified (harvested, no recorded run)
oriram/spider/dpr/models/biencoder.py
code served (permissive licence) · get_code("62589f451f5aa0bd")
How it ran

no invocation recorded.

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 2 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 2 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

FunctionAlso present inEarliest-datedOthers named
Tensorizer
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2110.04889 (2021-10)
Distantly-Supervised Evidence Retrieval Enables Question Answering without Evidence Annotation
2206.03281 (2022-06)
Unsupervised Context Aware Sentence Representation Pretraining for Multi-lingual Dense Retrieval
normalize_question
brick of this paper's assembly: helper
2 other papers
2 later · 2 only as an assembly brick
2110.04889 (2021-10)
Distantly-Supervised Evidence Retrieval Enables Question Answering without Evidence Annotation
2206.03281 (2022-06)
Unsupervised Context Aware Sentence Representation Pretraining for Multi-lingual Dense Retrieval

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Open-domain question answering relies on efficient passage retrieval to select candidate contexts, where traditional sparse vector space models, such as TF-IDF or BM25, are the de facto method. In this work, we show that retrieval can be practically implemented using dense representations alone, where embeddings are learned from a small number of questions and passages by a simple dualencoder framework. When evaluated on a wide range of open-domain QA datasets, our dense retriever outperforms a strong Lucene-BM25 system greatly by 9%-19% absolute in terms of top-20 passage retrieval accuracy, and helps our end-to-end QA system establish new state-of-the-art on multiple open-domain QA benchmarks. 1 * Equal contribution 1 The code and trained models have been released at https://github.com/facebookresearch/DPR. 2 For instance, the exact match score on SQuAD v1.1 drops from above 80% to less than 40% (Yang et al., 2019a).

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2004.04906")
get_code_for_paper("2004.04906")
have("2004.04906")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2004.04906.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2004.04906.svg)](https://syntology.ai/paper/2004.04906)

Connect an agent — have() is free.