SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2024.findings-acl.708 · ACL Findings · 2024

Analyze, Generate and Refine: Query Expansion with LLMs for Zero-Shot Open-Domain QA

Ben He, Le Sun, Xuanang Chen, Xinran Chen, Tengfei Wen

Code that ran

9 of 9 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 3 have no contract verdict; 6 failures of our instrument; 0 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, measured 2026-11-24; 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/2024.findings-acl.708.json · badge: /api/ran/2024.findings-acl.708.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
process-cxr/AGR canonical (classifier label)
classifier basis: census
9 ran · 0 no recorded run
FunctionStatusWhere it lives
dot_product_scores Ran
ran; our contract draft was wrong, not the code
process-cxr/AGR/dpr/models/biencoder.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from facebookresearch/dpr, is pointer only (licence: NOASSERTION) · get_code("928414780ee23e45")
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 facebookresearch/dpr, and GitHub could not classify the licence of that repository (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.

compute_loss Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
process-cxr/AGR/dpr/models/reader.py
code served (permissive licence) · get_code("1df81ea9d2da7b70")
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) and returned Tensor, ndim 0, dtype family float; no output shape is stated. 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 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
from torch.nn import CrossEntropyLoss

torch.manual_seed(0)

# Parameters based on function signature and usage:
# N = batch size (number of questions)
# M = number of candidate passages
# The function reshapes tensors to (N*M, -1) and processes them

N = 2
M = 3
seq_len = 4  # sequence length for start/end positions and logits

# start_positions: shape (N, M, 1) -> reshaped to (N*M, 1)
start_positions = torch.randint(0, seq_len, (N, M, 1), dtype=torch.long)

# end_positions: shape (N, M, 1) -> reshaped to (N*M, 1)
end_positions = torch.randint(0, seq_len, (N, M, 1), dtype=torch.long)

# answer_mask: shape (N, M, 1) -> reshaped to (N*M, 1)
# Used as float mask for multiplication
answer_mask = torch.randint(0, 2, (N, M, 1), dtype=torch.long)

# start_logits: shape (N*M, seq_len) before reshape, so input is (N, M, seq_len)
start_logits = torch.randn(N, M, seq_len)

# end_logits: shape (N*M, seq_len) before reshape, so input is (N, M, seq_len)
end_logits = torch.randn(N, M, seq_len)

# relevance_logits: shape (N*M,) before reshape to (N, M), so input is (N, M)
relevance_logits = torch.randn(N, M)

