---
title: 'CME-CAD: Executable CAD Code Generation'
url: https://www.emergentmind.com/topics/cme-cad
type: topic
---

# CME-CAD: Executable CAD Code Generation

Searching arXiv for the cited CME-CAD paper and closely related CAD code generation work.
Search query: `CME-CAD Heterogeneous Collaborative Multi-Expert Reinforcement Learning for CAD Code Generation arXiv`
CME-CAD is a training paradigm for CAD code generation that targets the production of **accurate, constraint-compatible, and fully editable CAD models** from **2D engineering drawings**. Formally introduced as **“Heterogeneous Collaborative Multi-Expert Reinforcement Learning for CAD Code Generation”**, it frames CAD reconstruction as the generation of **CadQuery-based Python scripts** from **orthographic projections with precise dimension annotations**, rather than as mesh reconstruction or unconstrained image-to-shape synthesis. Its core components are a two-stage training process—**Multi-Expert Fine-Tuning (MEFT)** and **Multi-Expert Reinforcement Learning (MERL)**—and the accompanying **CADExpert** benchmark of **17,299 instances** with orthographic projections, expert-generated Chain-of-Thought (CoT) processes, executable CadQuery code, and rendered 3D models [2512.23333].

## 1. Concept and scope

CME-CAD addresses a specific industrial problem: converting engineering drawings into **executable parametric programs** that preserve editability and design intent. The stated task is to generate a CadQuery script that, when executed, produces a 3D CAD model that matches the target geometry, respects a consistent coordinate system or work plane, and remains fully editable as parametric code. This differs from methods that output meshes or approximate solids, because the output is intended to remain usable inside a CAD workflow rather than merely approximate the final surface geometry [2512.23333].

The paradigm is aligned with the observation that industrial workflows rely on **orthographic projections with dimension annotations** rather than free-form consumer images or pure text prompts. A recurrent misconception is to view CME-CAD as a runtime mixture-of-experts system. The paper instead defines it as a **training paradigm** with a **single trainable base model** and a set of heterogeneous external experts used during supervision and reinforcement learning; inference can be performed with one selected expert prompt, so the multi-expert aspect is primarily a property of training rather than deployment [2512.23333].

A second conceptual distinction is that CME-CAD treats the problem as **CAD code generation**, not simply as geometric reconstruction. This suggests a stronger emphasis on constraint compatibility, work-plane consistency, and executability than in geometry-only pipelines. A plausible implication is that CME-CAD is best understood as a program synthesis framework specialized to CAD.

## 2. Two-stage training paradigm

The framework is organized into **MEFT** and **MERL**. In **MEFT**, a trainable base model—reported as **Qwen3-4B-Instruct**—is supervised on expert-generated CoT traces and final CadQuery programs. The external experts are heterogeneous vision-language models, specifically **Qwen3–VL-Plus**, **GPT-5-Mini**, and **Doubao-Seed-1.6-Vision**, each paired with a distinct **system prompt** intended to induce a different reasoning style. For each training instance, expert data take the form \(S_n = (P_n, I_i, C_i^{(n)}, A_i^{(n)})\), where \(P_n\) is the expert-specific prompt, \(I_i\) the input drawing, \(C_i^{(n)}\) the CoT, and \(A_i^{(n)}\) the target code [2512.23333].

A notable data-collection device is the **reverse-task strategy**. Because the experts struggle to generate correct code directly from 2D drawings, they are given both the orthographic projections and the ground-truth CadQuery code, and are asked to explain how the code could be derived from the drawings. This yields code-aligned CoT trajectories rather than free-form rationales. MEFT then trains the base model to reproduce the concatenation of CoT and answer conditioned on the expert prompt and the drawing. The paper defines this as supervised multi-expert distillation rather than prompt ensembling at inference [2512.23333].

In **MERL**, the same base model is further optimized with CAD-specific rewards. For each input and expert prompt, the policy samples multiple candidate CoT-plus-code responses. Rewards are computed from output format, code executability, geometric overlap, and coordinate-system consistency. The training signal is then refined through three mechanisms: **Expert-Internal Advantage Estimation (EIAE)**, **Multi-Expert Collaborative Learning (MECL)**, and **Hard Negative Sample Buffering (HSB)**. This structure is designed to overcome the limitation, stated in the paper, that on-policy RLVR tends to refine existing reasoning paths rather than discover new ones [2512.23333].

