Leaderboard

Contents

    Code-based Image Generation: Benchmarking, Baselines, and Improved Rewards


    Code-based image generation (CIG): an LLM writes a program, a renderer turns it into an image.
    Select an image to read its program.

    Abstract

    Code-based image generation

    An LLM generates code, and a renderer turns it into an image

    Image generation models, such as diffusion and autoregressive models, generate images in pixel or latent spaces. An LLM instead generates code, and a renderer turns the program into an image. We call this paradigm code-based image generation (CIG).

    An image model generates in latent space; an LLM generates a program that a fixed renderer draws

    A program can be read, checked and edited, while an image can only be viewed. The judge of an image model sees only the image; in CIG it can also read the program. Tap a shape or a line.

    CIG has three useful features.

    • Deterministic rendering. A fixed renderer executes the code, so improving image quality reduces to improving the code.
    • Interpretable. Each image comes from a program that can be read.
    • Scales with coding capabilities. A better coding model is a better image generator.

    CIG also allows a new reward signal: the judge can read the program, understand how the image is constructed, and check the prompt against it. But each single input has a drawback.

    The same judge gives different answers when shown the image, the program or both

    Real programs and real judge answers. Faded: what this judge is not shown. Monkeys score 0–10.

    An image-only judge struggles to tell what a crude shape is meant to be. A program-only judge struggles to tell whether an object in the code is visible.

    Can open-source LLMs learn CIG from stronger models? Yes: after SFT and GRPO, our model, Pictor-27B, matches or beats its teacher mix.

    Does having the program enable a better reward? Yes: the judge shown both gains GenEval2 GM over the base model, against for the program alone and for the image alone.

    Images are programs

    Read and edit an image as a program

    A program can be read, changed and rendered again. The renderer is fixed, so a better image needs a better program.

    Each teaser image is a program you can read and run

    The 21 images of the paper teaser, in its order. Programs run in your browser in a sandbox with no network.

    The model reads a text prompt and writes a JavaScript program. The renderer is headless Chrome. It opens a blank 512×512 page with no network and runs the program for at most 60 seconds. Rendering is deterministic, so a better image needs a better program.

    Change a value in the program and the image follows

    Program 11, read-only

    Each control changes one value in the program (underlined), and the renderer draws it again.
    Prompt

    Method

    Two stages: SFT, then GRPO

    Stage 1 is supervised fine-tuning on prompt-program pairs from three teachers: GPT-5.6 Luna, Terra and Sol write 50%, 30% and 20% of the programs. A program is kept if it renders a non-blank image within the token limit. Stage 2 is GRPO: for each prompt the model writes programs, and a judge scores each one.

    One GRPO step: one prompt, a group of programs

    The model writes programs for one prompt, and the judge scores each. The advantage of a program is its score minus the group mean. Scores in the drawing are illustrative.

    Four rewards differ only in what the judge is shown

    Rewardpromptimageprogramjudge calls
    IR✓✓–1
    PR✓–✓1
    IPR✓✓✓1
    avgR✓mean of the IR and PR scores2
    Same judge (GPT-6.1 Sol), same question: how well does the image match the prompt, 0 to 100. avgR uses both inputs in two separate calls, so each call still makes its single-input mistake.

    PR, IPR and the PR call of avgR read a cleaned program, with comments and unused code removed. The image is always rendered from the original program.

    Benchmarking

    Leaderboard

    How well do LLMs draw with code?

    Frontier models like GPT-6 Astra and Gemini 4 Argon have very strong scores, reaching about 70 on DPG-Bench and 40 strict score on GenOlympiad. Open-weight models and small language models like DeepSeek-V4.1-Flash and Claude Haiku 5.5 are worse.

    Select a model to see six of its images.

    Image modelLLM Ours, IPR in green

    Ours: Pictor-27B is Qwen3.8-27B after SFT, then GRPO with the image+program reward (IPR). Pictor-27B-SFT is the model after SFT only. Pictor-27B-IR, -PR and -avgR replace IPR with the image-only, program-only or averaged reward. Pictor-9B starts from Qwen3.5-9B.

      Filter

      Benchmark

        Compare

        How do LLMs compare with image models?

        GPT-Image-2.5 has the strongest scores on GenEval2, PRISM-Bench, DPG-Bench and WISE, but is inferior to LLMs on GenOlympiad, possibly because GenOlympiad needs reasoning, at which LLMs are strong.

        GPT-Image-2.5 has the strongest scores on GenEval2 and PRISM-Bench but is inferior to LLMs on GenOlympiad

        GenOlympiad strict: 100 only if every hard question passes (0–100). GenEval2 GM (0–100). PRISM-Bench aesthetics (0–10), scored by GPT-4.1.

        Larger and newer models score higher. GPT-6 Astra is above GPT-5.6 Sol, and GPT-6 Luna is above GPT-5.6 Luna, on all five benchmarks.

        Baselines

        Can open-source LLMs learn CIG from stronger models?

        Yes. SFT and GRPO take Qwen3.8-27B from to GenEval2 GM, above its teacher mix at .

        Pictor-27B passes its teacher mix on GenEval2 after SFT and GRPO

        GenEval2 GM (0–100). GRPO uses IPR. On PRISM-Bench Pictor-27B scores alignment (teacher mix ) and aesthetics (teacher mix ). On GenOlympiad, DPG-Bench and WISE it is below the teacher mix.

        SFT fixes most failed renders. At 27B, render success goes from % to %. At 9B it goes from % to %. GRPO raises it to % and %.

        Does model size matter?

        Yes. GenEval2 AM of the base models goes from near 0 (0.8B) to (27B); after SFT and GRPO it goes from to .

        A larger LLM is a better CIG model, before and after post-training

        Select a model size to see the scores.

        GenEval2 AM (0–100) for Qwen3.5 0.8B–9B and Qwen3.8-27B.

        Improved rewards

        Does having the program enable a better reward?

        Yes. The image+program reward (IPR) trains a better model. It scores higher than the image-only (IR), program-only (PR) and averaged rewards on 9 of 11 metrics, including out-of-distribution benchmarks, and people prefer its images to those of the IR model.

        IPR is best on 9 of the 11 metrics, in and out of distribution

        Qwen3.8-27B rows of Tab. 2. GRPO reward sees the image (IR), program (PR), both jointly (IPR) or both averaged (avgR). Bold: best of our trained open-source models. Generally, GRPO improves over SFT; IPR is the best among the four rewards. Pictor-27B: Qwen3.8-27B + SFT + GRPO IPR.

        Same eight prompts, six of our models

        Base, SFT and the four GRPO models of Qwen3.8-27B. First program per prompt. Under each image: GenEval2 GM (0–100) or PRISM alignment (0–10) for that image.

        Is the IPR gain reliable?

        Yes. People prefer the images from the IPR model, and the gains of IPR over IR and SFT are significant.

        The IR model gains little after update 50, while IPR keeps rising

        GenEval2 GM (0–100, 800 prompts, failed render = 0) of saved models. Dashed: SFT start. Shorter SFT starts from the same SFT run after 1.1 of its 2 epochs; only its IR and IPR runs are drawn here. The IR model gains little after update 50 in either setup, while IPR keeps rising.

        Each reward trains its own GRPO model from the same SFT model for 250 updates. We call a difference clear when it is statistically significant (95% interval on one side of zero).

        In a blind study, people prefer the images of the IPR model

        300 prompts, same prompt and seed for both models, three votes per pair. A model wins a pair with at least two of three votes. People prefer the IPR image on % of pairs with a winner (Sec. A of the paper).

        IPR is clearly above IR in three training setups

        GenEval2 GM, IPR model minus IR model, with 95% interval. Main: the setup of the leaderboard. Shorter SFT: the same SFT run after 1.1 of its 2 epochs, clipping 1.0. Other prompts: an earlier SFT model trained on other prompts, LoRA rank 128, clipping 1.0.

        With four programs per prompt, IPR is clearly above every other reward

        Main setup, 800 GenEval2 prompts; with four programs, a prompt’s four scores are averaged first. Bold: clear. The IPR model is clearly above the IR model under every judge, including the IR judge by points.

        Why does IPR train the best model?

        IR separates correct from incorrect images less than PR and IPR, and IPR follows the lower of the IR and PR scores.

        Higher agreement with humans does not mean a better reward. The agreement of IR and IPR with humans is similar, but IR trains the weakest models. A potential reason is that agreement only checks which image scores higher, while GRPO also uses how far apart the scores are.

        IR scores 90 or more to half of the incorrect images

        An image is correct if it passes every GenEval2 item for its prompt, and incorrect otherwise. For about half of the incorrect images, the reasoning of IR names no error.

        GenEval2 outputs of the five final models, one per model and prompt: % of incorrect images score 90 or more under IR, % under PR, % under avgR and % under IPR. Scores below 40 (under 4% of either kind) are not shown.

        IR scores correct and incorrect images closer together than PR and IPR

        This suggests the IR judge gives correct images a weaker advantage during GRPO.

        same-prompt pairs of one correct and one incorrect image (405 prompts). Shaded: within 5 points. Dashed outline: IR, for comparison. IR scores them within 5 points for % of pairs against % for PR and % for IPR.
        Inside the candidate groups of the SFT model

        The near-ties and the high scores repeat: IR % of pairs within 5 points, IPR %; incorrect scored 90 or more: % and %. The mean gap between a correct and an incorrect program is similar for every judge ( to points).

        Which judge counts best?

        The judge shown both. It matches human counts on % of counts with both inputs, % with the image and % with the program.

        Hide an elephant from the image only, and the program judge cannot react

        A correct program for “four pink elephants” loses one elephant.

        elephant() calls, lines 236–241

        Real scores, 0–100, one judge call each.
        The same test on 68 programs

        The removed version disables the first elephant() call. The program has no randomness, so deleting that line draws the same image. Mean change in judge points over 68 correct programs:

        Exact counts by what the judge sees

        % of 498 counts equal to the median of three human raters, with 95% intervals.

        IPR follows the lower of the IR and PR scores

        When PR is higher than IR by 20 points or more, the mean scores are for IR, for PR and for IPR. avgR gives . Fit within prompts: IPR = IR + PR + min(IR, PR).

        Mean scores of 5,862 SFT programs, binned by IR − PR. Whiskers: 95% intervals over prompts. IPR puts the largest weight on the lower of IR and PR (Tab. F.4).
        Programs only one judge likes

        SFT programs on 100 GenEval2 prompts, by which judges score them 70 or more. A program only one judge likes usually has an error, and IPR scores it low.

        Programs on which the two single-input judges disagree or agree

        SFT programs: four from each case where IR and PR disagree, and four that both score 80 or more. Scores 0–100; bold is the lower of IR and PR.

        Further analysis

        A judge that reads can be tricked by written instructions

        A fake program end raises the PR score by and the IPR score by . Removing comments and unused code before judging stops it.

        A fake program end raises the score without changing the image

        “”, last lines

        PR
        IPR
        Scores 0–100. The image is the same pixel for pixel in all three versions.

        A judge that reads the program also reads anything written in it. Training uses cleaned programs.

        edits raise the score; cleaning removes them

        Mean change in judge points (0–100) per edit, image unchanged, on uncleaned programs. Faded rows are within rescoring noise.

        The IPR judge uses the fewest reasoning tokens per call

        Per program scored by GPT-6.1 Sol, means over 1,050 programs. The IPR judge uses reasoning tokens per call, against for IR and for PR. We hypothesise it is more certain because it has both inputs: the program says what each shape is, and the image shows whether it is visible. avgR makes two calls.

        IPR’s ranking among correct programs follows the program

        Held-out correlation between program text and each part of the advantage: correct versus incorrect, and among correct programs (889 SFT programs, 97 prompts, automatic-count labels). With the GenEval2 labels instead, the differences in both parts are within noise.

        The IR model does not improve under its own judge

        Mean own-judge score of programs sampled during training, as change from updates 1–50. Dips shared by all runs come from the prompts in that block. The judges differ, so compare directions, not sizes. IPR’s score rises clearly in the shorter-SFT setup, and in the main setup clearly more than IR’s (Tab. F.4).
        Why each is ruled out
        • IR is a less accurate judge.

          IR agrees with the majority of raters % of the time and IPR %. Their models gain and GM over SFT.

        • The IPR model only looks better to its own judge.

          Under the IR judge, the IPR model is clearly above the IR model, by points.

        • IR was held back by tight gradient clipping.

          With clipping at 1.0 instead of 0.02 (shorter-SFT and other-prompts setups), IR is still GM below IPR. The IPR model writes Canvas more often (% against % of programs). In the shorter-SFT setup both mostly write Canvas (% and %) and IR still ends below, so format does not explain the gain.

        Paper and citation

        Paper, code and models

        BibTeX