SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2305.06983 · EMNLP · 2023

Active Retrieval Augmented Generation

Graham Neubig, Yiming Yang, Qian Liu, Zhiqing Sun, Zhengbao Jiang, Luyu Gao, Jamie Callan, Jane Dwivedi-Yu, Frank F. Xu

arXiv · PDF · Open in the Atlas

Code that ran

2 of 5 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 2 have no contract verdict; 0 failures of our instrument; 3 no recorded run), measured 2026-11-23; 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/2305.06983.json · badge: /api/ran/2305.06983.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
jzbjyb/flare canonical (classifier label)
classifier basis: census
2 ran · 3 no recorded run
FunctionStatusWhere it lives
bm25search_search Ran
ran on a synthesized input
jzbjyb/flare/src/retriever.py
code served (permissive licence) · get_code("9263211c0a0e3ad8")
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 dict. 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 numpy as np
from typing import Dict, Tuple

class MockElasticsearch:
    """Mock elasticsearch client that implements lexical_multisearch"""
    def lexical_multisearch(self, texts, filter_ids, top_hits):
        """Return mock search results"""
        results = []
        for text in texts:
            # Return a list of hits, each hit is (corpus_id, score, text)
            hits = {
                'hits': [
                    ('doc_1', 0.95, 'sample text 1'),
                    ('doc_2', 0.87, 'sample text 2'),
                ]
            }
            results.append(hits)
        return results

class MockBM25Search:
    """Mock BM25 search class that implements the interface needed by bm25search_search"""
    def __init__(self):
        self.initialize = True
        self.sleep_for = 0
        self.batch_size = 2
        self.es = MockElasticsearch()
        self.indexed = False
    
    def index(self, corpus: Dict[str, Dict[str, str]]):
        """Mock indexing method"""
        self.indexed = True

# Construct corpus
corpus = {
    'doc_1': {'title': 'First Document', 'text': 'This is the first document'},
    'doc_2': {'title': 'Second Document', 'text': 'This is the second document'},
    'doc_3': {'title': 'Third Document', 'text': 'This is the third document'},
}

# Construct queries: Dict[query_id, Tuple[query_text, filter_id]]
queries = {
    'q_1': ('what is this', 'filter_1'),
    'q_2': ('tell me more', 'filter_2'),
    'q_3': ('another query', 'filter_3'),
    'q_4': ('final question', 'filter_4'),
}

# Create the mock search instance
mock_search = MockBM25Search()

