arXiv:2604.18364cs.AIcs.GR2026-04被引 2

用强化学习与智能推理提升大模型生成数学动画代码的准确率和视觉效果。

Training and Agentic Inference Strategies for LLM-based Manim Animation Generation

  • 训练用SFT+GRPO融合代码与视觉奖励,提升模型理解力。
  • 推理采用渲染回路与文档增强策略,使动画成功率达94%。
  • 适合想做代码生成、动画创作或大模型应用的研究者参考。

使用Manim等程序化动画库生成动画对大语言模型(LLM)提出了独特挑战,需具备空间推理、时间序列规划及领域特定API知识,而这些在通用预训练数据中稀缺。本文提出首个统一训练与推理框架:ManimTrainer结合监督微调(SFT)与基于组相对策略优化(GRPO)的强化学习,使用融合代码与视觉评估的统一奖励信号;ManimAgent则引入渲染回路(RITL)及文档增强型RITL(RITL-DOC)推理策略。研究评估了17个开源子30B参数量的LLM,在九种训练与推理组合下表现。结果表明,SFT普遍提升代码质量,而GRPO增强视觉输出并提高模型在自纠错时对外部信号的响应能力。Qwen 3 Coder 30B模型配合GRPO与RITL-DOC实现最高性能:渲染成功率达94%,视觉相似度(VS)为85.7%,较基线GPT-4.1提升3个百分点。分析显示,代码与视觉指标的相关性随SFT和GRPO增强而上升,但推理优化会削弱此相关性,凸显训练与智能推理策略的互补作用。

原文摘要 · Abstract (English)

Generating programmatic animation using libraries such as Manim presents unique challenges for Large Language Models (LLMs), requiring spatial reasoning, temporal sequencing, and familiarity with domain-specific APIs that are underrepresented in general pre-training data. A systematic study of how training and inference strategies interact in this setting is lacking in current research. This study introduces ManimTrainer, a training pipeline that combines Supervised Fine-tuning (SFT) with Reinforcement Learning (RL) based Group Relative Policy Optimisation (GRPO) using a unified reward signal that fuses code and visual assessment signals, and ManimAgent, an inference pipeline featuring Renderer-in-the-loop (RITL) and API documentation-augmented RITL (RITL-DOC) strategies. Using these techniques, this study presents the first unified training and inference study for text-to-code-to-video transformation with Manim. It evaluates 17 open-source sub-30B LLMs across nine combinations of training and inference strategies using ManimBench. Results show that SFT generally improves code quality, while GRPO enhances visual outputs and increases the models' responsiveness to extrinsic signals during self-correction at inference time. The Qwen 3 Coder 30B model with GRPO and RITL-DOC achieved the highest overall performance, with a 94% Render Success Rate (RSR) and 85.7% Visual Similarity (VS) to reference videos, surpassing the baseline GPT-4.1 model by +3 percentage points in VS. Additionally, the analysis shows that the correlation between code and visual metrics strengthens with SFT and GRPO but weakens with inference-time enhancements, highlighting the complementary roles of training and agentic inference strategies in Manim animation generation.

动画生成代码生成强化学习大模型应用

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。