用强化学习生成结构可靠的图文矢量图,解决对齐错位、文字重叠等问题。
GeoSVG-RL: Geometry-Aware Reinforcement Learning for Layout-Constrained Text-to-SVG Diagram Generation

- 通过几何反馈优化策略,生成可执行的布局计划。
- 在箭头锚点准确率和文字框内率上显著优于现有方法。
- 适合需要高精度技术插图的自动化生成场景。
尽管大语言模型在通用矢量代码生成方面表现优异,但生成结构化且可编辑的图表仍面临重大挑战。主要难点在于输出结构脆弱:轻微错误如连接线端点错位、文本标签与边框重叠或复杂布局超出画布边界,都会使SVG文件在专业应用中无法使用。为此,我们提出GeoSVG-RL,一种专用于布局约束下文本到SVG生成的强化学习框架。不同于仅依赖词元级似然的标准训练目标,本方法基于可执行的几何反馈优化策略。模型首先生成一个结构化布局计划,作为后续SVG代码生成的几何契约。该代码通过浏览器后端验证器渲染,从而在六个关键维度计算细粒度奖励:渲染有效性、画布适配性、精确锚点定位、文本包含性、图一致性及代码整洁性。我们采用组相对策略优化(GRPO),每提示采样多个候选,基于相对质量进行更新。从合成数据上的监督预热开始,GeoSVG-RL在结构可靠性方面取得显著提升,尤其在箭头锚点准确率和文字在框内率上表现突出。定量评估表明,该方法在局部几何精度和图连通性保持方面持续优于当前最先进系统,为自动化且可靠的工程技术图生成提供了稳健路径。
原文摘要 · Abstract (English)
Generating structured, editable diagrams remains a significant challenge for contemporary large language models, despite their proficiency in general-purpose vector code generation. The primary difficulty lies in the structural fragility of the output; minor errors such as misaligned connector endpoints, text labels overlapping borders, or complex layouts drifting beyond the canvas boundaries render the resulting SVG files functionally unusable for professional applications. To address these issues, we introduce GeoSVG-RL, a specialized reinforcement learning framework designed for layout-constrained text-to-SVG generation. Unlike standard training objectives that rely solely on maximizing token-level likelihood, our approach optimizes the policy against explicit, executable geometric feedback. The model first produces a structured layout plan that serves as a geometric contract for the subsequent generation of the SVG code. This code is then rendered through a browser-backed verifier, enabling the calculation of fine-grained rewards across six critical dimensions: rendering validity, canvas fitting, precise anchor placement, text containment, graph consistency, and code cleanliness. We utilize Group Relative Policy Optimization (GRPO) to refine the model, sampling multiple candidates per prompt to facilitate updates based on relative quality. Starting from a supervised warm-start phase on synthetic data, GeoSVG-RL achieves substantial gains in structural reliability, particularly in arrow-anchor accuracy and text-in-box rates. Quantitative evaluations demonstrate that our method consistently outperforms current state-of-the-art systems in local geometric precision and the preservation of graph connectivity, providing a robust pathway toward automated yet reliable technical illustration.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。