SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2311.09519 · 2023

Leveraging Code to Improve In-context Learning for Semantic Parsing

arXiv · PDF · 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; 2 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 4 failures of our instrument; 2 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/2311.09519.json · badge: /api/ran/2311.09519.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
allenai/code-semparse canonical (classifier label)
classifier basis: census
6 ran · 2 no recorded run
FunctionStatusWhere it lives
bm25_stscores_v2 Ran
ran, honoured the contract we drafted
allenai/code-semparse/code_semparse/demonstrations_selection/structural.py
code served (permissive licence) · get_code("d9d948bbef311055")
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 (3, 2) 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

class MockBM25:
    def __init__(self):
        # doc_len: array of document lengths for 3 documents
        self.doc_len = [10, 15, 12]
        
        # doc_freqs: list of dicts mapping query terms to their frequencies in each doc
        # 2 documents with frequencies for terms
        self.doc_freqs = [
            {'term1': 5, 'term2': 3},
            {'term1': 2, 'term2': 7},
            {'term1': 4, 'term2': 1}
        ]
        
        # idf: dict mapping terms to their inverse document frequency scores
        self.idf = {'term1': 2.5, 'term2': 1.8}
        
        # BM25 parameters
        self.k1 = 1.5
        self.b = 0.75
        self.avgdl = 12.33  # average document length

bm25_instance = MockBM25()
query_structs = ['term1', 'term2']

ARGS = {
    'query_structs': query_structs,
    'bm25': bm25_instance
}
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 (3, 2) — shape (3, 2) 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
decomposed_coverage_greedy Ran
ran; our contract draft was wrong, not the code
allenai/code-semparse/code_semparse/demonstrations_selection/greedy.py
code served (permissive licence) · get_code("8de1afe1fb897006")
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

# Set up ARGS for decomposed_coverage_greedy
# The function performs a greedy selection algorithm

# Case 1: Using dict-based partial scores (list of dicts)
k = 3
num_candidates = 5

# Create cand_partial_scores as a list of dicts
# Each dict maps coverage dimensions to partial scores
cand_partial_scores = [
    {0: 0.5, 1: 0.3, 2: 0.1},
    {0: 0.4, 1: 0.6, 2: 0.2},
    {0: 0.7, 1: 0.2, 2: 0.5},
    {0: 0.3, 1: 0.4, 2: 0.8},
    {0: 0.6, 1: 0.5, 2: 0.3},
]

add_cand_score = False
cand_score_discount = 1
candidates = None
cand_lens = None
max_len = -1

ARGS = {
    'k': k,
    'cand_partial_scores': cand_partial_scores,
    'add_cand_score': add_cand_score,
    'cand_score_discount': cand_score_discount,
    'candidates': candidates,
    'cand_lens': cand_lens,
    'max_len': max_len,
}
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
exact_match_eval Ran
ran; our contract draft was wrong, not the code
allenai/code-semparse/code_semparse/eval/evaluate.py
code served (permissive licence) · get_code("9267d9f609a78e25")
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

def exact_match_eval(prediction, ex, prompt_method):
    gold_target = ex.get(prompt_method)
    return {'accuracy': int(prediction.lower() == gold_target.lower()), 'exact_match': int(prediction.lower() == gold_target.lower()), 'predicted_target': prediction}

torch.manual_seed(0)

