SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2022.findings-emnlp.174 · EMNLP Findings · 2022

CodeExp: Explanatory Code Document Generation

Jianfeng Gao, Nan Duan, Bo Wang, Chenglong Wang, Junjie Huang, Haotian Cui, Jeevana Priya, Todd Mytkowicz

Open in the Atlas

Code that ran

6 of 8 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 5 have no contract verdict; 1 failure of our instrument; 2 no recorded run), 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/2022.findings-emnlp.174.json · badge: /api/ran/2022.findings-emnlp.174.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
subercui/CodeExp canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
compute_metrics Ran
ran on a synthesized input
subercui/CodeExp/code2text/eval/ml_metrics.py
code served (permissive licence) · get_code("1be88a148135ec13")
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 sklearn.metrics import mean_squared_error

torch.manual_seed(0)

# The function expects a tuple (pred, labels)
# where pred and labels are array-like and compatible with mean_squared_error

pred = np.array([1.0, 2.0, 3.0, 4.0])
labels = np.array([1.1, 2.1, 2.9, 3.95])

p = (pred, labels)

ARGS = {
    'p': p
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, sklearn, 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_metrics Ran
ran on a synthesized input
subercui/CodeExp/code2text/eval/ml_metrics_step2.py
code served (permissive licence) · get_code("b34b4467b9b87ef8")
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 numpy as np

class PredictionOutput:
    """Stand-in class for huggingface trainer predictions object"""
    def __init__(self, predictions, label_ids):
        self.predictions = predictions
        self.label_ids = label_ids

# Create small arrays for testing
np.random.seed(0)
predictions = np.random.randn(2, 4)  # batch_size=2, num_classes=4
label_ids = np.array([0, 2])  # batch_size=2

p = PredictionOutput(predictions=predictions, label_ids=label_ids)

ARGS = {
    'p': p
}
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 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_code_doc Ran
ran on a synthesized input
subercui/CodeExp/code2text/GPT-J/eval-gpt-neo.py
code served (permissive licence) · get_code("5a213cd01bc9bcab")
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 for test files
temp_dir = tempfile.mkdtemp()

# Create a test .jsonl file
jsonl_file = os.path.join(temp_dir, "test_data.jsonl")
with open(jsonl_file, 'w') as f:
    f.write(json.dumps({"docstring": "Function to add numbers", "blocks_codes": ["x + y"], "code": "def add(x, y): return x + y"}) + "\n")
    f.write(json.dumps({"docstring": "Function to multiply numbers", "blocks_codes": ["x * y"], "code": "def mul(x, y): return x * y"}) + "\n")

# Also create a test .json file for testing the json branch
json_file = os.path.join(temp_dir, "test_data.json")
with open(json_file, 'w') as f:
    json.dump([
        {"docstring": "Function to subtract numbers", "code": "def sub(x, y): return x - y"},
        {"docstring": "Function to divide numbers", "code": "def div(x, y): return x / y"}
    ], f)

ARGS = {
    "data_file": jsonl_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
load_code_doc Ran
ran on a synthesized input
subercui/CodeExp/code2text/GPT-J/make_step2_filter_with_ml_annotator.py
code served (permissive licence) · get_code("95723de6523dd602")
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 2, 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 json
import tempfile
import os

# Create a temporary file with sample data in the expected format
temp_file = tempfile.NamedTemporaryFile(mode='w', suffix='.jsonl', delete=False)

sample_data = [
    {
        'code': 'def add(a, b):\n    return a + b',
        'docstring': 'Adds two numbers',
        'complexity': 'O(1)'
    },
    {
        'code': 'def sort_array(arr):\n    return sorted(arr)',
        'docstring': 'Sorts an array in ascending order',
        'complexity': 'O(n log n)'
    }
]

for item in sample_data:
    temp_file.write(json.dumps(item) + '\n')

temp_file.close()

ARGS = {
    'file': temp_file.name,
    'format': 'GithubCodeDocStep1Filtered'
}
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, ndim 2, 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
load_data Ran
ran on a synthesized input
subercui/CodeExp/code2text/eval/ml_metrics.py
code served (permissive licence) · get_code("04df4f2824375189")
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 2, 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 json
import tempfile
import os

# Create a temporary JSON file with valid data structure
temp_dir = tempfile.mkdtemp()
temp_path = os.path.join(temp_dir, "test_data.json")

# Create sample data matching the expected structure
sample_data = [
    {
        "docstring": "Function to add two numbers",
        "code": "def add(a, b):\n    return a + b",
        "step1": "2.5",
        "step2": "1"
    },
    {
        "docstring": "Function to multiply two numbers",
        "code": "def multiply(a, b):\n    return a * b",
        "step1": "1.8",
        "step2": ""
    }
]

# Write the sample data to the temporary file
with open(temp_path, 'w') as f:
    json.dump(sample_data, f)

# Define ARGS with the path and raw parameter
ARGS = {
    "path": temp_path,
    "raw": False
}
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, ndim 2, 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
postprocess_text Ran
ran; our contract draft was wrong, not the code
subercui/CodeExp/code2text/GPT-J/gpt-j.pre.py
pointer only (licence: MIT); the stored copy get_code serves, from jingyng/label-adaptive-self-rationalization, is pointer only (licence: NONE) · get_code("8b51adb8a6c014e5")
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 jingyng/label-adaptive-self-rationalization, 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.

load_model Not yet run
unverified (harvested, no recorded run)
subercui/CodeExp/code2text/GPT-J/eval-gpt-neo.py
code served (permissive licence) · get_code("b57f640e534abe05")
How it ran

no invocation recorded.

load_model Not yet run
unverified (harvested, no recorded run)
subercui/CodeExp/code2text/codeT5/eval-codeT5.py
code served (permissive licence) · get_code("9235f818b8e6af4d")
How it ran

no invocation recorded.

Also present in other papers' code

Of 8 samples lifted from this paper's linked repositories, 8 carry a function identity and 0 do not. Of the 8 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 7 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
postprocess_text 4 other papers
4 later
2404.05970 (2024-04)
Optimization Methods for Personalizing Large Language Models through Retrieval Augmentation
2406.02888 (2024-06)
HYDRA: Model Factorization Framework for Black-Box LLM Personalization
2410.04002 (2024-10)
Take It Easy: Label-Adaptive Self-Rationalization for Fact Verification and Explanation Generation
and 1 more not named here

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

Developing models that can automatically generate detailed code explanation can greatly benefit software maintenance and programming education. However, existing code-totext generation models often produce only high-level summaries of code that do not capture implementation-level choices essential for these scenarios. To fill in this gap, we propose the code explanation generation task. We first conducted a human study to identify the criteria for high-quality explanatory docstring for code. Based on that, we collected and refined a largescale code docstring corpus and formulated automatic evaluation metrics that best match human assessments. Finally, we present a multistage fine-tuning strategy and baseline models for the task. Our experiments show that (1) our refined training dataset lets models achieve better performance in the explanation generation tasks compared to larger unrefined data (15× larger), and (2) fine-tuned models can generate well-structured long docstrings comparable to human-written ones. We envision our training dataset, human-evaluation protocol, recommended metrics, and fine-tuning strategy can boost future code explanation research. The code and annotated data are available at https://github.com/subercui/CodeExp.

For agents

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

get_harvested_code_for_paper("2022.findings-emnlp.174")
get_code_for_paper("2022.findings-emnlp.174")
have("2022.findings-emnlp.174")

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

curl https://syntology.ai/api/ran/2022.findings-emnlp.174.json

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

[![Syntology run record](https://syntology.ai/api/ran/2022.findings-emnlp.174.svg)](https://syntology.ai/paper/2022.findings-emnlp.174)

Connect an agent — have() is free.