SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2308.08973 · 2023

End-to-End Beam Retrieval for Multi-Hop Question Answering

arXiv · PDF · Open in the Atlas

Code that ran

10 of 13 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; 3 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 7 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/2308.08973.json · badge: /api/ran/2308.08973.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
canghongjian/beam_retriever canonical (classifier label)
classifier basis: census
10 ran · 3 no recorded run
FunctionStatusWhere it lives
calculate_em_f1 Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/train_beam_retriever.py
code served (permissive licence) · get_code("14b4dc86a2f9d5fe")
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 tuple, 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.

import torch
import numpy as np

# The function calculate_em_f1 takes two parameters:
# - predicted_support_idxs: expected to be an iterable of indices that can be converted to int
# - gold_support_idxs: expected to be an iterable of indices that can be converted to int

# The function converts both to sets of ints and calculates precision, recall, F1 and exact match

# Create test data - simple lists of integers representing support indices
predicted_support_idxs = [0, 1, 3]
gold_support_idxs = [0, 1, 2]

ARGS = {
    "predicted_support_idxs": predicted_support_idxs,
    "gold_support_idxs": gold_support_idxs,
}
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 tuple, ndim 1, dtype family float — a tuple 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
collate_fn Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/retrieval/datasets.py
code served (permissive licence) · get_code("623c2ebe4e288e5d")
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

torch.manual_seed(0)

# Construct sample data that matches the expected structure
sample_1 = {
    'q_codes': torch.tensor([1, 2, 3, 4]),
    'c_codes': torch.tensor([5, 6, 7, 8]),
    'sf_idx': 0,
    'id': 'sample_1'
}

sample_2 = {
    'q_codes': torch.tensor([9, 10, 11, 12]),
    'c_codes': torch.tensor([13, 14, 15, 16]),
    'sf_idx': 1,
    'id': 'sample_2'
}

# Create a list of samples to pass to collate_fn
samples = [sample_1, sample_2]

# Define ARGS with the samples parameter
ARGS = {
    'samples': samples
}
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 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
collate_fn_each_hop Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/retrieval/datasets.py
code served (permissive licence) · get_code("385a19954a28f7ad")
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

torch.manual_seed(0)

# Create sample data that matches what the function expects
samples = [
    {
        'input_ids': torch.tensor([[101, 2054, 2003, 1998]], dtype=torch.long),
        'label': torch.tensor(0, dtype=torch.long),
        'hop': 1
    },
    {
        'input_ids': torch.tensor([[101, 2054, 2003]], dtype=torch.long),
        'label': torch.tensor(1, dtype=torch.long),
        'hop': 2
    }
]

ARGS = {
    'samples': samples
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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
compute_exact Ran
ran, honoured the contract we drafted
canghongjian/beam_retriever/train_reader.py
code served (permissive licence) · get_code("c1478415449411ed")
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 int, ndim 0, dtype family int, shape () 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 re
import string

def normalize_answer(s):

    def remove_articles(text):
        return re.sub('\\b(a|an|the)\\b', ' ', text)

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_articles(remove_punc(lower(s))))

def compute_exact(a_gold, a_pred):
    return int(normalize_answer(a_gold) == normalize_answer(a_pred))

ARGS = {
    'a_gold': 'The quick brown fox jumps over the lazy dog.',
    'a_pred': 'the quick brown fox jumps over the lazy dog'
}
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 int, ndim 0, dtype family int, shape () — shape () 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
get_next Ran
ran, honoured the contract we drafted
canghongjian/beam_retriever/qa/datasets.py
code served (permissive licence) · get_code("13a7774be41bd187")
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 int; 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.

import torch

# This function appears to be computing the KMP (Knuth-Morris-Pratt) failure function
# It expects a sequence `s` where it compares elements using == operator
# The sequence needs to support indexing and len()

# Create a simple string as the sequence parameter
s = "ababac"

