让大模型生成可运行的可视化代码,支持错误自修正。
VisCoder: Fine-Tuning LLMs for Executable Python Visualization Code Generation
- 构建20万条带执行反馈的可视化代码数据集,支持迭代修正。
- 在测试中表现接近GPT-4o-mini,优于多数开源模型。
- 适合需要高可靠可视化代码生成的研究者与开发者。
大型语言模型在绘图等可视化任务中常因代码正确性与视觉语义不一致而失败。现有指令微调数据集缺乏执行验证与迭代纠错支持,导致生成结果不可靠。本文提出VisCode-200K,一个大规模基于Python的可视化与自修正指令微调数据集,包含超过20万条样本:一是来自开源仓库的经验证绘图代码,配以自然语言指令和渲染图表;二是来自Code-Feedback的4.5万组多轮纠错对话,支持模型根据运行时反馈修改错误代码。基于此数据集,我们对Qwen2.5-Coder-Instruct进行微调,得到VisCoder,并在PandasPlotBench上评估。结果显示,VisCoder显著优于多个开源基线,接近专有模型GPT-4o-mini的性能。进一步采用自调试评估协议,验证了反馈驱动学习在生成可执行、视觉准确代码中的有效性。
原文摘要 · Abstract (English)
Large language models (LLMs) often struggle with visualization tasks like plotting diagrams, charts, where success depends on both code correctness and visual semantics. Existing instruction-tuning datasets lack execution-grounded supervision and offer limited support for iterative code correction, resulting in fragile and unreliable plot generation. We present VisCode-200K, a large-scale instruction tuning dataset for Python-based visualization and self-correction. It contains over 200K examples from two sources: (1) validated plotting code from open-source repositories, paired with natural language instructions and rendered plots; and (2) 45K multi-turn correction dialogues from Code-Feedback, enabling models to revise faulty code using runtime feedback. We fine-tune Qwen2.5-Coder-Instruct on VisCode-200K to create VisCoder, and evaluate it on PandasPlotBench. VisCoder significantly outperforms strong open-source baselines and approaches the performance of proprietary models like GPT-4o-mini. We further adopt a self-debug evaluation protocol to assess iterative repair, demonstrating the benefits of feedback-driven learning for executable, visually accurate code generation.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。