## 3. Reward design and collaborative optimization

CME-CAD’s reward function is CAD-specific and explicitly executable. It begins with a **format reward** \(R_{\text{format}}\), which checks whether the reasoning and code appear in the required structure, and an **executability reward** \(R_{\text{exec}}\), which checks whether the produced CadQuery code parses and runs. Only if those conditions are met do geometry-sensitive terms contribute to the total reward [2512.23333].

The geometric component is based on volumetric IoU:
$$
R_{\text{IoU}}(M_{\text{gen}}, M_{\text{gt}}) = J(M_{\text{gen}}, M_{\text{gt}}) = \frac{|M_{\text{gen}} \cap M_{\text{gt}}|}{|M_{\text{gen}} \cup M_{\text{gt}}|}.
$$
Because IoU is sensitive to coordinate-system mismatch, the framework also defines a **work-plane / coordinate system reward**. The origin deviation is
$$
Dis_{\text{ori}} = \| O_{\text{gen}} - O_{\text{gt}} \|_2,
$$
and the basis-vector deviation is
$$
Dis_{\text{vec}} = \frac{1}{2}\left[2 - \text{sim}(\boldsymbol{x}_{\text{gen}}, \boldsymbol{x}_{\text{gt}}) - \text{sim}(\boldsymbol{y}_{\text{gen}}, \boldsymbol{y}_{\text{gt}})\right].
$$
These are combined as
$$
R_{\text{plane}} = 1 - \beta \cdot Dis_{\text{ori}} - \gamma \cdot Dis_{\text{vec}}, \quad 0 \leq R_{\text{plane}} \leq 1.
$$
The total reward is then
$$
R = \lambda_{\text{format}} R_{\text{format}}
    \cdot \lambda_{\text{exec}} R_{\text{exec}}
    \cdot \left( \lambda_{\text{IoU}} R_{\text{IoU}} + \lambda_{\text{plane}} R_{\text{plane}} \right).
$$
The multiplicative gating means that if format or executability fails, geometric quality does not contribute positively [2512.23333].

The optimization layer around this reward is equally specific. **EIAE** computes each sample’s reward relative to the average reward of samples produced under the same expert prompt, so that each expert style is judged against its own baseline rather than a global one. **MECL** identifies the best-performing and worst-performing experts in a batch and applies a KL term to transfer successful behavior across expert prompts. **HSB** stores difficult cases for which experts repeatedly fail, and periodically revisits them with supervised fine-tuning on the ground-truth answer. This suggests that CME-CAD is not merely reward shaping for CAD code, but a coordinated scheme for stabilizing exploration across heterogeneous reasoning styles [2512.23333].

## 4. CADExpert benchmark and representation

The benchmark accompanying CME-CAD, **CADExpert**, contains **17,299 instances**. Each instance includes **orthographic projections with precise dimension annotations**, **expert-generated CoT processes**, **executable CadQuery code**, and **rendered 3D models**. The generation pipeline begins from **random constrained CadQuery generation**, produces **STEP solids**, converts them to orthographic views with **FreeCAD**, and adds dimensions with **ezdxf**. Code is filtered in two stages: first by execution validity in Python, then by human review by **10 experts** [2512.23333].

The benchmark is designed to support executable CAD reasoning rather than geometry-only retrieval. The paper emphasizes that earlier methods often depend on text or image inputs that require significant manual annotation or target approximate, non-editable outputs. CADExpert instead encodes design intent through executable programs and expert CoT traces, making it suitable for both MEFT and MERL. The output representation is **CadQuery-based Python code**, which the reward pipeline can execute directly and compare against ground truth [2512.23333].

