· via Hacker News – Front Page (native)
Project trains Qwen model to paint watercolour images as editable JavaScript
Surya Narreddi's project, surfaced on Hacker News, trains a Qwen model to paint watercolour images as editable p5.brush JavaScript, using a pairwise judge to turn subjective taste into an RL reward.

A project by Surya Narreddi, currently on the Hacker News front page, takes aim at a structural limit of AI image generation: once the model produces a picture, the sole adjustment lever is another prompt. Narreddi and his collaborator Cameron instead trained a language model to make images by writing code — p5.brush JavaScript sketches — so the output can be opened, read and edited directly, line by line, without another round trip through the model.
The model is Qwen 3.5 35B, tuned with GRPO, a reinforcement learning method. As the write-up frames it, the sketch itself is the deliverable rather than the pixels, and that is what makes granular edits possible.
The training loop
According to the write-up, training repeats a four-step loop thousands of times. The model receives a prompt such as "draw a peach hibiscus in watercolour" and writes a complete p5.brush JavaScript sketch. A sandboxed Puppeteer environment renders the sketch into a PNG, and a separate judge model compares that PNG pairwise against two reference paintings sampled at random from a hand-rated pool, picking the better watercolour. The verdict is converted into a reward signal, GRPO updates the model, and the loop runs again.
The reference pool holds 581 paintings, all of them model-generated, because p5.brush is a niche library and the authors say they could not source enough human-made examples. The pool was hand-rated from 1,664 generations: 117 images in the top "love" tier, 266 rated okay, and 198 supplements from a separate run added to widen coverage where rated examples were thin. Generation ran through two pipelines — an AutoResearch setup in which Opus 4.6, GPT-5.4 and Gemini 3.1 Pro iterated against reference photographs under a vision-language judge, plus a larger batch run on Gemini 3.1 Pro.
Writing a reward for taste
The deeper question, Narreddi argues, is how to run reinforcement learning on creative work at all. RL depends on rewards that can be verified: arithmetic answers either check out or they do not, and games end in wins or losses. Aesthetic preference is neither, so the design effort shifts onto the reward function itself. An overly narrow rubric teaches the model to imitate the handful of examples that were rated; an overly vague one never pins anything down.
The project's first rubric used nine signals, five of them redundant — among them a length ramp weighted at 32%, an aesthetics term at 15% and a five-judge council — and training plateaued around a reward of 0.65. The revised rubric keeps four signals: a compile gate at 5%, a length term at 5%, the HPSv3 aesthetic scorer at 30%, and the pairwise judgment at 60%, which now dominates the mix.
The prompt lesson
Even the system prompt needed training. Early versions embedded a 400-line p5.brush API reference, and the model responded with polished code that freely invented non-existent APIs. The fix came through GEPA, a prompt-optimisation library that evolves a prompt against a scoring function: 200 iterations against a taste-anchored seven-shot judge converged on a prompt containing nothing but a tight allowlist of eight brush methods — no API documentation and no worked examples. Narreddi reports that the first run in which every one of three generations rendered a recognisable hibiscus came from the version written after the 400-line reference was discarded entirely. The finding generalises, he writes: long reference documentation invites API hallucination, while a short, opinionated allowlist constrains output better than the original specification did.
Why it matters
Two things lift this above a hobby experiment. The first is the workflow implication: when generation produces editable code rather than opaque pixels, users gain a layer between the prompt and the picture where they can intervene precisely — a step toward more interactive generation tools. The second is methodological: the project sketches a repeatable recipe for applying RL to subjective tasks, where the real work is authoring a reward — and curating the comparisons it is judged against — carefully enough that the judges' preferences extend beyond the rated sample.
Narreddi is candid that this is not a better way to make images; it is considerably slower. The project is ongoing, with one final training run planned to address the issues the team discovered, and a full technical report to follow.
- #reinforcement-learning
- #image-generation
- #generative-art
- #javascript
- #qwen