SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2009.07258 · EMNLP Findings · 2020

BERT-QE: Contextualized Query Expansion for Document Re-ranking

Kai Hui, Ben He, Xianpei Han, Le Sun, Zhi Zheng, Andrew Yates

arXiv · PDF · Open in the Atlas

Code that ran

2 of 11 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 0 have no contract verdict; 2 failures of our instrument; 9 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/2009.07258.json · badge: /api/ran/2009.07258.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
zh-zheng/BERT-QE marked official in Papers with Code
Papers with Code archive
2 ran · 9 no recorded run
FunctionStatusWhere it lives
get_activation Ran
ran; our contract draft was wrong, not the code
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("aa38fe3f4ecdfc3b")
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 function. 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 tensorflow as tf
import six

def gelu(input_tensor):
    """Gaussian Error Linear Unit.

  This is a smoother version of the RELU.
  Original paper: https://arxiv.org/abs/1606.08415

  Args:
    input_tensor: float Tensor to perform activation.

  Returns:
    `input_tensor` with the GELU activation applied.
  """
    cdf = 0.5 * (1.0 + tf.erf(input_tensor / tf.sqrt(2.0)))
    return input_tensor * cdf

def get_activation(activation_string):
    """Maps a string to a Python function, e.g., "relu" => `tf.nn.relu`.

  Args:
    activation_string: String name of the activation function.

  Returns:
    A Python function corresponding to the activation function. If
    `activation_string` is None, empty, or "linear", this will return None.
    If `activation_string` is not a string, it will return `activation_string`.

  Raises:
    ValueError: The `activation_string` does not correspond to a known
      activation.
  """
    if not isinstance(activation_string, six.string_types):
        return activation_string
    if not activation_string:
        return None
    act = activation_string.lower()
    if act == 'linear':
        return None
    elif act == 'relu':
        return tf.nn.relu
    elif act == 'gelu':
        return gelu
    elif act == 'tanh':
        return tf.tanh
    else:
        raise ValueError('Unsupported activation: %s' % act)


ARGS = {
    'activation_string': 'relu'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
six, tensorflow — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function 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_shape_list Ran
ran; our contract draft was wrong, not the code
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("3ac12e42a0d45740")
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 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 tensorflow as tf
import numpy as np

# Create a simple TensorFlow tensor with known shape
# Using a 2D tensor with shape (2, 4) - batch size 2, feature dim 4
tensor_2d = tf.constant(np.random.randn(2, 4).astype(np.float32))

# Create a 3D tensor with shape (2, 3, 4) for testing with different ranks
tensor_3d = tf.constant(np.random.randn(2, 3, 4).astype(np.float32))

# Test with expected_rank as single integer
ARGS = {
    "tensor": tensor_2d,
    "expected_rank": 2,
    "name": "test_tensor"
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
numpy, six, tensorflow — 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
BertModel Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("d1820cb4dd9e6cb4")
How it ran

no invocation recorded.

assert_rank Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("102fa92b948d0383")
How it ran

no invocation recorded.

attention_layer Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("19d5694b63733ac3")
How it ran

no invocation recorded.

create_attention_mask_from_input_mask Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("b38d014af8b95484")
How it ran

no invocation recorded.

create_model Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("cb45bcc0e0e03684")
How it ran

no invocation recorded.

embedding_lookup Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("04726082484ff643")
How it ran

no invocation recorded.

embedding_postprocessor Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("7d98d29cc0d2a7f3")
How it ran

no invocation recorded.

reshape_from_matrix Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("965eee140c1b3230")
How it ran

no invocation recorded.

transformer_model Not yet run
unverified (harvested, no recorded run)
zh-zheng/BERT-QE/functions.py
code served (permissive licence) · get_code("5b85e1462c909ec8")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 10 are also present in other papers whose code we hold (10 with at least one paper dated earlier, 7 the same month, 7 later) and 1 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
get_activation
brick of this paper's assembly: helper
32 other papers
21 dated earlier, 1 the same month, 10 later · 1 only as an assembly brick
1804.05392 (2018-04)
Higher-order Coreference Resolution with Coarse-to-fine Inference
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1901.04085 (2019-01)
Passage Re-ranking with BERT
and 29 more not named here
get_shape_list
brick of this paper's assembly: helper
10 other papers
7 dated earlier, 1 the same month, 2 later · 4 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1905.12616 (2019-05)
Defending Against Neural Fake News
and 7 more not named here
assert_rank
brick of this paper's assembly: helper
8 other papers
5 dated earlier, 1 the same month, 2 later · 4 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
and 5 more not named here
reshape_from_matrix
brick of this paper's assembly: helper
8 other papers
6 dated earlier, 1 the same month, 1 later · 2 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1808.09781 (2018-08)
Self-Attentive Sequential Recommendation
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
and 5 more not named here
attention_layer
brick of this paper's assembly: helper
6 other papers
3 dated earlier, 1 the same month, 2 later · 2 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
2004.08097 (2020-04)
Fast and Accurate Deep Bidirectional Language Representations for Unsupervised Learning
and 3 more not named here
transformer_model
brick of this paper's assembly: helper
5 other papers
2 dated earlier, 1 the same month, 2 later · 1 only as an assembly brick
1706.03762 (2017-06)
Attention Is All You Need
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
2009.07602 (2020-09)
UNION: An Unreferenced Metric for Evaluating Open-ended Story Generation
and 2 more not named here
create_attention_mask_from_input_mask
brick of this paper's assembly: helper
3 other papers
1 dated earlier, 1 the same month, 1 later · 1 only as an assembly brick
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
2009.07602 (2020-09)
UNION: An Unreferenced Metric for Evaluating Open-ended Story Generation
2023.acl-long.693 (2023 (year only))
Towards Leaving No Indic Language Behind: Building Monolingual Corpora, Benchmark and Models for Indic Languages
embedding_lookup
brick of this paper's assembly: helper
3 other papers
3 dated earlier
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
1909.11942 (2019-09)
ALBERT: A Lite BERT for Self-supervised Learning of Language Representations
2004.11579 (2020-04)
Probabilistically Masked Language Model Capable of Autoregressive Generation in Arbitrary Word Order
BertModel
brick of this paper's assembly: helper
1 other paper
1 dated earlier
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding
embedding_postprocessor
brick of this paper's assembly: helper
1 other paper
1 dated earlier
1810.04805 (2018-10)
BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding

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

Query expansion aims to mitigate the mismatch between the language used in a query and in a document. However, query expansion methods can suffer from introducing non-relevant information when expanding the query. To bridge this gap, inspired by recent advances in applying contextualized models like BERT to the document retrieval task, this paper proposes a novel query expansion model that leverages the strength of the BERT model to select relevant document chunks for expansion. In evaluation on the standard TREC Robust04 and GOV2 test collections, the proposed BERT-QE model significantly outperforms BERT-Large models.

For agents

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

get_harvested_code_for_paper("2009.07258")
get_code_for_paper("2009.07258")
have("2009.07258")

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

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

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

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

Connect an agent — have() is free.