通过选择性工具接地提升界面代码生成的准确与效率
From Visual Widgets to UI Code: Efficient Tool-Grounded Generation

- 基于可观察文本和颜色证据,直接生成JSX代码,避免固定模板约束
- 在1000个界面组件上,多指标优于直接提示和结构化管道
- 适合需要高保真、灵活生成界面代码的研究者与开发者
现有截图转代码系统在灵活性与可控性间存在权衡。直接多模态生成易幻觉显式细节,而结构化流程虽降低错误,却依赖组件分解、预定义模板与定制中间表示,增加生成调度成本并限制输出范围。本文探究选择性工具接地是否能改善直接控件到代码生成的保真度-效率平衡。提出轻量级工具接地框架WidgetGen,提取可见文本与颜色证据,进行高层布局与可选图表推理,直接生成可执行的JavaScript XML(JSX)。该设计减少对组件级生成的依赖,同时避免固定用户界面模式。在六种多模态模型及1000个保留控件上,WidgetGen在多数视觉重建指标上优于直接提示与结构化Widget2Code流程,且在面积、可读性与风格上均有稳定提升。基于重建生成的图像-代码对,通过监督微调显著提升六个Qwen家族开源模型的各项指标。结果表明WidgetGen是一个强大的轻量级基线,选择性证据接地为减少表示约束提供了有效替代方案。
原文摘要 · Abstract (English)
Existing screenshot-to-code systems face a trade-off between flexibility and controllability. Direct multimodal generation can hallucinate visible details, whereas structured pipelines reduce such errors through component-wise decomposition, predefined templates, and customized intermediate representations. These structures, however, introduce additional generative orchestration and restrict outputs to designs covered by the representation. We investigate whether selective tool grounding can improve the fidelity--efficiency trade-off of direct widget-to-code generation. We introduce \textbf{WidgetGen}, a lightweight tool-grounded framework that extracts observable text and color evidence, performs high-level layout and optional chart reasoning, and directly generates executable JavaScript XML (\emph{JSX}). This design reduces reliance on component-wise generation while avoiding a fixed UI schema. Across six multimodal models and \(1{,}000\) held-out widgets, WidgetGen outperforms direct prompting and the structured Widget2Code pipeline on most visual reconstruction metrics, with consistent gains in area, legibility, and style. Finally, reconstruction-derived image-code pairs improve six Qwen-family open-weight models across every reported metric through supervised fine-tuning. These results establish WidgetGen as a strong lightweight baseline and show that selective evidence grounding offers an effective alternative to extensive representation constraints.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。