DEV Community

Maziar Sanjabi
Maziar Sanjabi

Posted on

I built an SVG optimizer with an LLM, then compiled the LLM out

I built an SVG optimizer by having an LLM clean up files one at a time, then distilled its recurring moves into deterministic functions plus the analysis and routing that picks the right fix per input. Every step is verified: render before and after, keep the change only if it measurably helps. The result goes beyond SVGO, runs offline, and costs nothing per run.

The surprising part: when I stripped the verification tools from the model, its output got worse, not just more expensive. Much of what a "tool-using AI" benefits from is access to tools to verify its work.

The deeper idea generalizes: wherever you can measure "better" and "not broken," use a model to discover the structure once, then compile it into cheap, verifiable code.

Try it (runs in your browser): https://maziars.github.io/svgym/app/
Code: https://github.com/maziars/svgym
Full write-up: https://same-fridge-b15.notion.site/The-Missing-Arrow-Distilling-Agentic-Hill-Climbing-into-Deterministic-Code-Software-3-0-1-0-37e44c00e05d81cba14cf0dfe1b7a4a7

Top comments (0)