Training AI to Paint with Code
TL;DR Highlight
Cutting 9 reward signals to 4 with pairwise judging made RL training reach the old plateau 3x faster.
Who Should Read
A developer whose LLM-judge scores or RL tuning have plateaued and who wants to fix the reward design.
Core Mechanics
- Painting with code makes the output editable
- Image models can only be steered by re-prompting.
- The authors trained Qwen 3.5 35B with reinforcement learning (RL) to write p5.brush JavaScript.
- The code is the artefact, so it can be edited directly without a prompt.
- Nine signals were saying the same thing
- The first reward had nine signals, including a compile gate, code length, HPSv3, four quality judges and prompt adherence.
- The four quality judges and prompt adherence correlated at 0.85 to 0.95.
- Reward plateaued at 0.65 and every output was a flat clip-art flower with five petals.
- The code length reward saturated by step 30
- Code length made up roughly a third of the total reward.
- It produced zero gradient (no learning signal) after about step thirty.
- HPSv3, the one signal with real variance, was weighted only 0.10.
- Pairwise judging replaced absolute scores
- Scores from 0 to 10 came back compressed near zero.
- The judge saw the rollout plus two reference paintings and picked the better watercolour.
- The reward is the fraction of comparisons won.
- The new rubric has 4 parts, 60% pairwise
- It uses a compile and brush gate 0.05, a length check 0.05, HPSv3 0.30 and a pairwise judge 0.60.
- With the same base model and data, it reached the old plateau 3x faster and kept climbing.
- Code shrank from 13,500 tokens to under 2,000.
- Dropping 400 lines of API docs cut hallucination
- The 400-line p5.brush reference made the model invent nonexistent APIs.
- GEPA, a prompt evolution library, ran 200 iterations and settled on an allowlist of eight brush methods.
- The first 3 out of 3 hibiscus generations came after removing docs and examples entirely.
Community Reactions
- A view that SVG is a better target
- One commenter argued SVG is already image as code, so teaching models to emit SVG beats JavaScript that renders pixels.
- Experience that RL is weak at new styles
- One commenter who trained a model to draw SVG pelicans said most of the behavior came from SFT on the base model.
- They said RL is very inefficient at style or at novelty outside the distribution.
- A quick capability test for LLM art
- One commenter asks models to programmatically assign color and alpha values to an 800x800 PNG and gets generative art.
- A similar attempt with voxels
- One commenter built a similar setup for voxels using Python calling a Rust native module.
- They said it worked better than hoped but is not perfect.
How to Apply
- Switch your LLM judge to pairwise comparison
- Plot the score histogram of your current 0 to 10 LLM judge first.
- If scores cluster, compare each output against two reference samples and ask which is better.
- Use the win rate as the score.
- Check correlation between reward signals
- Log each eval criterion's score separately.
- If two criteria correlate above 0.85, keep only one.
- Lower the weight of saturated signals or turn them into gates.
- Shrink API docs in the system prompt to an allowlist
- If the model hallucinates APIs, remove the long reference and keep an allowlist of around eight functions.
- Run it three times and check for calls to nonexistent functions.
- Build a pool of hand-picked good examples
- Hand-sort 100 to 200 outputs into love, okay and nope.
- Use only the love tier as comparison references.
Try It
# Paste into Claude or ChatGPT as is (simplified version of the paper's method: pairwise judging)
You are a strict judge. Below are reference answers A and B to the same question, and a candidate answer C.
Question: {{question}}
[Reference A]
{{good example 1}}
[Reference B]
{{good example 2}}
[Candidate C]
{{answer to evaluate}}
Instruction: Compare C with A and pick which is better, then compare C with B and pick which is better. Give a one-line reason for each. Finish with JSON only: {"vs_A": "C"|"A", "vs_B": "C"|"B", "win_rate": 0|0.5|1}.
Next step: compare the results with your old 0 to 10 scoring and check whether the score distribution spreads out more.Terminology
Related Papers
Gemini 4 Neon is the new #1 on the Models Engineering Index
Gemini 4 Neon ranks first on the Models Engineering Index with 68.0, combining multiple benchmarks.
LLMs can read and write executables byte by byte from a hex dump
Given only a hex dump and no tools, an LLM analyzed, patched and wrote working executables.
Claude was trained on protein sequences at scale
Next-amino-acid tests on obscure proteins show only the latest Claude models predict them
Remembered as Brief: Stored Preferences SilentlyRemove Decision-Critical Information
A stored 'keep it short' preference silently drops warnings; listing must-know points first restores content.
All AI-generated code should be Open Source
A blog argues AI-generated code should be open source; most HN commenters disagreed.
What thousands of conversations look like inside a language model
Mapping Qwen3-1.7B states showed Chinese sitting apart from English, while German and Croatian overlapped it.
AI, activity, and outcomes in software engineering
AI sped up writing code, but shipping speed did not rise as much, says a talk
LLMs Play Zachtronics' TIS-100
16 LLMs played TIS-100 and set 133 new Pareto frontier points across 18 puzzles