SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2309.03409 · ICLR · 2024

Large Language Models as Optimizers

Denny Zhou, Xuezhi Wang, Xinyun Chen, V Le, Yifeng Lu, Chengrun Yang, Hanxiao Liu Quoc

arXiv · PDF · Open in the Atlas

Code that ran

14 of 14 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; 13 failures of our instrument; 0 no recorded run); 1 of them was also run on the host, not in the jail, by the peer-agreement lane that set its level, 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/2309.03409.json · badge: /api/ran/2309.03409.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
google-deepmind/opro canonical (classifier label)
classifier basis: census
9 ran · 0 no recorded run
yaolu/random-prompt canonical (classifier label)
classifier basis: census
3 ran · 0 no recorded run
thunderous77/glape community
Papers with Code archive
2 ran · 0 no recorded run
FunctionStatusWhere it lives
read_jsonl Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/evaluation/eval_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from lmsdss/ipo, is pointer only (licence: NONE) · get_code("a4cf9d0d1ece601e")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from lmsdss/ipo, 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.

balanced_sample Ran
ran; our contract draft was wrong, not the code
yaolu/random-prompt/utils.py
code served (permissive licence) · get_code("19d3b6894577dc43")
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 random
from collections import defaultdict

torch.manual_seed(0)

class MockDataset:
    """Mock dataset that supports __getitem__ with include_output parameter."""
    def __init__(self):
        self.items = [
            {'output': 0, 'feature': torch.randn(4)},
            {'output': 0, 'feature': torch.randn(4)},
            {'output': 1, 'feature': torch.randn(4)},
            {'output': 1, 'feature': torch.randn(4)},
            {'output': 2, 'feature': torch.randn(4)},
            {'output': 2, 'feature': torch.randn(4)},
        ]
    
    def __len__(self):
        return len(self.items)
    
    def __getitem__(self, idx, include_output=False):
        item = self.items[idx]
        if include_output:
            return item
        return item['feature']

data = MockDataset()