ARGS = {
    "start_positions": start_positions,
    "end_positions": end_positions,
    "answer_mask": answer_mask,
    "start_logits": start_logits,
    "end_logits": end_logits,
    "relevance_logits": relevance_logits,
    "N": N,
    "M": M,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 0, dtype family float — no output shape is stated: observe_signature.py could not observe it (call:AssertionError)
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
cosine_scores Ran
ran; our contract draft was wrong, not the code
process-cxr/AGR/dpr/models/biencoder.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from facebookresearch/dpr, is pointer only (licence: NOASSERTION) · get_code("4c7d079ed8d8dd58")
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 facebookresearch/dpr, and GitHub could not classify the licence of that repository (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.

get_datasets Ran
ran on a synthesized input
process-cxr/AGR/retriever_utils.py
code served (permissive licence) · get_code("1840e16e501abdc9")
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 tempfile
import csv
import json
from pathlib import Path

# Create temporary directory for test files
temp_dir = tempfile.mkdtemp()

# Create a sample CSV file
csv_file = Path(temp_dir) / "test_dataset.csv"
with open(csv_file, 'w', newline='') as f:
    writer = csv.writer(f, delimiter='\t')
    writer.writerow(["What is the capital of France?", "['Paris', 'paris']"])
    writer.writerow(["What is 2+2?", "['4', 'four']"])

# Create a sample JSON file
json_file = Path(temp_dir) / "test_dataset.json"
json_data = [
    {"question": "What is the capital of Germany?", "answers": ["Berlin", "berlin"]},
    {"question": "What is the largest planet?", "answers": ["Jupiter", "jupiter"]}
]
with open(json_file, 'w') as f:
    json.dump(json_data, f)

# Define the pattern to match both files
qa_file_pattern = f"{temp_dir}/*.csv,{temp_dir}/*.json"

ARGS = {
    "qa_file_pattern": qa_file_pattern
}
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 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
get_encoder_params_state Ran
ran; our contract draft was wrong, not the code
process-cxr/AGR/options.py
code served (permissive licence) · get_code("2e1d17bdf7c14048")
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 torch.nn as nn

# Build a small stand-in args object with all required attributes
class Args:
    def __init__(self):
        self.do_lower_case = True
        self.pretrained_model_cfg = "bert-base-uncased"
        self.encoder_model_type = "bert"
        self.pretrained_file = "/path/to/model.pt"
        self.projection_dim = 768
        self.sequence_length = 512
        self.weight_sharing = False

args = Args()

ARGS = {
    "args": args
}
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
load_passages Ran
ran; our contract draft was wrong, not the code
process-cxr/AGR/retriever_utils.py
code served (permissive licence) · get_code("975966fd72462c49")
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 tempfile
import gzip
import csv
import os

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

# Create a test TSV file (uncompressed)
test_tsv_path = os.path.join(temp_dir, "test_passages.tsv")
with open(test_tsv_path, 'w', newline='') as f:
    writer = csv.writer(f, delimiter='\t')
    writer.writerow(['id', 'title', 'text'])
    writer.writerow(['doc1', 'Title One', 'Text content one'])
    writer.writerow(['doc2', 'Title Two', 'Text content two'])

# Create a test gzipped TSV file
test_gz_path = os.path.join(temp_dir, "test_passages.tsv.gz")
with gzip.open(test_gz_path, 'wt', newline='') as f:
    writer = csv.writer(f, delimiter='\t')
    writer.writerow(['id', 'title', 'text'])
    writer.writerow(['doc3', 'Title Three', 'Text content three'])
    writer.writerow(['doc4', 'Title Four', 'Text content four'])

# Define ARGS with the uncompressed TSV file path
ARGS = {
    'ctx_file': test_tsv_path
}
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 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
process_worker Ran
ran on a synthesized input
process-cxr/AGR/retrieval_result_synthesize.py
code served (permissive licence) · get_code("87608a5b0a6dec66")
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. 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 json
import tempfile
import os

# Create a temporary directory and JSON file for testing
temp_dir = tempfile.mkdtemp()
results_subdir = os.path.join(temp_dir, "experiment_key")
os.makedirs(results_subdir)
results_file = os.path.join(results_subdir, "results.json")

# Create sample data that matches what the function expects
sample_data = []
for i in range(40):
    sample_data.append({
        "question": f"What is question {i}?",
        "hit_min_rank": i % 5,
        "ctxs": [
            {"title": f"Title {i}_0", "text": f"Text content {i}_0"},
            {"title": f"Title {i}_1", "text": f"Text content {i}_1"},
            {"title": f"Title {i}_2", "text": f"Text content {i}_2"},
        ]
    })

# Write the JSON file
with open(results_file, 'w') as f:
    json.dump(sample_data, f)

# Define ARGS
ARGS = {
    "results_dir": results_file
}
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 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: none by the harness; any seed is in the setup block
set_encoder_params_from_state Ran
ran; our contract draft was wrong, not the code
process-cxr/AGR/options.py
code served (permissive licence) · get_code("33d1f092fabab342")
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 MockArgs. 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 logging
from argparse import Namespace

logger = logging.getLogger()

class MockArgs:
    """Stand-in args object that may or may not have the encoder parameters."""
    pass

# Create a state dict with some of the encoder checkpoint params
state = {
    'do_lower_case': True,
    'pretrained_model_cfg': 'bert-base',
    'encoder_model_type': 'bert',
    'pretrained_file': '/path/to/model.pt',
    'projection_dim': 768,
    'sequence_length': 512,
    'weight_sharing': False
}

# Create args object - start with some existing attributes to test override behavior
args = MockArgs()
args.do_lower_case = False  # This will be overridden
args.other_param = 'should_not_change'  # This should remain unchanged

ARGS = {
    'state': state,
    'args': args
}
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 MockArgs — a MockArgs output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a MockArgs 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
setup_logger Ran
ran on a synthesized input
process-cxr/AGR/simple_retriever.py
code served (permissive licence) · get_code("d4d799ec9f3b1aaf")
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 Logger. 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 logging
import tempfile
import os

# Create a temporary directory and file for logging
temp_dir = tempfile.mkdtemp()
log_path = os.path.join(temp_dir, "test.log")

ARGS = {
    "log_path": log_path
}
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 Logger — a Logger output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Logger 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

Also present in other papers' code

Of 9 samples lifted from this paper's linked repositories, 9 carry a function identity and 0 do not. Of the 9 distinct functions with an identity, 6 are also present in other papers whose code we hold (6 with at least one paper dated earlier, 0 the same month, 2 later) and 3 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
cosine_scores 7 other papers
3 dated earlier, 1 later, 3 same year, order not determinable
1911.03868 (2019-11)
Knowledge Guided Text Retrieval and Reading for Open Domain Question Answering
2106.05346 (2021-06)
End-to-End Training of Multi-Document Reader and Retriever for Open-Domain Question Answering
2205.09843 (2022-05)
Table Retrieval May Not Necessitate Table-specific Model Design
and 4 more not named here
dot_product_scores 7 other papers
3 dated earlier, 1 later, 3 same year, order not determinable
1911.03868 (2019-11)
Knowledge Guided Text Retrieval and Reading for Open Domain Question Answering
2106.05346 (2021-06)
End-to-End Training of Multi-Document Reader and Retriever for Open-Domain Question Answering
2205.09843 (2022-05)
Table Retrieval May Not Necessitate Table-specific Model Design
and 4 more not named here
compute_loss 5 other papers
3 dated earlier, 2 same year, order not determinable
2109.04014 (2021-09)
Weakly-Supervised Visual-Retriever-Reader for Knowledge-based Question Answering
2110.03611 (2021-10)
Adversarial Retriever-Ranker for dense text retrieval
2205.09843 (2022-05)
Table Retrieval May Not Necessitate Table-specific Model Design
and 2 more not named here
load_passages 4 other papers
3 dated earlier, 1 same year, order not determinable
2101.06983 (2021-01)
Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup
2102.08633 (2021-02)
Open-Retrieval Conversational Machine Reading
2023.findings-emnlp.957 (2023 (year only))
An Empirical Investigation of Implicit and Explicit Knowledge-Enhanced Methods for Ad Hoc Dataset Retrieval
and 1 more not named here
get_encoder_params_state 2 other papers
1 dated earlier, 1 same year, order not determinable
2007.00808 (2020-07)
Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval
2403.03516 (2024-03)
Unsupervised Multilingual Dense Retrieval via Generative Pseudo Labeling
set_encoder_params_from_state 2 other papers
1 dated earlier, 1 same year, order not determinable
2007.00808 (2020-07)
Approximate Nearest Neighbor Negative Contrastive Learning for Dense Text Retrieval
2403.03516 (2024-03)
Unsupervised Multilingual Dense Retrieval via Generative Pseudo Labeling

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

Repositories linked to this paper

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

Abstract

Query expansion (QE) is a critical component in the open-domain question answering (OpenQA) pipeline, enhancing the retrieval performance by broadening the scope of queries with additional relevant texts. However, existing methods like GAR and EAR rely heavily on supervised training and often struggle to maintain effectiveness across domains and datasets. Meanwhile, although large language models (LLMs) have demonstrated QE capability for information retrieval (IR) tasks, their application in OpenQA is hindered by the inadequate analysis of query's informational needs and the lack of quality control for generated QEs, failing to meet the unique requirements of OpenQA. To bridge this gap, we propose a novel LLM-based QE approach named AGR for the OpenQA task, leveraging a threestep prompting strategy. AGR begins with an analysis of the query, followed by the generation of answer-oriented expansions, and culminates with a refinement process for better query formulation. Extensive experiments on four OpenQA datasets reveal that AGR not only rivals in-domain supervised methods in retrieval accuracy, but also outperforms state-of-the-art baselines in out-of-domain zero-shot scenarios. Moreover, it exhibits enhanced performance in end-to-end QA evaluations, underscoring the superiority of AGR for OpenQA. 1

For agents

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

get_harvested_code_for_paper("2024.findings-acl.708")
get_code_for_paper("2024.findings-acl.708")
have("2024.findings-acl.708")

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

curl https://syntology.ai/api/ran/2024.findings-acl.708.json

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

[![Syntology run record](https://syntology.ai/api/ran/2024.findings-acl.708.svg)](https://syntology.ai/paper/2024.findings-acl.708)

Connect an agent — have() is free.