SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2209.14610 · ICLR · 2023

Dynamic Prompt Learning via Policy Gradient for Semi-structured Mathematical Reasoning

Kai-Wei Chang, Song-Chun Zhu, Peter Clark, Ying Wu, Pan Lu, Liang Qiu, Ashwin Kalyan, Tanmay Rajpurohit

arXiv · PDF · Open in the Atlas

Code that ran

3 of 7 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; 1 honoured the contract we drafted, 0 violated it and 0 have no contract verdict; 2 failures of our instrument; 4 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/2209.14610.json · badge: /api/ran/2209.14610.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
lupantech/promptpg community
Papers with Code archive
3 ran · 4 no recorded run
FunctionStatusWhere it lives
extract_prediction Ran
ran; our contract draft was wrong, not the code
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("03b16328d15c5de2")
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 str. 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
import random
import re

# Set seed for reproducibility
random.seed(0)
np.random.seed(0)

# Test case 1: With options (multiple choice scenario)
output1 = "The answer is (A)"
options1 = ["apple", "banana", "cherry", "date"]
option_inds1 = ["A", "B", "C", "D"]

# Test case 2: Without options (free response scenario)
output2 = "The answer is 42"
options2 = []
option_inds2 = []

# Test case 3: With options and complex output
output3 = "According to the table, the answer is (B) which is the correct choice"
options3 = ["incorrect", "correct", "wrong", "right"]
option_inds3 = ["A", "B", "C", "D"]

# Test case 4: Without options, extracting numerical answer
output4 = "The value should be = 3.14"
options4 = []
option_inds4 = []

# Use the simplest test case
ARGS = {
    "output": "The answer is (A)",
    "options": ["apple", "banana", "cherry"],
    "option_inds": ["A", "B", "C"]
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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_answer Ran
ran; our contract draft was wrong, not the code
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("580caf49d1cd4e8e")
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 str. 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 re

def normalize_answer(text, unit):
    text = re.sub('^[\\$]', '', text)
    text = re.sub('[\\,\\.\\,\\/]$', '', text)
    result = re.match('^[-+]?[\\d,./]+$', text)
    if result is not None:
        text = text.replace(',', '')
        result = re.match('[-+]?\\d+$', text)
        try:
            if result is not None:
                number = int(text)
            elif '/' in text:
                nums = text.split('/')
                number = round(float(nums[0]) / float(nums[1]), 3)
            else:
                number = round(float(text), 3)
            number = str(number)
            number = re.sub('\\.[0]+$', '', number)
            return number
        except:
            return text
    else:
        if unit:
            text = text.replace(unit, '').strip()
        return text


ARGS = {
    "text": "$123.45,",
    "unit": "kg"
}
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 str — a str output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a str 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
score_string_similarity Ran
ran, honoured the contract we drafted
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("cc627ffb4d816873")
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 float, ndim 0, dtype family float, shape () 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 torch

# Define test arguments for score_string_similarity
ARGS = {
    "str1": "hello world",
    "str2": "hello there"
}
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 float, ndim 0, dtype family float, shape () — shape () 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
call_gpt3 Not yet run
unverified (harvested, no recorded run)
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("afad6bcff6e4c6ce")
How it ran

no invocation recorded.

get_batch_reward_loss Not yet run
unverified (harvested, no recorded run)
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("63b8daf675dc9a6a")
How it ran

no invocation recorded.

get_gpt3_output Not yet run
unverified (harvested, no recorded run)
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("92646ee5d73f558a")
How it ran

no invocation recorded.

policy_gradient_train Not yet run
unverified (harvested, no recorded run)
lupantech/promptpg/run_gpt3_rl/learn_policy.py
code served (permissive licence) · get_code("38fcc5eb9e91cdb9")
How it ran

no invocation recorded.

Also present in other papers' code

Of 7 samples lifted from this paper's linked repositories, 7 carry a function identity and 0 do not. Of the 7 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 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.

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

Mathematical reasoning, a core ability of human intelligence, presents unique challenges for machines in abstract thinking and logical reasoning. Recent large pre-trained language models such as GPT-3 have achieved remarkable progress on mathematical reasoning tasks written in text form, such as math word problems (MWP). However, it is unknown if the models can handle more complex problems that involve math reasoning over heterogeneous information, such as tabular data. To fill the gap, we present Tabular Math Word Problems (TABMWP), a new dataset containing 38,431 open-domain grade-level problems that require mathematical reasoning on both textual and tabular data. Each question in TABMWP is aligned with a tabular context, which is presented as an image, semi-structured text, and a structured table. There are two types of questions: free-text and multichoice, and each problem is annotated with gold solutions to reveal the multi-step reasoning process. We evaluate different pre-trained models on TABMWP, including the GPT-3 model in a few-shot setting. As earlier studies suggest, since few-shot GPT-3 relies on the selection of in-context examples, its performance is unstable and can degrade to near chance. The unstable issue is more severe when handling complex problems like TABMWP. To mitigate this, we further propose a novel approach, PROMPTPG, which utilizes policy gradient to learn to select in-context examples from a small amount of training data and then constructs the corresponding prompt for the test example. Experimental results show that our method outperforms the best baseline by 5.31% on the accuracy metric and reduces the prediction variance significantly compared to random selection, which verifies its effectiveness in selecting in-context examples. 1

For agents

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

get_harvested_code_for_paper("2209.14610")
get_code_for_paper("2209.14610")
have("2209.14610")

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

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

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

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

Connect an agent — have() is free.