AI
New Fine-Tuning Strategy Boosts AI's Ability to Convert Design Mockups into HTML Code
Researchers introduce Waffle, a method that helps language models better understand HTML structure and connect visual designs to working code.
A team of researchers has developed Waffle, a fine-tuning approach designed to improve how large language models convert visual UI designs into functional HTML code. The technique addresses a fundamental gap in web development automation: bridging the visual world of design mockups with the hierarchical, text-based complexity of HTML markup.
The Challenge in Automating Web Development#
Converting a designer's mockup into working HTML remains surprisingly difficult, even as large language models have grown more capable at code generation. The core problem involves two mismatches: LLMs struggle to reason about HTML's nested hierarchical structure, and they must somehow map visual information from an image directly into text-based code without losing semantic meaning.
How Waffle Works#
The method combines two key innovations:
- Structure-aware attention: A specialized attention mechanism that helps the model focus on and understand HTML's nested hierarchy more effectively, treating code structure as a first-class concern rather than an afterthought.
- Contrastive fine-tuning: A training approach that explicitly aligns the model's understanding of UI images with their corresponding HTML representations, teaching it to recognize that the same design can be expressed multiple ways in code.
Measured Performance Gains#
When tested on two benchmarks—the new WebSight-Test dataset and the existing Design2Code benchmark—models fine-tuned with Waffle demonstrated substantial improvements:
- Up to 9 percentage points higher HTML code match rates
- 0.0982 improvement in CW-SSIM (structural similarity metric)
- 32.99 point gain in CLIP-based visual alignment
- 27.12 percentage point improvement in LLEM (layout-level evaluation metric)
These gains suggest that the approach genuinely improves the model's ability to produce valid, visually accurate HTML rather than simply memorizing training examples.
Why It Matters#
As web development continues to shift toward AI-assisted workflows, improving the quality of automatically generated code reduces manual cleanup work and accelerates front-end development pipelines. Better structure-aware reasoning could also inform how language models tackle other code generation tasks involving rigid syntactic hierarchies.

