TL;DR
RA-CAD introduces a state-aware ReAct agent that treats post-execution critique as a learnable, outcome-aligned policy action rather than a static prompt. By optimizing the entire Generate-Execute-Critique-Rewrite trajectory using reinforcement learning, it dramatically improves the executability and geometric accuracy of text-to-CAD generation, outperforming both specialized baselines and powerful proprietary LLMs.
What Problem Does This Paper Address?
Generating parametric computer-aided design (CAD) code from natural language descriptions is highly desirable for automating engineering workflows, but it is notoriously difficult. CAD programs are incredibly brittle: a single incorrect parameter or invalid geometric operation can completely break execution, while syntactically valid code might still produce the wrong 3D shape.
Standard one-shot decoders cannot fix their own mistakes. While recent methods try to incorporate execution feedback, they treat it as static, heuristic guidance from an external reviewer. They fail to optimize how the agent actually interprets this feedback and translates it into effective corrective actions throughout the generation process.
Methods
The authors present RA-CAD (ReAct Agent for CAD), which operates in a closed-loop Generate–Execute–Critique–Rewrite cycle. The training framework consists of two main stages:
- CAD Code Bootstrapping (CCB): The base model (Meta-Llama-3-8B-Instruct) undergoes supervised fine-tuning (SFT) on text-to-CAD pairs to learn basic CAD syntax and geometric constraints.
- Feedback-Driven Agent Optimization (FAO): The interaction loop is modeled as a Markov Decision Process (MDP). Instead of optimizing a single code prediction, the authors use Group Relative Policy Optimization (GRPO) to jointly optimize the entire trajectory—including the code proposals, the critique text, and the subsequent rewrites.
Crucially, the critique module is a learnable policy component inside the agent. The entire trajectory is guided by a terminal reward function combining an F1 score (for sketch topology similarity) and Chamfer Distance (for 3D geometric accuracy).
Datasets
The model was evaluated on two primary datasets, both reparameterized using SkexGen's rules to form a unified CAD code sequence based on "Sketch-and-Extrude" operations:
- CADFusion: Contains approximately 20k samples, using a three-stage structured description (Shape Overview, Shape Details, Shape Applications).
- Text2CAD: Contains approximately 60k samples. The authors focused on the intermediate "L2" level descriptions, which balance technical accuracy with natural language readability.
Key Insights and Ideas
- Critique as a Learnable Action: The core "aha" moment is treating the post-execution critique not as a static prompt template or an external black-box oracle, but as a learnable policy action. By forcing the model to generate its own explicit critique and optimizing it via GRPO, the agent learns how to diagnose errors and how to use its own diagnosis to rewrite code.
- Trajectory-Level Optimization: Rather than rewarding individual steps, the framework evaluates the final instantiated 3D geometry at the end of the loop. This aligns the intermediate reasoning and critique steps directly with the ultimate goal: generating valid, accurate 3D shapes.
- Proprietary LLMs Struggle with CAD Semantics: The paper highlights that even state-of-the-art proprietary LLMs (like GPT-4o and DeepSeek-V4-Flash) struggle significantly with parametric CAD generation, frequently outputting syntactically invalid code or geometrically impossible shapes when prompted directly.
Key Results
RA-CAD achieved state-of-the-art performance across both benchmarks, significantly slashing the Invalidity Ratio (IR)—the percentage of generated code sequences that fail to execute or render properly.
- On CADFusion: RA-CAD reduced the Invalidity Ratio to 6.20% (compared to 21.98% for the CADFusion baseline and 54.26% for GPT-4o). It also achieved the lowest average Chamfer Distance (35.44).
- On Text2CAD: The Invalidity Ratio dropped to 9.44% (compared to 71.76% for the Text2CAD baseline).
Qualitative results demonstrate that RA-CAD successfully recovers from initial mistakes (e.g., missing holes or incorrect primitives) over successive loops to match the ground truth geometry perfectly.
Limitations and Future Work
- Text-Only Input: The current agent only accepts natural language descriptions. It cannot yet handle direct visual conditioning from images, sketches, or 3D point clouds, which limits its use in reverse engineering tasks.
- Restricted Domain Space: The code space is limited to the sketch-and-extrude Domain Specific Language (DSL) provided by the datasets, using 6-bit quantized parameters. It does not yet support complex industrial CAD operations or continuous-parameter precision.
- Future Directions: The authors plan to extend RA-CAD to support multimodal inputs, interactive user feedback during design sessions, and finer quantization levels for broader CAD code spaces.
Summary updated