Can executing generated code measure CAD generation quality?
Can an LLM be trained to write executable CAD scripts, and can running those scripts against a target shape yield reliable rewards for improving geometric accuracy?
CAD-Coder reformulates text-to-CAD generation as writing executable CadQuery scripts — "a Python-based, parametric CAD language" — instead of predicting low-level CAD command sequences. The authors choose CadQuery because it "provides inherent geometric validation, as CadQuery scripts can be directly executed to verify the validity of the resulting CAD model," offers "a richer modeling vocabulary," and is "composed of semantic, function-based constructs, making them more interpretable." Training runs in two stages: supervised fine-tuning (SFT) on a constructed set of 110K paired text–CadQuery–3D model triplets to teach syntax, then reinforcement learning with Group Reward Policy Optimization (GRPO) using "a CAD-specific reward comprising both a geometric reward (Chamfer Distance) and a format reward." The full pipeline — SFT, GRPO, and a chain-of-thought (CoT) planning stage — reduces Mean Chamfer Distance (CD) to 6.54 and Median CD to 0.17, "surpassing all existing LLMs" including the strong baseline Text2CAD, while keeping "a lower code invalidity ratio."
The mechanism hinges on executability. Because CadQuery "can be executed directly without any external software dependencies," the reward needs no separate learned critic or human judge: a script is run through the OpenCascade kernel to produce a 3D model, and that rendered geometry is scored against the target shape by Chamfer Distance. The format reward separately "enforces the reasoning process and syntactic correctness of the generated code." So the two reward terms split the dual requirement the paper names up front — "syntactic correctness (from a programming perspective) and geometric plausibility (from a 3D modeling perspective)" — with the geometric half judged by deterministic render-and-compare rather than by any learned preference model.
This pairs with What drives CAD-Coder's improvement over supervised fine-tuning alone?, which breaks out why the reward stage, not SFT, produces most of the 6.54-CD result reported here. The automated construction of the 110K-triplet dataset also echoes a point made in Why does random tool sampling produce unrealistic synthetic training data?: both rely on a structural verification step — there, graph-based sampling for realistic tool combinations; here, execution and Chamfer-Distance checking — to keep automatically generated training data valid, though the excerpt gives no detail on the CAD pipeline's filtering steps beyond calling it "automated" and describing the result as "geometrically verified."
The excerpt does not specify how CD is computed (point-cloud sampling density, units), how the two reward terms are weighted against each other, or whether any human CAD practitioner evaluated the outputs beyond the automated metrics. The claim that this "unlocks new capabilities for LLMs" in CAD generation therefore rests entirely on Chamfer Distance and code-validity rate, not on any assessment of whether the resulting models would satisfy an engineer's design intent.
Inquiring lines that read this note 13
This note is a source for these research framings, grouped by the broader line of inquiry each explores. Scan the bold lines of inquiry; follow any specific question forward.
Can visual rendering-based rewards effectively improve code and layout quality?- What filtering and verification steps ensure automatically generated CAD training data remain valid?
- Can Chamfer Distance and code validity capture whether designs match an engineer's intent?
- How do format rewards and geometric rewards split the work of training CAD models?
- What is Chamfer Distance and why measure it for CAD models?
- Does format reward contribute independently to CAD-Coder's final performance?
- Why do multiple CadQuery scripts produce geometrically equivalent CAD models?
- Can an independent VLM judge prevent design quality from regressing during refinement?
- Why is verifying rendered output easier than generating code from scratch?
Related concepts in this collection 4
This note in its neighbourhood — explore the map, then jump to a related concept in the list below.
Click a node to walk · click center to open · click Open in graph to see this note in the full knowledge graph
-
What drives CAD-Coder's improvement over supervised fine-tuning alone?
CAD-Coder combines multiple training components. This explores which parts—geometric reward optimization, chain-of-thought planning, or supervised learning—contribute most to improving 3D model accuracy.
the sibling note's ablation explains which training stage actually produces this result
-
Why does random tool sampling produce unrealistic synthetic training data?
Tool-calling datasets generated through random sampling and single-turn framing lack the complexity and coherence of real deployment. This explores what structural choices in data synthesis determine whether models can learn realistic tool composition.
both pipelines use a structural verification step to keep automatically generated training data valid
-
Can task-specific rewards outperform general pretraining for CAD code?
Does reinforcement learning with hand-designed rewards—executability, geometric accuracy, and external evaluation—help language models generate more precise CAD modeling code than general pretraining alone? This matters because CAD demands both symbolic reasoning and numeric precision beyond typical VLM capabilities.
extends CAD-Coder's single geometric reward with three task-specific rewards, surpassing it on executability and geometric accuracy
-
Can CAD code be syntactically correct yet geometrically wrong?
This explores whether training for executable code and training for accurate geometry require different approaches, and what each training stage contributes to closing that gap.
evidence for A: ablation shows SFT alone is executable but geometrically imprecise, confirming the RL/geometric reward drives accuracy gains
Related papers in this collection 8
Papers most semantically related to this note, ranked by cosine similarity in the embedding space.
- CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward
- From Intent to Execution: Multimodal Chain-of-Thought Reinforcement Learning for Precise CAD Code Generation
- AutoPresent: Designing Structured Visuals from Scratch
- SlideCoder: Layout-aware RAG-enhanced Hierarchical Slide Generation from Design
- Generative Floor Plan Design with LLMs via Reinforcement Learning with Verifiable Rewards
- RE-Bench: Evaluating frontier AI R&D capabilities of language model agents against human experts
- IFEvalCode: Controlled Code Generation
- Breaking the SFT Plateau: Multimodal Structured Reinforcement Learning for Chart-to-Code Generation
Original note title
CAD-Coder rewards text-to-CAD generation by executing the generated code and measuring Chamfer Distance to the target 3D shape