Abstract
Computer-Aided Design (CAD) plays a vital role in engineering and manufacturing, yet current CAD workflows require extensive domain expertise and manual modeling effort. Recent advances in large language models (LLMs) have made it possible to generate code from natural language, opening new opportunities for automating parametric 3D modeling. However, directly translating human design intent into executable CAD code remains highly challenging, due to the need for logical reasoning, syntactic correctness, and numerical precision. In this work, we propose CAD-RL, a multimodal Chain-of-Thought (CoT) guided reinforcement learning post training framework for CAD modeling code generation. Our method combines CoT-based Cold Start with goal-driven reinforcement learning post training using three task-specific rewards: executability reward, geometric accuracy reward, and external evaluation reward. To ensure stable policy learning under sparse and high-variance reward conditions, we introduce three targeted optimization strategies: Trust Region Stretch for improved exploration, Precision Token Loss for enhanced dimensions parameter accuracy, and Overlong Filtering to reduce noisy supervision. To support training and benchmarking, we release ExeCAD, a novel dataset comprising 16,540 real-world CAD examples with paired natural language and structured design language descriptions, executable CADQuery scripts, and rendered 3D models. Experiments demonstrate that CAD-RL achieves significant improvements in reasoning quality, output precision, and code executability over existing VLMs.
Introduction
Computer-Aided Design (CAD) is the backbone of modern engineering, yet it remains a highly manual process requiring deep domain expertise. While Large Language Models (LLMs) have demonstrated proficiency in general code generation, CAD modeling presents a unique "triple threat" of challenges. First, it requires complex logical reasoning to plan a sequence of geometric operations (e.g., extrusions, fillets) in the correct order. Second, it demands strict syntactic correctness to ensure code executes within CAD engines like CadQuery. Finally, it requires extreme numerical precision, where minor parametric errors result in non-functional parts.
Existing Vision-Language Models (VLMs) often struggle with these requirements, frequently producing "hallucinated" geometry or non-executable code. To address this, we introduce CAD-RL, a framework that leverages multimodal Chain-of-Thought (CoT) and Reinforcement Learning (RL) to bridge the gap between human intent and precise 3D execution.
Methodology
CAD-RL utilizes a two-stage training pipeline designed to instill spatial and parametric logic into the model.
Stage 1: CoT-based Cold Start
The model is initially fine-tuned on a high-quality dataset of reasoning traces. Rather than generating code directly, the model learns to articulate its geometric logic step-by-step (e.g., "First, I will create a base rectangle, then extrude it to a height of 10mm"). This "thinking" phase helps the model plan the 3D space before committing to syntax.
Stage 2: Reinforcement Learning Post-Training
Following the cold start, the model undergoes RL post-training where it explores various reasoning paths and is rewarded based on three signals:
- Executability: A binary reward indicating if the generated CadQuery code runs without error.
- Geometric Accuracy: Measured via Intersection-over-Union (IoU) between the generated model and the ground truth.
- External Evaluation: A "soft" reward provided by a frontier model (GPT-4o) to assess alignment with the original design intent.
To stabilize training, we introduce three optimization strategies: Trust Region Stretch (TRS) to encourage diverse exploration, Precision Token Loss to penalize numerical errors more heavily than syntactic ones, and Overlong Filtering to remove noisy, excessively verbose reasoning traces.
The ExeCAD Dataset
To support this research, we introduce ExeCAD, a benchmark containing 16,540 real-world CAD examples. Each entry is semantically aligned, featuring a natural language prompt, a structured technical specification, executable CadQuery scripts, and rendered 3D models. This dataset addresses the lack of high-quality, executable CAD data in the open-source community.
Experimental Results
CAD-RL sets a new state-of-the-art for CAD code generation. As shown in the comparative analysis, CAD-RL significantly outperforms general-purpose frontier models and specialized CAD models across all metrics.
Key Findings
- Superior Executability: CAD-RL achieved a near-perfect 99.63% success rate in generating executable code, compared to 73.16% for GPT-4o.
- High Geometric Fidelity: On the ExeCAD benchmark, the model achieved an IoU of 72.3% for natural language prompts and 78.7% for structured specifications, a substantial lead over the previous best (CAD-Coder).
- The Power of Reasoning: Incorporating Chain-of-Thought reasoning alone boosted geometric fidelity from 49.5% to over 60% before RL was even applied, proving that "thinking" is essential for spatial planning.
Conclusion and Future Work
CAD-RL demonstrates that combining multimodal reasoning with goal-driven reinforcement learning can automate complex engineering tasks with high precision. While the model excels at standard geometric primitives, future work will focus on expanding to organic 3D shapes and incorporating downstream manufacturing constraints (such as CNC or 3D printing limitations) directly into the reward function. Additionally, we aim to explore interactive loops that allow real-time design refinement based on user feedback.
Summary updated