ARGS = {
    'prediction': 'Hello World',
    'ex': {'method_1': 'hello world', 'method_2': 'HELLO WORLD'},
    'prompt_method': 'method_1'
}
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
recall_stscores_v3 Ran
ran, honoured the contract we drafted
allenai/code-semparse/code_semparse/demonstrations_selection/structural.py
code served (permissive licence) · get_code("53b47e4f86974d17")
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 (4, 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

# Analyzing the function:
# - query_structs: used in "for s in query_structs" and "len(query_structs)"
#   so it needs to be an iterable with a length
# - cand_structs: used in "for _cand_structs in cand_structs" and "s in _cand_structs"
#   so it's an iterable of iterables where membership can be tested

# Create simple list structures
query_structs = ['struct_a', 'struct_b', 'struct_c', 'struct_d']
cand_structs = [
    ['struct_a', 'struct_b'],
    ['struct_b', 'struct_c', 'struct_d'],
    ['struct_a'],
    ['struct_a', 'struct_b', 'struct_c']
]

ARGS = {
    'query_structs': query_structs,
    'cand_structs': cand_structs
}
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 (4, 4) — shape (4, 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
set_broadcasted_max Ran
ran; our contract draft was wrong, not the code
allenai/code-semparse/code_semparse/demonstrations_selection/greedy.py
code served (permissive licence) · get_code("18f0feae070154e5")
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 torch
import numpy as np

# Analyze the function:
# - Parameter 'a': list[dict[int, float]] - a list of dictionaries mapping ints to floats
# - Parameter 'b': dict[int, float] - a dictionary mapping ints to floats
# 
# The function iterates through each dict in 'a', and for each key:
# - If key exists in both a_i and b, take the max
# - If key exists only in a_i, keep it
# - If key exists only in b, add it
#
# Construction strategy:
# - Create list 'a' with 2 dicts of different sizes
# - Create dict 'b' with some overlapping and some new keys

a = [
    {0: 1.5, 1: 2.3, 2: 0.8},      # First dict with keys 0, 1, 2
    {1: 3.2, 2: 1.1, 3: 2.5}       # Second dict with keys 1, 2, 3
]

b = {
    0: 2.0,      # Will take max with a[0][0]
    1: 1.5,      # Will take max with values in a[i][1]
    2: 1.5,      # Will take max with values in a[i][2]
    4: 5.0       # New key not in either dict in a
}

ARGS = {
    "a": a,
    "b": b
}
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 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
skip Ran
ran; our contract draft was wrong, not the code
allenai/code-semparse/code_semparse/eval/datamodel_helper.py
code served (permissive licence) · get_code("99e2f8251e3051b3")
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 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 torch
import torch.nn as nn

def skip(func):
    return func

# The skip function takes a single parameter 'func' which should be a callable
# We'll pass a simple function as the argument

def dummy_function():
    """A simple dummy function to pass to skip"""
    return "test"

ARGS = {
    "func": dummy_function
}
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 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
represent_class Not yet run
unverified (harvested, no recorded run)
allenai/code-semparse/code_semparse/eval/datamodel_helper.py
code served (permissive licence) · get_code("c4bb9ebedb9831ab")
How it ran

no invocation recorded.

run_experiment_wrapper Not yet run
unverified (harvested, no recorded run)
allenai/code-semparse/code_semparse/run_multiple_experiments.py
code served (permissive licence) · get_code("0a19fad79726fbdf")
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, 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 8 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-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

In-context learning (ICL) is an appealing approach for semantic parsing due to its few-shot nature and improved generalization. However, learning to parse to rare domain-specific languages (DSLs) from just a few demonstrations is challenging, limiting the performance of even the most capable LLMs. In this work, we improve the effectiveness of ICL for semantic parsing by (1) using general-purpose programming languages such as Python instead of DSLs, and (2) augmenting prompts with a structured domain description that includes, e.g., the available classes and functions. We show that both these changes significantly improve accuracy across three popular datasets. Combined, they lead to dramatic improvements (e.g. 7.9% to 66.5% on SMCalFlow compositional split), nearly closing the performance gap between easier i.i.d.\ and harder compositional splits when used with a strong model, and reducing the need for a large number of demonstrations. We find that the resemblance of the target parse language to general-purpose code is a more important factor than the language's popularity in pre-training corpora. Our findings provide an improved methodology for building semantic parsers in the modern context of ICL with LLMs.

For agents

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

get_harvested_code_for_paper("2311.09519")
get_code_for_paper("2311.09519")
have("2311.09519")

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

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

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

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

Connect an agent — have() is free.