CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward
Yandong Guan, Xilin Wang, Ximing Xing, Jing Zhang, Dong Xu, Qian Yu
TL;DR
This paper tackles text-to-CAD by reframing the task as generating CadQuery Python scripts, enabling executable validation and richer modeling vocabularies. A two-stage training pipeline—supervised fine-tuning followed by reinforcement learning with Group Reward Policy Optimization—uses CAD-specific rewards and chain-of-thought planning to improve geometric fidelity and code correctness. A large-scale dataset of 110K text–CadQuery–3D triplets plus 1.5K CoT samples supports the training and evaluation. Experiments show CAD-Coder delivers significantly better geometric accuracy and executability than prior methods, advancing geometric reasoning in text-to-CAD generation and offering a foundation for CAD editing via natural language.
Abstract
In this work, we introduce CAD-Coder, a novel framework that reformulates text-to-CAD as the generation of CadQuery scripts - a Python-based, parametric CAD language. This representation enables direct geometric validation, a richer modeling vocabulary, and seamless integration with existing LLMs. To further enhance code validity and geometric fidelity, we propose a two-stage learning pipeline: (1) supervised fine-tuning on paired text-CadQuery data, and (2) reinforcement learning with Group Reward Policy Optimization (GRPO), guided by a CAD-specific reward comprising both a geometric reward (Chamfer Distance) and a format reward. We also introduce a chain-of-thought (CoT) planning process to improve model reasoning, and construct a large-scale, high-quality dataset of 110K text-CadQuery-3D model triplets and 1.5K CoT samples via an automated pipeline. Extensive experiments demonstrate that CAD-Coder enables LLMs to generate diverse, valid, and complex CAD models directly from natural language, advancing the state of the art of text-to-CAD generation and geometric reasoning.