# Define ARGS
ARGS = {
    'self': mock_search,
    'corpus': corpus,
    'queries': queries,
    'top_k': 2,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, torch, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type dict — a dict output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a dict 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
elasticsearch_lexical_multisearch Ran
ran on a synthesized input
jzbjyb/flare/src/retriever.py
code served (permissive licence) · get_code("5acb1fd13ba8f119")
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 list, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim 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.

from unittest.mock import Mock, MagicMock

class MockElasticsearch:
    def msearch(self, body):
        # Mock response structure matching what the function expects
        return {
            'responses': [
                {
                    'hits': {
                        'hits': [
                            {
                                '_id': 'doc1',
                                '_score': 0.95,
                                '_source': {'txt': 'sample text 1'}
                            },
                            {
                                '_id': 'doc2',
                                '_score': 0.87,
                                '_source': {'txt': 'sample text 2'}
                            }
                        ]
                    }
                },
                {
                    'hits': {
                        'hits': [
                            {
                                '_id': 'doc3',
                                '_score': 0.92,
                                '_source': {'txt': 'sample text 3'}
                            }
                        ]
                    }
                }
            ]
        }

class MockSearcher:
    def __init__(self):
        self.es = MockElasticsearch()
        self.index_name = 'test_index'
        self.title_key = 'title'
        self.text_key = 'content'
    
    def hit_template(self, es_res, hits):
        return {
            'hits': hits,
            'total': len(hits)
        }
    
    def elasticsearch_lexical_multisearch(self, texts, filter_ids=None, top_hits=10, skip=0):
        request = []
        assert skip + top_hits <= 10000, 'Elastic-Search Window too large, Max-Size = 10000'
        filter_ids = filter_ids or [None] * len(texts)
        for text, fid in zip(texts, filter_ids):
            req_head = {'index': self.index_name, 'search_type': 'dfs_query_then_fetch'}
            if fid is not None:
                req_body = {'_source': True, 'query': {'bool': {'must': {'multi_match': {'query': text, 'type': 'best_fields', 'fields': [self.title_key, self.text_key], 'tie_breaker': 0.5}}, 'filter': {'term': {'_id': fid}}}}, 'size': skip + top_hits}
            else:
                req_body = {'_source': True, 'query': {'multi_match': {'query': text, 'type': 'best_fields', 'fields': [self.title_key, self.text_key], 'tie_breaker': 0.5}}, 'size': skip + top_hits}
            request.extend([req_head, req_body])
        res = self.es.msearch(body=request)
        result = []
        for resp in res['responses']:
            responses = resp['hits']['hits'][skip:] if 'hits' in resp else []
            hits = []
            for hit in responses:
                hits.append((hit['_id'], hit['_score'], hit['_source']['txt']))
            result.append(self.hit_template(es_res=resp, hits=hits))
        return result

searcher = MockSearcher()

ARGS = {
    'self': searcher,
    'texts': ['machine learning query', 'deep learning models'],
    'filter_ids': ['filter1', 'filter2'],
    'top_hits': 10,
    'skip': 0
}
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 list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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
elasticsearch_hit_template Not yet run
unverified (harvested, no recorded run)
jzbjyb/flare/src/retriever.py
pointer only (licence: MIT); the stored copy get_code serves, from thu-keg/seakr, is pointer only (licence: GPL-3.0) · get_code("189363ca95998f9a")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (MIT), but get_code serves the stored copy, first harvested from thu-keg/seakr, and GPL-3.0, as GitHub detects it on that repository, is not in the permissive set Syntology serves inline. 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.

search_bing_api Not yet run
unverified (harvested, no recorded run)
jzbjyb/flare/src/bing.py
code served (permissive licence) · get_code("5495f41fd029b69c")
How it ran

no invocation recorded.

search_bing_batch Not yet run
unverified (harvested, no recorded run)
jzbjyb/flare/src/bing.py
code served (permissive licence) · get_code("e3c17172dbe9dace")
How it ran

no invocation recorded.

Also present in other papers' code

Of 5 samples lifted from this paper's linked repositories, 5 carry a function identity and 0 do not. Of the 5 distinct functions with an identity, 1 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 1 later) and 4 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
elasticsearch_hit_template 3 other papers
3 later
2403.10081 (2024-03)
DRAGIN: Dynamic Retrieval Augmented Generation based on the Information Needs of Large Language Models
2406.19215 (2024-06)
SeaKR: Self-aware Knowledge Retrieval for Adaptive Retrieval Augmented Generation
2025.acl-long.548 (2025 (year only))
Improving Factuality with Explicit Working Memory

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-23.

Repositories linked to this paper

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

Abstract

Despite the remarkable ability of large language models (LMs) to comprehend and generate language, they have a tendency to hallucinate and create factually inaccurate output. Augmenting LMs by retrieving information from external knowledge resources is one promising solution. Most existing retrieval augmented LMs employ a retrieve-and-generate setup that only retrieves information once based on the input. This is limiting, however, in more general scenarios involving generation of long texts, where continually gathering information throughout generation is essential. In this work, we provide a generalized view of active retrieval augmented generation, methods that actively decide when and what to retrieve across the course of the generation. We propose Forward-Looking Active REtrieval augmented generation (FLARE), a generic method which iteratively uses a prediction of the upcoming sentence to anticipate future content, which is then utilized as a query to retrieve relevant documents to regenerate the sentence if it contains low-confidence tokens. We test FLARE along with baselines comprehensively over 4 longform knowledge-intensive generation tasks/datasets. FLARE achieves superior or competitive performance on all tasks, demonstrating the effectiveness of our method. 1 * Lead contributors.

For agents

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

get_harvested_code_for_paper("2305.06983")
get_code_for_paper("2305.06983")
have("2305.06983")

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

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

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

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

Connect an agent — have() is free.