Training and implementation details are also explicit. The base model is trained on **8 × H100 GPUs**. For MEFT, the learning rate is **\(1\times10^{-5}\)** with **batch size 32**. For MERL, the learning rate remains **\(1\times10^{-5}\)** with **batch size 8**, using **\(G = 4\)** rollouts per prompt and **temperature 0.9** during training. The implementation uses **vLLM** for rollout efficiency, and the paper states that training with three experts is only about **20–30% slower** than a single-expert baseline rather than three times slower [2512.23333].

## 5. Empirical performance

CME-CAD is evaluated against pretrained vision-language models and against **CAD-RL**, described as a strong RL baseline. On CADExpert, the main reported metrics are **IoU**, **Mean CD**, **Med CD**, and **Executability**. The best CME-CAD model reaches **IoU 80.71%**, **Mean CD 1.00**, **Med CD 0.11**, and **Exec 98.25%**, compared with **CAD-RL** at **IoU 71.84%**, **Mean CD 1.38**, **Med CD 0.36**, and **Exec 97.32%** [2512.23333].

| Method | IoU | Mean CD | Med CD | Exec |
|---|---:|---:|---:|---:|
| Qwen3-VL | 37.04% | — | — | 54.79% |
| CAD-RL | 71.84% | 1.38 | 0.36 | 97.32% |
| CME-CAD | 80.71% | 1.00 | 0.11 | 98.25% |

Ablations clarify the source of the gain. Under single-expert supervised fine-tuning, IoU ranges from **38.08** to **44.02**. Under **multi-expert SFT**, IoU rises to **57.19**, **61.30**, and **64.45** depending on expert style. Under full CME-CAD, the three expert-conditioned variants reach **75.69**, **75.06**, and **80.71** IoU, with executability between **97.18%** and **98.35%**. This indicates that simply aggregating heterogeneous expert traces already helps, but the full MERL stage yields the largest gains [2512.23333].

The component ablation isolates **EIAE**, **HSB**, and **MECL**. Starting from a baseline of **IoU 64.45**, **Mean CD 1.63**, and **Exec 96.99**, adding **EIAE** raises IoU to **73.89**; adding **HSB** on top yields **78.14**; adding **MECL** instead yields **76.71**; and combining all three produces the final **80.71** IoU with **Mean CD 1.00** and **Exec 98.25**. The paper therefore attributes the final performance not to a single mechanism but to the interaction of internal reward normalization, cross-expert transfer, and supervised replay on hard cases [2512.23333].

## 6. Position within programmatic CAD research

CME-CAD belongs to a broader shift from geometry-only CAD reconstruction toward **programmatic CAD**, where the objective is to recover an executable, editable construction process. In that landscape, **BenchCAD** formalizes industrial CAD reasoning around **17,900 execution-verified CadQuery programs** and shows that current systems often recover coarse outer geometry but fail to produce faithful parametric CAD programs, especially when essential operations such as **sweeps**, **lofts**, and **twist-extrudes** are required [2605.10865]. This external result helps explain why CME-CAD emphasizes executability and coordinate-system consistency as first-class reward terms rather than relying only on geometric overlap.

Relative to other recent systems, CME-CAD is distinguished by its input modality and training strategy. **CADEvolve** synthesizes a large corpus of executable CadQuery scripts and reports state-of-the-art results on **Image2CAD** with multi-view rendered inputs rather than engineering drawings [2602.16317]. **CADmium** fine-tunes code language models for **text-driven sequential CAD design** using a JSON-based CAD sequence representation [2507.09792]. **CMT** focuses on **multimodal conditional CAD generation** in **B-Rep** space rather than executable CadQuery code [2504.20830]. CME-CAD therefore occupies a specific niche: orthographic drawings with dimension annotations as input, CadQuery code as output, and heterogeneous collaborative reinforcement learning as the training mechanism.

The paper also states clear limitations. CADExpert remains centered on single-part code generation; the framework is tied to **CadQuery**; and training is heavier than pure supervised fine-tuning because it requires expert rollouts and reward evaluation. The data are synthesized rather than taken from proprietary industrial workflows. These constraints suggest that, while CME-CAD advances industrial-style CAD code generation, broader coverage of assemblies, richer operation sets, and transfer to other CAD kernels remain open directions.

Source: https://www.emergentmind.com/topics/cme-cad