SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1904.00720 · 2019

CoaCor: Code Annotation for Code Retrieval with Reinforcement Learning

arXiv · PDF · Open in the Atlas

Code that ran

6 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 6 have no contract verdict; 0 failures of our instrument; 5 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/1904.00720.json · badge: /api/ran/1904.00720.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
LittleYUYU/CoaCor canonical (classifier label)
classifier basis: census
6 ran · 5 no recorded run
FunctionStatusWhere it lives
dot_np Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/utils.py
code served (permissive licence) · get_code("cbe2069a075e6e0c")
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, 3) 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 two small normalized numpy arrays for cosine similarity computation
# data1 shape: (2, 4) - 2 vectors of dimension 4
# data2 shape: (3, 4) - 3 vectors of dimension 4
# This allows us to test dot product between different batch sizes

np.random.seed(0)
data1 = np.random.randn(2, 4).astype(np.float32)
data2 = np.random.randn(3, 4).astype(np.float32)

# Normalize the vectors to unit length (for cosine similarity)
data1 = data1 / np.linalg.norm(data1, axis=1, keepdims=True)
data2 = data2 / np.linalg.norm(data2, axis=1, keepdims=True)

ARGS = {
    "data1": data1,
    "data2": data2,
}
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, 3) — shape (2, 3) 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_config Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/configs.py
code served (permissive licence) · get_code("413d087fe8bff822")
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 argparse

class Args:
    def __init__(self):
        self.use_anno = False
        self.qn_mode = 'default'
        self.mode = 'train'
        self.val_setup = 'default'
        self.eval_setup = 'default'

ARGS = {
    '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 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_rank Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/ensemble.py
code served (permissive licence) · get_code("a9f21950fb827c6d")
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 numpy as np

def get_rank(sims):
    negsims = np.negative(sims)
    predict = np.argsort(negsims)
    predict = [int(k) for k in predict]
    return predict

# Create a small similarity matrix
# The function takes a numpy array and negates it, then argsorts it
sims = np.array([0.5, 0.2, 0.9, 0.1, 0.7])

ARGS = {
    "sims": sims
}
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 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
load_dict Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/data.py
code served (permissive licence) · get_code("c409ff1142d08d65")
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 pickle
import tempfile
import os

# Create a temporary directory and file for testing
temp_dir = tempfile.mkdtemp()
test_file = os.path.join(temp_dir, "test.pkl")

# Create a simple dict to pickle
test_dict = {"key1": "value1", "key2": 42, "key3": [1, 2, 3]}

# Write the dict to a pickle file
with open(test_file, 'wb') as f:
    pickle.dump(test_dict, f)

# Define ARGS with the filename parameter
ARGS = {
    "filename": test_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 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 Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/utils.py
code served (permissive licence) · get_code("33e433978ce44e47")
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 small test matrix with distinct dimensions
# Shape: (2, 4) - 2 rows, 4 columns
data = np.array([
    [1.0, 2.0, 3.0, 4.0],
    [5.0, 6.0, 7.0, 8.0]
], dtype=np.float32)

ARGS = {
    "data": data
}
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
processed_dataset Ran
ran on a synthesized input
LittleYUYU/CoaCor/code/code_annotation/code_retrieval/CodeRetrievalCritic.py
code served (permissive licence) · get_code("fd69d94337ac6494")
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 numpy as np

# Construct valid arguments for processed_dataset function
# The function expects:
# - list_of_strings: a list of tuples where each tuple is (idx, string_of_space_separated_ints)
# - PAD_ID: an integer used as padding

# Create sample data: list of (index, space-separated integer string) tuples
list_of_strings = [
    (0, "1 2 3 4"),
    (1, "5 6 7"),
    (2, ""),  # Empty string case
    (3, "8 9")
]

PAD_ID = 0

ARGS = {
    "list_of_strings": list_of_strings,
    "PAD_ID": PAD_ID
}
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 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
cos_np Not yet run
unverified (harvested, no recorded run)
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/utils.py
code served (permissive licence) · get_code("041969a396e87962")
How it ran

no invocation recorded.

get_aligned_embedding Not yet run
unverified (harvested, no recorded run)
LittleYUYU/CoaCor/code/code_annotation/a2c-train.py
code served (permissive licence) · get_code("8c405090ea694b22")
How it ran

no invocation recorded.

limit_vocab Not yet run
unverified (harvested, no recorded run)
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/data.py
code served (permissive licence) · get_code("a07f7713e1872a63")
How it ran

no invocation recorded.

weighting_scores_codenn Not yet run
unverified (harvested, no recorded run)
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/ensemble.py
code served (permissive licence) · get_code("e73e640366ffedf6")
How it ran

no invocation recorded.

weighting_scores_staqc Not yet run
unverified (harvested, no recorded run)
LittleYUYU/CoaCor/code/CodeRetrieval-Main/code/ensemble.py
code served (permissive licence) · get_code("53857a2d4dcb69b2")
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, 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 11 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

To accelerate software development, much research has been performed to help people understand and reuse the huge amount of available code resources. Two important tasks have been widely studied: code retrieval, which aims to retrieve code snippets relevant to a given natural language query from a code base, and code annotation, where the goal is to annotate a code snippet with a natural language description. Despite their advancement in recent years, the two tasks are mostly explored separately. In this work, we investigate a novel perspective of Code annotation for Code retrieval (hence called `CoaCor'), where a code annotation model is trained to generate a natural language annotation that can represent the semantic meaning of a given code snippet and can be leveraged by a code retrieval model to better distinguish relevant code snippets from others. To this end, we propose an effective framework based on reinforcement learning, which explicitly encourages the code annotation model to generate annotations that can be used for the retrieval task. Through extensive experiments, we show that code annotations generated by our framework are much more detailed and more useful for code retrieval, and they can further improve the performance of existing code retrieval models significantly.

For agents

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

get_harvested_code_for_paper("1904.00720")
get_code_for_paper("1904.00720")
have("1904.00720")

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

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

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

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

Connect an agent — have() is free.