ARGS = {
    'data': data,
    'n_shot': 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 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
call_openai_server_func Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/prompt_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from lmsdss/IPO, is pointer only (licence: NONE) · get_code("310edb478a4009a1")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from lmsdss/IPO, 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.

call_openai_server_single_prompt Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/prompt_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from lmsdss/IPO, is pointer only (licence: NONE) · get_code("daa969a73f4f1e26")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from lmsdss/IPO, 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.

compute_loss Ran
ran; our contract draft was wrong, not the code
thunderous77/glape/utils.py
pointer only (licence: NONE) · get_code("ab2577b54a5de0f2")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, thunderous77/glape 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.

extract_string_in_square_brackets Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/optimization/opt_utils.py
code served (permissive licence) · get_code("9e6b4f1e39187226")
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 extract_string_in_square_brackets(input_string):
    raw_result = re.findall('\\[.*?\\]', input_string)
    if raw_result:
        return raw_result[0][1:-1]
    else:
        return ''

ARGS = {
    'input_string': 'This is a test [content here] with brackets'
}
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
gen_ins_and_score_pairs_substr Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/optimization/opt_utils.py
code served (permissive licence) · get_code("d3c113af9902217e")
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

# Define the arguments for gen_ins_and_score_pairs_substr
ARGS = {
    'old_instructions_and_scores': [
        ('Write a Python function', 0.85, 0),
        ('Create a neural network', 0.72, 1),
        ('Implement a sorting algorithm', 0.65, 2),
        ('Build a data pipeline', 0.58, 3),
        ('Design a REST API', 0.92, 4),
    ],
    'old_instruction_score_threshold': 0.1,
    'max_num_instructions': 1000,
    'return_str_only': False,
    'num_score_buckets': np.inf,
}
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
get_context_limit Ran
ran, honoured the contract we drafted
yaolu/random-prompt/utils.py
code served (permissive licence) · get_code("355c3b041e1b77a5")
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 int, ndim 0, dtype family int, 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
import torch.nn as nn

class MockConfig:
    def __init__(self, **kwargs):
        for key, value in kwargs.items():
            setattr(self, key, value)

class MockModel(nn.Module):
    def __init__(self, config):
        super().__init__()
        self.config = config
    
    def forward(self, x):
        return x

torch.manual_seed(0)

# Test case 1: model with n_ctx
config_with_n_ctx = MockConfig(n_ctx=2048)
model_with_n_ctx = MockModel(config_with_n_ctx)

ARGS = {
    "model": model_with_n_ctx
}
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 int, ndim 0, dtype family int, 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
instruction_to_filename Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/evaluation/eval_utils.py
code served (permissive licence) · get_code("22e0818b777cfffa")
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 hashlib
import string

def remove_punctuation_from_string(input_string, is_filename=True):
    """Remove punctuations from string to comply with filename requirements."""
    if is_filename:
        punctuation_subset_str = string.punctuation.replace('!', '').replace('?', '').replace('.', '')
        output_string = input_string.translate(str.maketrans('', '', punctuation_subset_str))
        output_string = output_string.replace('!', '<EXCLAMATION>').replace('?', '<QUESTION>').replace('.', '<PERIOD>')
    else:
        output_string = input_string.translate(str.maketrans('', '', string.punctuation))
    return output_string

def instruction_to_filename(instruction, md5_hashing=True):
    """Convert an instruction string to filename."""
    if md5_hashing:
        m = hashlib.md5()
        m.update(instruction.encode('ascii'))
        filename = m.hexdigest()
    else:
        filename = instruction.replace('\n', '')
        filename = remove_punctuation_from_string(repr(filename))
        filename = filename if filename else '<NO INSTRUCTION>'
    return filename

ARGS = {
    "instruction": "This is a test instruction with punctuation!",
    "md5_hashing": True
}
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
optimize Ran
ran; the contract check could not run (RAISES, DEP_MISSING or TIMEOUT)
thunderous77/glape/utils.py
pointer only (licence: NONE) · get_code("a3f7ac8674bc5e72")
How it ran

The body of this sample is withheld: GitHub detected no licence in this paper's repository, thunderous77/glape 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.

parse_tag_content Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/optimization/opt_utils.py
code served (permissive licence) · get_code("2bd751a94e813601")
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 re

def parse_tag_content(text, prefix='<TEXT>', suffix='</TEXT>'):
    pattern = f'{prefix}(.*?){suffix}'
    results = re.findall(pattern, text, re.DOTALL)
    return results

# Construct test arguments
text = """
Some content here
<TEXT>First extracted content</TEXT>
More text in between
<TEXT>Second extracted content</TEXT>
Final text
"""

prefix = '<TEXT>'
suffix = '</TEXT>'

ARGS = {
    'text': text,
    'prefix': prefix,
    'suffix': suffix
}
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 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
profile_time Ran
ran; our contract draft was wrong, not the code
yaolu/random-prompt/utils.py
code served (permissive licence) · get_code("77a2c584ec1b5055")
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
import time

def profile_time(func):

    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        elapsed_time = time.time() - start_time
        print(f'Function: {func.__name__}, Elapsed time: {elapsed_time} seconds')
        return result
    return wrapper


# Create a simple test function to be decorated
@profile_time
def sample_function(x, y, multiplier=1):
    """A simple function that does some computation."""
    time.sleep(0.01)  # Simulate some work
    return (x + y) * multiplier


# Define ARGS dict with the function and its arguments
ARGS = {
    'func': sample_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
remove_punctuation_from_string Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/evaluation/eval_utils.py
pointer only (licence: Apache-2.0); the stored copy get_code serves, from lmsdss/ipo, is pointer only (licence: NONE) · get_code("dc0fb1ce4824c2c3")
How it ran

The body of this sample is withheld: this paper's link allows the body inline (Apache-2.0), but get_code serves the stored copy, first harvested from lmsdss/ipo, 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.

remove_punctuation_from_string Ran
ran; our contract draft was wrong, not the code
google-deepmind/opro/opro/evaluation/metrics.py
code served (permissive licence) · get_code("f980d622248dbd94")
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 string

def remove_punctuation_from_string(input_string):
    output_string = input_string.translate(str.maketrans('', '', string.punctuation))
    return output_string

ARGS = {
    "input_string": "Hello, World! This is a test string with punctuation."
}
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

Also present in other papers' code

Of 14 samples lifted from this paper's linked repositories, 14 carry a function identity and 0 do not. Of the 14 distinct functions with an identity, 4 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 4 later) and 10 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
call_openai_server_func 1 other paper
1 later
2410.15397 (2024-10)
IPO: Interpretable Prompt Optimization for Vision-Language Models
call_openai_server_single_prompt 1 other paper
1 later
2410.15397 (2024-10)
IPO: Interpretable Prompt Optimization for Vision-Language Models
read_jsonl 1 other paper
1 later
2410.15397 (2024-10)
IPO: Interpretable Prompt Optimization for Vision-Language Models
remove_punctuation_from_string 1 other paper
1 later
2410.15397 (2024-10)
IPO: Interpretable Prompt Optimization for Vision-Language Models

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

Optimization is ubiquitous. While derivative-based algorithms have been powerful tools for various problems, the absence of gradient imposes challenges on many real-world applications. In this work, we propose Optimization by PROmpting (OPRO), a simple and effective approach to leverage large language models (LLMs) as optimizers, where the optimization task is described in natural language. In each optimization step, the LLM generates new solutions from the prompt that contains previously generated solutions with their values, then the new solutions are evaluated and added to the prompt for the next optimization step. We first showcase OPRO on linear regression and traveling salesman problems, then move on to our main application in prompt optimization, where the goal is to find instructions that maximize the task accuracy. With a variety of LLMs, we demonstrate that the best prompts optimized by OPRO outperform human-designed prompts by up to 8% on GSM8K, and by up to 50% on Big-Bench Hard tasks. Code at https://github.com/google-deepmind/opro.

For agents

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

get_harvested_code_for_paper("2309.03409")
get_code_for_paper("2309.03409")
have("2309.03409")

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

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

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

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

Connect an agent — have() is free.