SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2005.11401 · NeurIPS · 2020

Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks

Douwe Kiela, Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-Tau Yih, Tim Rocktäschel, Sebastian Riedel

arXiv · PDF · Open in the Atlas

Code that ran

6 of 6 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (3 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 5 have no contract verdict; 1 failure of our instrument; 0 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/2005.11401.json · badge: /api/ran/2005.11401.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
amaiya/onprem community
Papers with Code archive
3 ran · 0 no recorded run
docarray/docarray community (classifier label)
classifier basis not recorded on the link
2 ran · 0 no recorded run
assafelovic/gpt-researcher community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
RAGPipeline Ran
ran on a synthesized input · constructed an object; no result was computed
amaiya/onprem/onprem/pipelines/rag.py
code served (permissive licence) · get_code("97232ee5cefc6ca0")
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, RAGPipeline: 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 langchain_core.documents import Document
from typing import Optional, Dict, List, Any


class MockLLM:
    """Mock LLM object that provides minimal interface for RAGPipeline."""
    
    def __init__(self):
        self.store_type = 'dense'
        self._vectorstore = MockVectorStore()
    
    def load_vectorstore(self):
        """Load and return the mock vector store."""
        return self._vectorstore


class MockVectorStore:
    """Mock vector store that simulates semantic search functionality."""
    
    def __init__(self):
        self.documents = [
            Document(
                page_content="Uber revenue growth in 2021 was significant",
                metadata={"source": "/data/uber_2021.txt", "score": 0.95}
            ),
            Document(
                page_content="Lyft reported strong EBITDA metrics",
                metadata={"source": "/data/lyft_2021.txt", "score": 0.87}
            ),
            Document(
                page_content="Comparative analysis of ride-sharing companies",
                metadata={"source": "/data/comparison.txt", "score": 0.78}
            ),
        ]
    
    def get_size(self) -> int:
        """Return the size of the store."""
        return len(self.documents)
    
    def semantic_search(
        self,
        query: str,
        filters: Optional[Dict[str, str]] = None,
        where_document = None,
        limit: int = 4,
        **kwargs
    ) -> List[Document]:
        """Perform semantic search and return documents."""
        results = self.documents[:limit]
        return results


class MockConfig:
    """Mock configuration object."""
    
    def __init__(self):
        self.model_type = "qa"
        self.max_length = 512


# Setup arguments for RAGPipeline.__init__
llm = MockLLM()

qa_template = "Use the following pieces of context delimited by three backticks to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.\n\n```{context}```\n\nQuestion: {question}\nHelpful Answer:"

ARGS = {
    "llm": llm,
    "qa_template": qa_template,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
langchain_core, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type RAGPipeline — 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 RAGPipeline 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
SafeFormatter Ran
ran on a synthesized input · constructed an object; no result was computed
amaiya/onprem/onprem/pipelines/rag.py
code served (permissive licence) · get_code("0e37c1a090eb1522")
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, SafeFormatter: 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 re
from typing import Optional, Dict, List

class SafeFormatter:
    """
    Safe string formatter that does not raise KeyError if key is missing.
    Adapted from llama_index.
    """

    def __init__(self, format_dict: Optional[Dict[str, str]]=None):
        self.format_dict = format_dict or {}

    def format(self, format_string: str) -> str:
        return re.sub('\\{([^{}]+)\\}', self._replace_match, format_string)

    def parse(self, format_string: str) -> List[str]:
        return re.findall('\\{([^{}]+)\\}', format_string)

    def _replace_match(self, match: re.Match) -> str:
        key = match.group(1)
        return str(self.format_dict.get(key, match.group(0)))


ARGS = {
    "format_dict": {
        "name": "Alice",
        "age": "30",
        "city": "New York"
    }
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SafeFormatter — 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 SafeFormatter 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
SearchAPIRetriever Ran
ran on a synthesized input · constructed an object; no result was computed
assafelovic/gpt-researcher/gpt_researcher/context/retriever.py
code served (permissive licence) · get_code("8ebc0b59ac8e1139")
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, SearchAPIRetriever: 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 os
from typing import Any, Dict, List, Optional
from langchain_core.callbacks import CallbackManagerForRetrieverRun
from langchain_core.documents import Document
from langchain_core.retrievers import BaseRetriever

# Set a small MAX_CONTENT_CHARS for testing
os.environ['MAX_CONTENT_CHARS'] = '1000'

# Create sample pages data structure
pages = [
    {
        'raw_content': 'This is the content of the first page with some sample text.',
        'title': 'First Page',
        'url': 'https://example.com/page1'
    },
    {
        'raw_content': 'This is the content of the second page with different information.',
        'title': 'Second Page',
        'url': 'https://example.com/page2'
    },
    {
        'raw_content': None,  # Test case with missing raw_content
        'title': 'Third Page',
        'url': 'https://example.com/page3'
    }
]

# Create a mock CallbackManagerForRetrieverRun
class MockCallbackManager:
    pass

mock_run_manager = MockCallbackManager()

# Define ARGS dictionary with all parameters for SearchAPIRetriever
ARGS = {
    'pages': pages
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
langchain_core — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SearchAPIRetriever — 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 SearchAPIRetriever 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
format_string Ran
ran; our contract draft was wrong, not the code
amaiya/onprem/onprem/pipelines/rag.py
code served (permissive licence) · get_code("b5b35b915ca92dc5")
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 str. 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 re
from typing import Optional, Dict, List, Any

class SafeFormatter:
    """
    Safe string formatter that does not raise KeyError if key is missing.
    Adapted from llama_index.
    """

    def __init__(self, format_dict: Optional[Dict[str, str]]=None):
        self.format_dict = format_dict or {}

    def format(self, format_string: str) -> str:
        return re.sub('\\{([^{}]+)\\}', self._replace_match, format_string)

    def parse(self, format_string: str) -> List[str]:
        return re.findall('\\{([^{}]+)\\}', format_string)

    def _replace_match(self, match: re.Match) -> str:
        key = match.group(1)
        return str(self.format_dict.get(key, match.group(0)))

def format_string(string_to_format: str, **kwargs: str) -> str:
    """Format a string with kwargs"""
    formatter = SafeFormatter(format_dict=kwargs)
    return formatter.format(string_to_format)

ARGS = {
    "string_to_format": "Hello {name}, you are {age} years old",
    "name": "Alice",
    "age": "30"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
get_paths Ran
ran on a synthesized input
docarray/docarray/docarray/helper.py
code served (permissive licence) · get_code("f54f8f538675cd65")
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 generator. 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 os
import tempfile
from pathlib import Path

# Create a temporary directory with some test files
temp_dir = tempfile.mkdtemp()

# Create some test files
test_files = [
    os.path.join(temp_dir, 'file1.txt'),
    os.path.join(temp_dir, 'file2.txt'),
    os.path.join(temp_dir, 'file3.py'),
    os.path.join(temp_dir, 'test_file.txt'),
]

for file_path in test_files:
    with open(file_path, 'w') as f:
        f.write('test content')

# Create a subdirectory with more files
subdir = os.path.join(temp_dir, 'subdir')
os.makedirs(subdir, exist_ok=True)
subdir_file = os.path.join(subdir, 'nested.txt')
with open(subdir_file, 'w') as f:
    f.write('nested content')

# Define arguments for get_paths
ARGS = {
    'patterns': os.path.join(temp_dir, '*.txt'),
    'recursive': True,
    'size': None,
    'exclude_regex': None,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type generator — a generator output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a generator 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
identity Ran
ran on a synthesized input
docarray/docarray/docarray/computation/numpy_backend.py
code served (permissive licence) · get_code("e855f42db656867c")
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 ndarray, ndim 2, dtype family float, shape (2, 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 numpy as np

# Create a simple numpy array
array = np.array([[1, 2, 3, 4],
                   [5, 6, 7, 8]], dtype=np.float32)

ARGS = {
    "array": array
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type ndarray, ndim 2, dtype family float, shape (2, 4) — shape (2, 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

Also present in other papers' code

Of 6 samples lifted from this paper's linked repositories, 6 carry a function identity and 0 do not. Of the 6 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 6 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.

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

Large pre-trained language models have been shown to store factual knowledge in their parameters, and achieve state-of-the-art results when fine-tuned on downstream NLP tasks. However, their ability to access and precisely manipulate knowledge is still limited, and hence on knowledge-intensive tasks, their performance lags behind task-specific architectures. Additionally, providing provenance for their decisions and updating their world knowledge remain open research problems. Pretrained models with a differentiable access mechanism to explicit non-parametric memory have so far been only investigated for extractive downstream tasks. We explore a general-purpose fine-tuning recipe for retrieval-augmented generation (RAG) -models which combine pre-trained parametric and non-parametric memory for language generation. We introduce RAG models where the parametric memory is a pre-trained seq2seq model and the non-parametric memory is a dense vector index of Wikipedia, accessed with a pre-trained neural retriever. We compare two RAG formulations, one which conditions on the same retrieved passages across the whole generated sequence, and another which can use different passages per token. We fine-tune and evaluate our models on a wide range of knowledgeintensive NLP tasks and set the state of the art on three open domain QA tasks, outperforming parametric seq2seq models and task-specific retrieve-and-extract architectures. For language generation tasks, we find that RAG models generate more specific, diverse and factual language than a state-of-the-art parametric-only seq2seq baseline.

For agents

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

get_harvested_code_for_paper("2005.11401")
get_code_for_paper("2005.11401")
have("2005.11401")

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

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

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

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

Connect an agent — have() is free.