SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2212.09611 · NeurIPS · 2023

Optimizing Prompts for Text-to-Image Generation

Furu Wei, Li Dong, Zewen Chi, Yaru Hao

arXiv · PDF · Open in the Atlas

Code that ran

6 of 9 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 5 have no contract verdict; 0 failures of our instrument; 3 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/2212.09611.json · badge: /api/ran/2212.09611.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
microsoft/lmops canonical (classifier label)
classifier basis: classifier_2025
1 ran · 3 no recorded run
adieyal/sd-dynamic-prompts community (classifier label)
classifier basis not recorded on the link
5 ran · 0 no recorded run
FunctionStatusWhere it lives
append_chunks Ran
ran on a synthesized input
adieyal/sd-dynamic-prompts/sd_dynamic_prompts/special_syntax.py
code served (permissive licence) · get_code("db75fe2b0d0c70d2")
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 torch

def append_chunks(s: str, chunks: list[str]) -> str:
    """
    Append (A1111 special syntax) chunks to a string.
    """
    if not chunks:
        return s
    return f"{s}{''.join(chunks)}"

ARGS = {
    "s": "base_string",
    "chunks": ["chunk1", "chunk2", "chunk3"]
}
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 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
compute_headline Ran
ran, honoured the contract we drafted
microsoft/lmops/adaptllm/src/utils/metric.py
code served (permissive licence) · get_code("7a198adf3d9f7923")
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) 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.

from sklearn.metrics import f1_score

# Construct valid data for compute_headline
# The function expects a list of dicts with keys: 'class_id', 'label', 'pred'
# class_id ranges from 0 to 8 (9 classes total)
# label and pred are binary labels (0 or 1) for f1_score

data = [
    {'class_id': 0, 'label': 0, 'pred': 0},
    {'class_id': 0, 'label': 1, 'pred': 1},
    {'class_id': 1, 'label': 0, 'pred': 1},
    {'class_id': 1, 'label': 1, 'pred': 1},
    {'class_id': 2, 'label': 0, 'pred': 0},
    {'class_id': 2, 'label': 1, 'pred': 0},
    {'class_id': 3, 'label': 1, 'pred': 1},
    {'class_id': 3, 'label': 0, 'pred': 0},
    {'class_id': 4, 'label': 1, 'pred': 1},
    {'class_id': 4, 'label': 0, 'pred': 1},
    {'class_id': 5, 'label': 0, 'pred': 0},
    {'class_id': 5, 'label': 1, 'pred': 1},
    {'class_id': 6, 'label': 1, 'pred': 0},
    {'class_id': 6, 'label': 0, 'pred': 0},
    {'class_id': 7, 'label': 1, 'pred': 1},
    {'class_id': 7, 'label': 0, 'pred': 1},
    {'class_id': 8, 'label': 0, 'pred': 0},
    {'class_id': 8, 'label': 1, 'pred': 1},
]

ARGS = {
    'data': data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1
Imports
sklearn — 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
get_seeds Ran
ran on a synthesized input
adieyal/sd-dynamic-prompts/sd_dynamic_prompts/helpers.py
code served (permissive licence) · get_code("420f90dad5a53d9b")
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 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.

class SeedParams:
    def __init__(self):
        self.subseed_strength = 0
        self.seed = 42
        self.subseed = 100
        self.all_seeds = [42]
        self.all_subseeds = [100]

ARGS = {
    "p": SeedParams(),
    "num_seeds": 5,
    "use_fixed_seed": True,
    "is_combinatorial": False,
    "combinatorial_batches": 1
}
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 int — 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
massage_prompt Ran
ran on a synthesized input
adieyal/sd-dynamic-prompts/sd_dynamic_prompts/magic_prompt.py
code served (permissive licence) · get_code("eda2c82cf3ccfff3")
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 massage_prompt(prompt: str) -> str:
    prompt = re.sub('([.,])\\1+', '\\1', prompt)
    prompt = prompt.strip()
    return prompt

ARGS = {
    "prompt": "Hello,, world.. This is a test!!"
}
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
remove_a1111_special_syntax_chunks Ran
ran on a synthesized input
adieyal/sd-dynamic-prompts/sd_dynamic_prompts/special_syntax.py
code served (permissive licence) · get_code("d302597c36e3aa49")
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 re

A1111_SPECIAL_SYNTAX_RE = re.compile('\\s*<[^>]+>')

def remove_a1111_special_syntax_chunks(s: str) -> tuple[str, list[str]]:
    """
    Remove A1111 special syntax chunks from a string and return the string and the chunks.
    """
    chunks: list[str] = []

    def put_chunk(m):
        chunks.append(m.group(0))
        return ''
    return (re.sub(A1111_SPECIAL_SYNTAX_RE, put_chunk, s), chunks)

ARGS = {
    "s": "Hello <tag1> world <tag2 attr='value'> test"
}
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
should_freeze_prompt Ran
ran on a synthesized input
adieyal/sd-dynamic-prompts/sd_dynamic_prompts/helpers.py
code served (permissive licence) · get_code("3142982634487f73")
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 bool, 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

class MockParameter:
    def __init__(self, subseed_strength):
        self.subseed_strength = subseed_strength

ARGS = {
    'p': MockParameter(subseed_strength=0.5)
}
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 bool, 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
get_generate_final_answer_prompt Not yet run
unverified (harvested, no recorded run)
microsoft/lmops/corag/src/prompts.py
code served (permissive licence) · get_code("b22edc9c818f9d69")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

get_generate_intermediate_answer_prompt Not yet run
unverified (harvested, no recorded run)
microsoft/lmops/corag/src/prompts.py
code served (permissive licence) · get_code("bca0d52a7a79a28a")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

get_generate_subquery_prompt Not yet run
unverified (harvested, no recorded run)
microsoft/lmops/corag/src/prompts.py
code served (permissive licence) · get_code("62a26007268b8192")
How it ran

no invocation recorded. this sample carries JSON test cases instead of a setup block; get_reference_implementation serves them with the level they back.

Also present in other papers' code

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

Well-designed prompts can guide text-to-image models to generate amazing images. However, the performant prompts are often model-specific and misaligned with user input. Instead of laborious human engineering, we propose prompt adaptation, a general framework that automatically adapts original user input to model-preferred prompts. Specifically, we first perform supervised fine-tuning with a pretrained language model on a small collection of manually engineered prompts. Then we use reinforcement learning to explore better prompts. We define a reward function that encourages the policy to generate more aesthetically pleasing images while preserving the original user intentions. Experimental results on Stable Diffusion show that our method outperforms manual prompt engineering in terms of both automatic metrics and human preference ratings. Moreover, reinforcement learning further boosts performance, especially on out-of-domain prompts. The pretrained checkpoints are available at https://aka.ms/promptist. The demo can be found at https://aka.ms/promptist-demo.

For agents

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

get_harvested_code_for_paper("2212.09611")
get_code_for_paper("2212.09611")
have("2212.09611")

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

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

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

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

Connect an agent — have() is free.