ARGS = {
    "s": s
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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 int — 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
get_tokens Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/gpt_turbo_exp.py
code served (permissive licence) · get_code("8a4f13df2795176e")
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.

import re
import string

def normalize_answer(s):

    def remove_articles(text):
        return re.sub('\\b(a|an|the)\\b', ' ', text)

    def white_space_fix(text):
        return ' '.join(text.split())

    def remove_punc(text):
        exclude = set(string.punctuation)
        return ''.join((ch for ch in text if ch not in exclude))

    def lower(text):
        return text.lower()
    return white_space_fix(remove_articles(remove_punc(lower(s))))

def get_tokens(s):
    if not s:
        return []
    return normalize_answer(s).split()

ARGS = {
    "s": "The quick brown fox jumps over the lazy dog!"
}
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
kmp Ran
ran, honoured the contract we drafted
canghongjian/beam_retriever/qa/datasets.py
code served (permissive licence) · get_code("e142253af9285485")
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 int, ndim 0, dtype family int, shape () 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.

# Setup for KMP string matching function

# The function operates on sequences (strings or lists) where elements can be compared with ==
# src: source sequence to search in
# tgt: target sequence to search for

# Simple test case: finding a pattern in a text
src = "ABABDABACDABABCABAB"  # source string
tgt = "ABABCABAB"             # target pattern to find

ARGS = {
    "src": src,
    "tgt": tgt
}
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 int, ndim 0, dtype family int, shape () — shape () 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
load_saved Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/utils/utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from yuwvandy/kg-llm-mdqa, is pointer only (licence: NONE) · get_code("69c2c7b48e030046")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from yuwvandy/kg-llm-mdqa, and GitHub detected no licence in that repository 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.

move_to_cuda Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
canghongjian/beam_retriever/utils/utils.py
code served (permissive licence) · get_code("a4978f078a7eb7ec")
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. 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

torch.manual_seed(0)

# The function move_to_cuda recursively moves tensors to CUDA
# It accepts a sample which can be:
# - empty dict
# - dict with tensor/dict/list/other values
# - list with tensor/dict/list/other values
# - tensor
# - other types (returned as-is)

# Create a complex nested structure to test the recursive behavior
sample = {
    "tensor_1": torch.randn(2, 4),
    "tensor_2": torch.randn(3, 5),
    "nested_dict": {
        "inner_tensor": torch.randn(2, 6),
        "scalar": 42,
    },
    "list_data": [
        torch.randn(1, 4),
        {"nested_in_list": torch.randn(2, 3)},
        "string_value",
    ],
    "plain_value": 3.14,
}

ARGS = {
    "sample": sample,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — 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
normalize_answer Ran
ran; our contract draft was wrong, not the code
canghongjian/beam_retriever/gpt_turbo_exp.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from shmsw25/GraphRetriever, is pointer only (licence: NONE) · get_code("dae7ab386661a4f4")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from shmsw25/GraphRetriever, and GitHub detected no licence in that repository 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.

get_response Not yet run
unverified (harvested, no recorded run)
canghongjian/beam_retriever/llm_exp_long.py
code served (permissive licence) · get_code("0a8f1af973c82ca0")
How it ran

no invocation recorded.

gpt_turbo_request Not yet run
unverified (harvested, no recorded run)
canghongjian/beam_retriever/gpt_turbo_exp.py
code served (permissive licence) · get_code("8e84eac6133f306f")
How it ran

no invocation recorded.

reader_mhop_collate Not yet run
unverified (harvested, no recorded run)
canghongjian/beam_retriever/qa/datasets.py
code served (permissive licence) · get_code("0918ce50e5647e35")
How it ran

no invocation recorded.

Also present in other papers' code

Of 13 samples lifted from this paper's linked repositories, 13 carry a function identity and 0 do not. Of the 13 distinct functions with an identity, 4 are also present in other papers whose code we hold (3 with at least one paper dated earlier, 3 the same month, 3 later) and 9 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
normalize_answer 133 other papers
44 dated earlier, 3 the same month, 84 later, 1 same year, order not determinable, 1 undated · 1 only as an assembly brick
1508.06615 (2015-08)
Character-Aware Neural Language Models
1606.05250 (2016-06)
SQuAD: 100,000+ Questions for Machine Comprehension of Text
1608.07905 (2016-08)
Machine Comprehension Using Match-LSTM and Answer Pointer
and 130 more not named here
get_tokens 25 other papers
13 dated earlier, 1 the same month, 10 later, 1 same year, order not determinable
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
1908.08962 (2019-08)
Well-Read Students Learn Better: On the Importance of Pre-training Compact Models
and 22 more not named here
compute_exact 11 other papers
4 dated earlier, 6 later, 1 same year, order not determinable
1902.01718 (2019-02)
End-to-End Open-Domain Question Answering with BERTserini
2004.07347 (2020-04)
HybridQA: A Dataset of Multi-Hop Question Answering over Tabular and Textual Data
2105.02692 (2021-05)
Learning to Perturb Word Embeddings for Out-of-distribution QA
and 8 more not named here
load_saved 1 other paper
1 the same month
2308.11730 (2023-08)
Knowledge Graph Prompting for Multi-Document Question Answering

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

Multi-hop question answering (QA) involves finding multiple relevant passages and step-by-step reasoning to answer complex questions, indicating a retrieve-and-read paradigm. However, previous retrievers were customized for two-hop questions, and most of them were trained separately across different hops, resulting in a lack of supervision over the entire multi-hop retrieval process and leading to poor performance in complicated scenarios beyond two hops. In this work, we introduce Beam Retrieval, an end-to-end beam retrieval framework for multi-hop QA. This approach models the multi-hop retrieval process in an end-to-end manner by jointly optimizing an encoder and two classification heads across all hops. Moreover, Beam Retrieval maintains multiple partial hypotheses of relevant passages at each step, expanding the search space and reducing the risk of missing relevant passages. To establish a complete QA system, we incorporate a supervised reader or a large language model (LLM). Experimental results demonstrate that Beam Retrieval achieves a nearly 50% improvement compared with baselines on challenging MuSiQue-Ans, and it also surpasses all previous retrievers on HotpotQA and achieves 99.9% precision on 2WikiMultiHopQA. Providing high-quality context, Beam Retrieval helps our supervised reader achieve new state-of-the-art performance and substantially improves the few-shot QA performance of LLMs.

For agents

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

get_harvested_code_for_paper("2308.08973")
get_code_for_paper("2308.08973")
have("2308.08973")

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

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

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

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

Connect an agent — have() is free.