RA-CAD: Learning Post-Execution Critique for State-Aware Text-to-CAD Generation
Summary
RA-CAD presents a state-aware agent for text-to-CAD generation that uses a Generate–Execute–Critique–Rewrite loop, with feedback-driven agent optimization via Group Relative Policy Optimization. It achieves state-of-the-art execution validity and geometric quality on CADFusion and Text2CAD benchmarks.
View Cached Full Text
Cached at: 08/07/26, 07:47 AM
# Learning Post-Execution Critique for State-Aware Text-to-CAD Generation
Source: [https://arxiv.org/html/2608.05714](https://arxiv.org/html/2608.05714)
###### Abstract
Text\-to\-CAD generation translates natural\-language design intent into editable and executable parametric computer\-aided design \(CAD\) codes, reducing the expertise and effort required for manual modeling\. Existing methods incorporate fixed, externally supplied, prompt\-induced, or separately optimized critique mechanisms to optimize the generation process, but they do not necessarily optimize how feedback is interpreted and translated into effective corrective actions throughout the generation process\. To bridge this feedback\-utilization gap, we present RA\-CAD \(ReAct Agent for CAD\), a state\-aware agent that interacts with the CAD environment through a Generate–Execute–Critique–Rewrite loop\. At each iteration, RA\-CAD executes the current code and observes its outcome\. Conditioned on the design instruction, current code, and execution feedback, the agent then generates an explicit post\-execution critique as an intermediate policy action\. This critique either validates the current result for termination or provides revision\-oriented guidance that conditions the next rewrite\. CAD Code Bootstrapping \(CCB\) first establishes fundamental parametric CAD coding capabilities through supervised fine\-tuning\. Feedback\-Driven Agent Optimization \(FAO\) subsequently applies trajectory\-level Group Relative Policy Optimization to both policy\-generated code and critique sequences, assigning terminal F1 and Chamfer Distance rewards to the complete interaction trajectory\. This formulation makes critique an outcome\-aligned, learnable policy decision rather than an unoptimized auxiliary output\. Experiments on CADFusion and Text2CAD show that RA\-CAD achieves state\-of\-the\-art execution validity and geometric quality compared with existing methods and strong proprietary language models, demonstrating the effectiveness of the proposed state\-aware text\-to\-CAD agent\.
## Introduction
Computer\-aided design \(CAD\) represents engineered objects through precise, editable geometric operations and is central to product design and manufacturing\(Wuet al\.[2021](https://arxiv.org/html/2608.05714#bib.bib1); Xuet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib2)\)\. Creating these models manually, however, requires substantial domain expertise and effort\(Denget al\.[2023](https://arxiv.org/html/2608.05714#bib.bib40)\)\. In recent years, various automatic CAD generation technologies have been proposed to translate user specifications or design intent into executable, editable CAD representations as shown in[Figure˜1](https://arxiv.org/html/2608.05714#Sx1.F1)\.\(a\)\.
Figure 1:Comparison of CAD generation methods between existing methods and our method\. Existing methods treat feedback as heuristic guidance from external visual reviewers\. Our work models it as an explicit decision\-making process with an agent\-side component\.Early neural approaches learned unconditional distributions over CAD construction sequences\(Wuet al\.[2021](https://arxiv.org/html/2608.05714#bib.bib1); Xuet al\.[2023](https://arxiv.org/html/2608.05714#bib.bib27)\)\. Conditional methods subsequently emerged to guide generation with natural\-language descriptions, typically formulating the task as one\-shot supervised prediction\(Khanet al\.[2024b](https://arxiv.org/html/2608.05714#bib.bib6); Heet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib9); Xie and Ju[2025](https://arxiv.org/html/2608.05714#bib.bib8); Yuanet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib11)\)\. Preference learning and geometric\-reward optimization further improve final\-output fidelity\(Wanget al\.[2025](https://arxiv.org/html/2608.05714#bib.bib35); Guanet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib10); Liet al\.[2026a](https://arxiv.org/html/2608.05714#bib.bib36)\)\. Nevertheless, a complete CAD program is brittle: a single invalid parameter or inconsistent operation may prevent execution, while syntactically valid code may still instantiate the wrong geometry\. A one\-shot decoder cannot use these outcomes to repair its prediction\.
Figure 2:Overview of our training framework, including two stages: CAD Code Bootstrapping \(CCB\) and Feedback\-driven Agent Optimization \(FAO\)\. In the CCB stage, the agent is initialized by supervised fine\-tuning using paired text\-CAD data to learn the syntax and geometric constraints of parametric CAD codes\. In the FAO stage, the GRPO algorithm is adopted to fine\-tune the complete execution trajectory of the agent, enabling the generation and critique policy to co\-evolve under feedback\-driven execution\.Recent systems address this limitation through execution feedback, external visual reviewers, tool interaction, or iterative refinement\(Liet al\.[2026b](https://arxiv.org/html/2608.05714#bib.bib37); Gonget al\.[2026](https://arxiv.org/html/2608.05714#bib.bib19); Huet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib17); Fanet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib18)\)\. The availability of feedback, however, does not by itself specify how feedback utilization is represented or learned: it may serve only as a training reward, be produced by a fixed reviewer or compiler, or remain embedded in a broader reasoning trace\. Regardless of the form, they treat it as heuristic guidance as shown in[Figure˜1](https://arxiv.org/html/2608.05714#Sx1.F1)\.\(b\), and its practical value hinges on a single critical post\-execution decision: judging whether the instantiated code satisfies the instruction, identifying actionable defects, and deciding whether and how to revise it\. In CAD, an inaccurate decision can cause premature acceptance, unnecessary edits, or accumulated syntactic and geometric errors\. Reliable generation therefore requires executable code synthesis and a post\-execution critique decision that is optimized together with rewriting\.
RA\-CAD addresses this problem with a ReAct Agent\(Yaoet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib46)\)that operates as a state\-aware Generate–Execute–Critique–Rewrite loop\. As shown in[Figure˜2](https://arxiv.org/html/2608.05714#Sx1.F2), RA\-CAD organizes CAD generation as a critique\-guided revision process under environment interaction\. Rather than treating critique as a fixed post\-hoc prompt or an auxiliary textual analysis step, we model it as an agent\-side decision component that produces diagnostic signals for subsequent rewriting and termination\. Specifically, CAD Code Bootstrapping \(CCB\) initializes code generation with supervised fine\-tuning \(SFT\), whereas Feedback\-Driven Agent Optimization \(FAO\) uses terminal code and geometry rewards to optimize all policy\-generated code and critique tokens through Group Relative Policy Optimization \(GRPO\)\. RA\-CAD then explicitly factorizes post\-execution critique as a learnable policy component and jointly optimizes critique and code proposal/rewrite over complete environment\-interaction trajectories as shown in[Figure˜1](https://arxiv.org/html/2608.05714#Sx1.F1)\.\(c\), rather than an external reviewer as shown in[Figure˜1](https://arxiv.org/html/2608.05714#Sx1.F1)\.\(b\)\. In this way, RA\-CAD learns not only to propose CAD code, but also to critique intermediate results and use those critique outputs to guide later revisions\. By optimizing the full interaction trajectory, the framework improves the executability, geometric accuracy, and robustness of complex CAD code generation\.
The main contributions are summarized as follows:
- •We formulate state\-aware text\-to\-CAD generation as a round\-level closed loop with an explicitly factorized, learnable post\-execution critique policy\. The critique is explicitly modeled as an agent\-side decision component rather than treated as a fixed prompt template or a purely post\-hoc analysis step\.
- •We propose trajectory\-level FAO with CCB, which assigns terminal CAD\-quality rewards to complete interaction trajectories and jointly optimizes code generation, post\-execution critique, and rewriting\.
- •Experimental results on CADFusion and Text2CAD demonstrate that closed\-loop, critique\-guided revision substantially improves execution validity and geometric quality over existing text\-to\-CAD methods and strong proprietary language models\.
## Related Work
### CAD Generation
Sequence models such as DeepCAD\(Wuet al\.[2021](https://arxiv.org/html/2608.05714#bib.bib1)\), SkexGen\(Xuet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib2)\), HNC\-CAD\(Xuet al\.[2023](https://arxiv.org/html/2608.05714#bib.bib27)\), SketchGen\(Paraet al\.[2021](https://arxiv.org/html/2608.05714#bib.bib28)\), and CAD\-as\-Language\(Ganinet al\.[2021](https://arxiv.org/html/2608.05714#bib.bib5)\)learn structured sketch or sketch\-extrude representations, whereas BRepGen\(Xuet al\.[2024](https://arxiv.org/html/2608.05714#bib.bib3)\)and SolidGen\(Jayaramanet al\.[2023](https://arxiv.org/html/2608.05714#bib.bib4)\)directly model boundary representations\. Methods conditioned on images/sketches\(Liet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib21); Youet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib20); Chenet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib22); Doriset al\.[2026](https://arxiv.org/html/2608.05714#bib.bib23)\), or point clouds\(Khanet al\.[2024a](https://arxiv.org/html/2608.05714#bib.bib24); Liuet al\.[2024](https://arxiv.org/html/2608.05714#bib.bib25); Rukhovichet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib26)\)reconstruct CAD codes from geometric observations; FlexCAD and GeoCAD additionally support controllable editing\(Zhanget al\.[2025](https://arxiv.org/html/2608.05714#bib.bib29),[2026](https://arxiv.org/html/2608.05714#bib.bib30)\)\. Although these inputs provide strong geometric constraints, natural language offers a more direct interface for expressing high\-level design intent\.
Text\-to\-CAD methods instead predict parametric sequences or CAD code from descriptions\(Yavartanooet al\.[2024](https://arxiv.org/html/2608.05714#bib.bib7); Xie and Ju[2025](https://arxiv.org/html/2608.05714#bib.bib8); Liet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib14); Govindarajanet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib15)\)\. Most emphasize supervised mapping, planning, or controllable generation\. Their outputs may be executed for evaluation, but execution is not necessarily represented as a learned post\-execution critique action within a refinement trajectory\.
### Feedback\-Guided CAD Refinement
Feedback\-guided methods differ in both the source and representation of feedback\. CADFusion\(Wanget al\.[2025](https://arxiv.org/html/2608.05714#bib.bib35)\)pioneered the introduction of DPO\(Rafailovet al\.[2023](https://arxiv.org/html/2608.05714#bib.bib33)\), using rendered 3D visual feedback as preference signals to improve geometric consistency and visual fidelity\. In order to further improve geometric accuracy, CAD\-Coder\(Guanet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib10)\)introduced GRPO\(Shaoet al\.[2024](https://arxiv.org/html/2608.05714#bib.bib34)\), which further advanced geometric accuracy with GRPO, leveraging chain\-of\-thought \(CoT\)\(Weiet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib43)\)inference and geometric metrics as optimization signals\. ReCAD\(Liet al\.[2026a](https://arxiv.org/html/2608.05714#bib.bib36)\), PR\-CAD\(Anet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib39)\), CME\-CAD\(Niuet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib38)\), ToolCAD\(Gonget al\.[2026](https://arxiv.org/html/2608.05714#bib.bib19)\), and IterCAD\(Huet al\.[2026](https://arxiv.org/html/2608.05714#bib.bib17)\)further demonstrate the value of reinforcement learning, structured reasoning, multi\-turn refinement, and environment interaction in CAD generation\. Although these methods show that feedback can improve CAD generation, they primarily optimize structured inputs, generation policies, or tool\-use processes\. In contrast, we formulate text\-to\-CAD generation as a closed\-loop refinement process driven by explicit learnable post\-execution critique and jointly optimize the generation, rewriting, and critique policies at the trajectory level\.
## Method
### Problem Formulation
Let𝒟=\{\(d\(i\),c⋆\(i\)\)\}i=1N\\mathcal\{D\}=\\\{\(d^\{\(i\)\},c^\{\\star\(i\)\}\)\\\}\_\{i=1\}^\{N\}be a text\-to\-CAD dataset, whereddis a natural\-language design description andc⋆=\(c1⋆,…,cL⋆\)c^\{\\star\}=\(c^\{\\star\}\_\{1\},\\ldots,c^\{\\star\}\_\{L\}\)is its ground\-truth parametric CAD code\. A CAD executorℰ\\mathcal\{E\}maps a candidate codeccto an execution resulte=ℰ\(c\)e=\\mathcal\{E\}\(c\), which records whether the code is valid and any available diagnostic message\. If execution succeeds, the CAD environment instantiates geometry𝒢\(c\)\\mathcal\{G\}\(c\)\. Text\-to\-CAD generation therefore seeks a conditional policy
c^∼πθ\(⋅∣d\),e^=ℰ\(c^\),\\hat\{c\}\\sim\\pi\_\{\\theta\}\(\\,\\cdot\\mid d\),\\qquad\\hat\{e\}=\\mathcal\{E\}\(\\hat\{c\}\),\(1\)wherec^\\hat\{c\}is executable, agrees with the design intent indd, and instantiates geometry consistent with𝒢\(c⋆\)\\mathcal\{G\}\(c^\{\\star\}\)\. A one\-shot policy ends after producingc^\\hat\{c\}and cannot usee^\\hat\{e\}to repair the code\. RA\-CAD instead formulates generation as a finite sequence of interactions between the policy andℰ\\mathcal\{E\}\. Starting from a state initialized bydd, roundttfollows the high\-level transition
c~t\\displaystyle\\tilde\{c\}\_\{t\}∼πθg&r\(⋅∣st−1\),\\displaystyle\\sim\\pi\_\{\\theta\}^\{\\mathrm\{g\\&r\}\}\(\\,\\cdot\\mid s\_\{t\-1\}\),et\\displaystyle e\_\{t\}=ℰ\(c~t\),\\displaystyle=\\mathcal\{E\}\(\\tilde\{c\}\_\{t\}\),\(2\)f~t\\displaystyle\\tilde\{f\}\_\{t\}∼πθcrit\(⋅∣s¯t\),\\displaystyle\\sim\\pi\_\{\\theta\}^\{\\mathrm\{crit\}\}\(\\,\\cdot\\mid\\bar\{s\}\_\{t\}\),wherec~t\\tilde\{c\}\_\{t\}is the initial code att=1t=1or a rewrite att\>1t\>1,s¯t\\bar\{s\}\_\{t\}is the state after execution, andf~t\\tilde\{f\}\_\{t\}is the explicit post\-execution critique\. The critique either accepts the current code or supplies guidance that conditions the next rewrite\. The process terminates upon acceptance or at the interaction limit and returns the final codecTc\_\{T\}\. As shown in[Figure˜3](https://arxiv.org/html/2608.05714#Sx3.F3), its complete trajectory is
τ=\(s0,a1,s1,…,aT,sT\),\\tau=\(s\_\{0\},a\_\{1\},s\_\{1\},\\ldots,a\_\{T\},s\_\{T\}\),\(3\)whereτ\\taurepresents the trajectory,s0s\_\{0\}represents the initial state consisting solely ofdd,a\>0a\_\{\>0\}indicates each composite action,s\>0s\_\{\>0\}represents the each complete state, andTTrepresents the final round\.
As shown in[Figure˜2](https://arxiv.org/html/2608.05714#Sx1.F2), RA\-CAD trains this policy in two stages\. CAD Code Bootstrapping \(CCB\) first learns the description\-to\-code mapping from\(d,c⋆\)\(d,c^\{\\star\}\)pairs by supervised fine\-tuning\. Feedback\-driven Agent Optimization \(FAO\) then samples complete Generate–Execute–Critique–Rewrite trajectories and applies terminal CAD\-quality rewards to all policy\-generated code and critique sequences\. The following subsections specify these two stages and the trajectory\-level objective\.
### CAD Code Bootstrapping
Strict CAD syntax and geometric constraints make it unreliable for reinforcement learning to learn valid CAD generation from scratch\. CCB therefore first performs supervised fine\-tuning on the basic language model to initialize its parametric CAD code generation capability\.
During the training process, we adopt a teacher forcing policy to gradually predict each token in the target CAD code through autoregression \(next\-token prediction\)\. In thell\-th generation step, the model predicts the current tokencl⋆c^\{\\star\}\_\{l\}based on the previousl−1l\-1ground\-truth tokens as conditions, and uses cross\-entropy loss for supervised optimization\. The entire training objective is defined as
ℒSFT=−1L∑l=1Llogπθ\(cl⋆\|d,c<l⋆\),\\mathcal\{L\}\_\{\\mathrm\{SFT\}\}=\-\\frac\{1\}\{L\}\\sum\_\{l=1\}^\{L\}\\log\\pi\_\{\\theta\}\(c^\{\\star\}\_\{l\}\|d,c^\{\\star\}\_\{<l\}\),\(4\)whereLLrepresents the length of the ground\-truth code,πθ\\pi\_\{\\theta\}denotes the model policy with parametersθ\\theta\.
Figure 3:Overview of the agent trajectory in RA\-CAD\. The input description is considered the initial states0s\_\{0\}\. At each loop, the agent executes an actionata\_\{t\}and interacts with the CAD environment, producing a state transition fromst−1s\_\{t\-1\}tosts\_\{t\}\. After completing the multi\-step interaction trajectory, the final reward is computed based on the generated CAD code and its execution results for policy optimization of code proposals and critique outputs\.
### Feedback\-driven Agent Optimization
While CAD Code Bootstrapping \(CCB\) enables the agent to generate executable CAD code, it does not explicitly optimize the agent’s reasoning and decision\-making ability during multi\-round interaction\. To address this limitation, we design a ReAct Agent that works as a closed\-loop CAD generation process, and we model the process as a Markov Decision Process \(MDP\)\(Bellman[1957](https://arxiv.org/html/2608.05714#bib.bib44); Liet al\.[2019](https://arxiv.org/html/2608.05714#bib.bib45)\), in which the agent makes decisions conditioned on the current design objective, historical generation result, and execution result from the environment\. The complete process forms a trajectoryτ\\tau, which is optimized according to the quality of the final executable CAD model, as shown in[Figure˜3](https://arxiv.org/html/2608.05714#Sx3.F3)\. In this way, GRPO optimization is no longer focused on single CAD code prediction, but on the decision\-making policy of the entire agent\.
#### State
To capture both the current CAD generation result and the execution result returned by the environment, we define the state at roundttas
st=\(d,ct,et,ft\),s\_\{t\}=\(d,c\_\{t\},e\_\{t\},f\_\{t\}\),\(5\)wheredddenotes the user\-provided text description,ctc\_\{t\}denotes the current CAD code candidate,ete\_\{t\}denotes the results returned by the CAD execution environment, andftf\_\{t\}denotes the critique result associated with the current round\. Therefore, each decision made by the agent is conditioned on the design objective, the current code state, the execution result, and the critique feedback\.
#### Action
Our framework contains four functional modules: Generation, Execution, Critique, and Rewriting\. Among them, Generation, Critique, and Rewriting constitute the agent\-side decision process, while Execution belongs to the environment and is responsible for executing the current CAD code and returning feedback\.
Instead of treating Generation, Critique, and Rewriting as isolated actions, we formulate the agent’s decision at each round as a composite action:
at=\(c~t,f~t\),a\_\{t\}=\(\\tilde\{c\}\_\{t\},\\tilde\{f\}\_\{t\}\),\(6\)whereata\_\{t\}is temporally ordered composite decision,c~t\\tilde\{c\}\_\{t\}denotes the CAD code proposed by the agent at the current round which depends on the action mode ofmt∈\{generate,rewrite\}m\_\{t\}\\in\\\{\\texttt\{generate\},\\texttt\{rewrite\}\\\}, andf~t\\tilde\{f\}\_\{t\}denotes the critique output, which is the evaluation of whether the current code and its execution result meet the design objectives\. Specifically, whenm1=generatem\_\{1\}=\\texttt\{generate\}, the agent only generates the initial CAD code based on the input description\. Whenm\>1=rewritem\_\{\>1\}=\\texttt\{rewrite\}, the agent will modify the previous CAD code based on the text description, execution results, and previous evaluation records\. After getting the generated code in the above steps and then obtaining the execution result, the agent critiques it again\. On this basis, we can define the policy in detail as
πθ\(at∣st−1\)=πθg&r\(c~t∣st−1\)πθcrit\(f~t∣s¯t\)\.\\pi\_\{\\theta\}\(a\_\{t\}\\mid s\_\{t\-1\}\)=\\pi\_\{\\theta\}^\{\\mathrm\{g\\&r\}\}\(\\tilde\{c\}\_\{t\}\\mid s\_\{t\-1\}\)\\pi\_\{\\theta\}^\{\\mathrm\{crit\}\}\(\\tilde\{f\}\_\{t\}\\mid\\bar\{s\}\_\{t\}\)\.\(7\)whereπθg&r\\pi\_\{\\theta\}^\{\\mathrm\{g\\&r\}\}andπθcrit\\pi\_\{\\theta\}^\{\\mathrm\{crit\}\}denote the conditional distributions for Generation/Rewriting and Critique, respectively\. Afterc~t\\tilde\{c\}\_\{t\}is produced, the CAD environment updates to intermediate states¯t\\bar\{s\}\_\{t\}, which has been updated toc~t\\tilde\{c\}\_\{t\}andete\_\{t\}, respectively\. The Critique module then producesf~t\\tilde\{f\}\_\{t\}conditioned ons¯t\\bar\{s\}\_\{t\}\. As shown in[Figure˜3](https://arxiv.org/html/2608.05714#Sx3.F3), after fully executing actionata\_\{t\}, the environment state transitions fromst−1s\_\{t\-1\}tosts\_\{t\}\.
The four modules are described as follows:
1\. GenerationThe Generation module is responsible for producing the initial CAD code from the input text description\. Given an initial states0s\_\{0\}that only containsdd, the Generation module will generate the initial candidate CAD codec1c\_\{1\}and pass it into the environment\. Rather than being directly treated as the final output, the generated code is regarded as an intermediate hypothesis for the current design objective, which will be further verified and refined through interaction with the execution environment\.
2\. ExecutionThe Execution module belongs to the environment rather than the agent itself\. It instantiates and executes the CAD codectc\_\{t\}proposed by the agent, detects syntax errors, invalid parameters, and other execution failures, and returns execution status together with the corresponding error message, if it exists, to the environment\. Then it forms an intermediate states¯t\\bar\{s\}\_\{t\}\.
3\. CritiqueThe Critique module evaluates the current CAD result by jointly considering the intermediate states¯t\\bar\{s\}\_\{t\}\(including input descriptiondd, the generated CAD codectc\_\{t\}, and the execution resultete\_\{t\}\)\. It determines whether the current code satisfies the design requirements in terms of intent consistency, geometric validity, and overall model quality\. The critique output not only decides whether further optimization is needed, but also provides revision suggestions for the next round\.
4\. RewritingWhen the Critique results indicate that the current code still has room for improvement, the rewriting module will work as the start of a new round of actions for the agent\. It will rewrite the code based on the complete statest=\(d,ct,et,ft\)s\_\{t\}=\(d,c\_\{t\},e\_\{t\},f\_\{t\}\)updated from the previous round of actions\. The modified codect\+1c\_\{t\+1\}will then be sent back to the Execution module for verification\. The interaction loop continues until the critique module determines that the design goal has been satisfied or the maximum number of iterations is reached\.
#### Reward
Since the ultimate goal of CAD codes is to generate parameterized models that meet design requirements and can be executed correctly, we calculate the final reward value for the complete trajectory based on the final generated code results\. For the final generated result, we comprehensively consider the following aspects: how close the generated sequence is to the ground\-truth sequence; whether the CAD code can be successfully executed; and geometric similarity between the generated model and ground\-truth model\. Therefore, the reward function can be expressed as
R=λ1RF1\+λ2RCD,R=\\lambda\_\{1\}R\_\{\\text\{F1\}\}\+\\lambda\_\{2\}R\_\{\\text\{CD\}\},\(8\)whereλ1,λ2\\lambda\_\{1\},\\lambda\_\{2\}are weight coefficients;RF1R\_\{\\text\{F1\}\}is the F1 score reward of the basic sketch topological tokens, which measures the similarity between the generated parameter sequence and the real parameter sequence;RCDR\_\{\\text\{CD\}\}is the distance of the instantiated model of the final result of the trajectory, which not only measures whether the code is successfully executed, but also measures the quality of the executable model generation\. Specifically,RCDR\_\{\\text\{CD\}\}andRF1R\_\{\\text\{F1\}\}are defined as:
RCD=\{e−γCD,if CAD code is executable0,otherwise,R\_\{\\text\{CD\}\}=\\begin\{cases\}e^\{\-\\gamma\\text\{CD\}\},&\\text\{if CAD code is executable\}\\\\ 0,&\\text\{otherwise\}\\end\{cases\},\(9\)RF1=RAvg F1=\(F1line\+F1arc\+F1circle\)/3,R\_\{\\text\{F1\}\}=R\_\{\\text\{Avg F1\}\}=\(\\text\{F1\}\_\{\\text\{line\}\}\+\\text\{F1\}\_\{\\text\{arc\}\}\+\\text\{F1\}\_\{\\text\{circle\}\}\)/3,\(10\)whereγ\\gammais hyperparameter andCDis the chamfer distance between the point cloud corresponding to the generated CAD model𝒢\(c\)\\mathcal\{G\}\(c\)and the point cloud corresponding to the ground\-truth CAD model𝒢\(c⋆\)\\mathcal\{G\}\(c^\{\\star\}\), andRF1R\_\{\\text\{F1\}\}only considers the basic sketch topological tokens\{line,arc,circle\}\\\{\\texttt\{line\},\\texttt\{arc\},\\texttt\{circle\}\\\}as they dominate CAD sequences and determine structural correctness\. Extrusion tokens\{add,cut,intersect\}\\\{\\texttt\{add\},\\texttt\{cut\},\\texttt\{intersect\}\\\}exhibit substantially higher numerical variability than sketch topology tokens, making token\-level matching less reliable, with their quality indirectly measured by the CD reward\. Due to the dependence of rewards on the entire agent inference process, they cannot be decomposed into a single step, but rather serve as the final reward for the entire trajectory\. Although the reward is defined on the final trajectory outcome, the critique behavior is implicitly optimized because critique outputs constitute part of the action trajectory updated by GRPO\.
\(a\)CADFusion Dataset
\(b\)Text2CAD Dataset
Table 1:Comparison of RA\-CAD with existing methods on CADFusion and Text2CAD datasets\. The evaluation indicators include parameter sequence quality \(F1 scores\) and instantiated model quality \(Avg CD, Med CD, JSD, and IR\)\. RA\-CAD performed significantly better than other methods in these two tasks, demonstrating excellent accuracy and controllability\. All indicators are multiplied by10210^\{2\}for readability\.↑\\uparrow: The higher the better;↓\\downarrow: The lower the better\. The best performance is highlighted in bold\.
#### Policy Optimization with GRPO
Given the trajectory\-level rewardRR, we adopt GRPO to optimize the agent policyπθ\\pi\_\{\\theta\}\. It normalizes rewards within each group of trajectories sampled from the same input, providing a stable and computation\-efficient advantage estimation\. Firstly, it calculates the group\-relative advantageAk\[p\]A\_\{k\}\[p\]of thekk\-th trajectory of theii\-th sample through the reward value, which is defined as follows
Ak\[p\]=Rk−μiσi,A\_\{k\}\[p\]=\\displaystyle\\frac\{R\_\{k\}\-\\mu\_\{i\}\}\{\\sigma\_\{i\}\},\(11\)whereRkR\_\{k\}is the final reward of thekk\-th trajectory,μi\\mu\_\{i\}represents group\-wise mean,σi\\sigma\_\{i\}represents standard deviation, andppis the valid token position in the trajectory\. Given the advantages, we compute the token\-level probability ratio
ρk\[p\]=πθ\(lk,t\[p\]∣sk,t,lk,t\[:p\]\)πθold\(lk,t\[p\]∣sk,t,lk,t\[:p\]\)\\rho\_\{k\}\[p\]=\\frac\{\\pi\_\{\\theta\}\(l\_\{k,t\}\[p\]\\mid s\_\{k,t\},\\;l\_\{k,t\}\[:p\]\)\}\{\\pi\_\{\\theta\_\{\\text\{old\}\}\}\(l\_\{k,t\}\[p\]\\mid s\_\{k,t\},\\;l\_\{k,t\}\[:p\]\)\}\(12\)between the current policyπθ\\pi\_\{\\theta\}and the old policyπθold\\pi\_\{\\theta\_\{\\text\{old\}\}\}, wherelk,t∈\{lk,1,…,lk,T\}l\_\{k,t\}\\in\\\{l\_\{k,1\},\\dots,l\_\{k,T\}\\\}represents the output sequence in thett\-th sub\-action round, including the generated code sequence and the critique sequence\. Then we optimize the clipped surrogate objective defined as
ℒGRPO=−1K∑k=1K1Lk∑p=0Lk−1min\(ρk\[p\]⋅Ak\[p\],clip\(ρk\[p\],1−ε−,1\+ε\+\)⋅Ak\[p\]\)\+β⋅𝔼k,p\(logπθπref−1\+πrefπθ\),\\mathcal\{L\}\_\{\\text\{GRPO\}\}=\\begin\{aligned\} &\-\\frac\{1\}\{K\}\\sum\_\{k=1\}^\{K\}\\begin\{aligned\} &\\frac\{1\}\{L\_\{k\}\}\\sum\_\{p=0\}^\{L\_\{k\}\-1\}\\min\\big\(\\rho\_\{k\}\[p\]\\cdot A\_\{k\}\[p\],\\;\\\\ &\\quad\\operatorname\{clip\}\(\\rho\_\{k\}\[p\],\\;1\-\\varepsilon\_\{\-\},\\;1\+\\varepsilon\_\{\+\}\)\\cdot A\_\{k\}\[p\]\)\\end\{aligned\}\\\\ &\+\\beta\\cdot\\mathbb\{E\}\_\{k,p\}\\big\(\\log\\frac\{\\pi\_\{\\theta\}\}\{\\pi\_\{\\text\{ref\}\}\}\-1\+\\frac\{\\pi\_\{\\text\{ref\}\}\}\{\\pi\_\{\\theta\}\}\),\\end\{aligned\}\(13\)whereKKis the total number of trajectories,LkL\_\{k\}is the length of thekk\-th trajectory,ε−\\varepsilon\_\{\-\}andε\+\\varepsilon\_\{\+\}are the clipping hyperparameter that constrains the magnitude of policy updates to ensure training stability, andβ⋅𝔼k,p\(⋅\)\\beta\\cdot\\mathbb\{E\}\_\{k,p\}\(\\cdot\)are KL regularization and its corresponding hyperparameter\. By optimizing this objective with GRPO, the generation and critique policy within the agent are jointly and synergistically optimized under the guidance of the state\.
## Experiments
In this section, we conducted experiments on the CADFusion and Text2CAD datasets to comprehensively evaluate the effectiveness of the proposed method\. Firstly, the experimental setups are introduced, including the datasets, training settings, and evaluation metrics\. Subsequently, RA\-CAD will be compared with existing representative methods and mainstream proprietary LLMs to verify its overall performance\. After that, we analyze the contribution of each core module to the model performance through ablation experiments, further verifying the effectiveness of the proposed framework\.
### Setups
#### Datasets
We adopt SkexGen’s parameter sequence construction rules\(Xuet al\.[2022](https://arxiv.org/html/2608.05714#bib.bib2)\)to reparameterize the CAD models in the Text2CAD and CADFusion datasets and construct a unified CAD code sequence\. The text description retains the natural language annotations provided by the original datasets, while performing data cleaning on the datasets to remove samples whose ground\-truth parameter sequences cannot be instantiated, in order to ensure data quality and training stability\. It should be noted that when processing the Text2CAD dataset, considering that user descriptions in actual CAD design scenarios typically focus on high\-level semantics rather than the specific geometric parameters, we only used its intermediate\-level text description for experimentation\. The processed CADFusion and Text2CAD datasets contain approximately 20k and 60k samples, respectively, and the ratio of training, validation, and testing sets is retained at 90%\-5%\-5%\.
#### Implementation Details
We use the open\-source Meta\-Llama\-3\-8B\-Instruct as the base model\. In the CCB stage, the CADFusion SFT training framework is used, and Low Rank Adaptation \(LoRA\) is used for efficient parameter tuning\. The model is trained for 9 epochs, with a learning rate set to1×10−41\\times 10^\{\-4\}, LoRA hyperparameters set tor=32r=32,α=32\\alpha=32, and an optimizer using AdamW\. In the FAO stage, we train based on the AgentLightning framework\(Luoet al\.[2025](https://arxiv.org/html/2608.05714#bib.bib42)\)and implement distributed training using Fully Sharded Data Parallel \(FSDP\)\. The training learning rate is set to1×10−61\\times 10^\{\-6\}\. Each input sample hasK=8K=8trajectories, and the training batch size is 16\. GRPO hyperparameters set toλ1=0\.1\\lambda\_\{1\}=0\.1,λ2=0\.9\\lambda\_\{2\}=0\.9,γ=1\\gamma=1,β=10−3\\beta=10^\{\-3\},ε−=0\.2\\varepsilon\_\{\-\}=0\.2,ε\+=0\.3\\varepsilon\_\{\+\}=0\.3\. All experiments were conducted on two NVIDIA GeForce RTX 4090 \(48 GB\) GPUs\.
#### Baseline
We consider two baselines, the first of which is the transformer architecture for implementing end\-to\-end text\-to\-parametric CAD model generation in Text2CAD\(Khanet al\.[2024b](https://arxiv.org/html/2608.05714#bib.bib6)\)\. Due to significant differences between its model structure and the method proposed in this paper, we follow the original implementation\. The second type is CADFusion’s\(Wanget al\.[2025](https://arxiv.org/html/2608.05714#bib.bib35)\)LLM fine\-tuning architecture based on visual signals for preference learning\.
#### Metrics
We evaluated the model from two aspects: the parameter sequence and the instantiated CAD model\. The quality of the parameter sequence was measured using the evaluation protocols of Text2CAD and CADFusion, based on the F1 scores of each topological operation \(including line, arc, circle, and extrusion\) and the average of basic sketch topological tokens\. The model quality was assessed by instantiating the generated sequence into a 3D CAD model and comparing it with the real model point cloud\. The geometric accuracy, executability, and distribution consistency were evaluated using average CD \(Avg CD\), median CD \(Med CD\), invalidity ratio \(IR\), and Jensen\-Shannon divergence \(JSD\) indicators\.
\(a\)CADFusion Dataset
\(b\)Text2CAD Dataset
Table 2:Comparison of RA\-CAD with proprietary LLMs under the same prompting protocol\. The results are measured by sequence\-level accuracy \(Avg F1\), geometric similarity \(Avg CD\), and execution validity \(IR\)\.Table 3:Ablation studies on the effectiveness of different components in RA\-CAD on the CADFusion dataset\. The experiments evaluate the contributions of CCB and FAO, among which FAO is composed of GRPO and the Generation and Critique of the agent\. The results are measured by sequence\-level accuracy \(Avg F1\), geometric similarity \(Avg CD\), and execution validity \(IR\)\.
### Main Results
We evaluated RA\-CAD through comprehensive experiments on the CADFusion\(Wanget al\.[2025](https://arxiv.org/html/2608.05714#bib.bib35)\)and Text2CAD\(Khanet al\.[2024b](https://arxiv.org/html/2608.05714#bib.bib6)\)datasets, and compared its final parameter sequence generation quality and instantiated CAD model quality with existing methods\. The final results are shown in[Table˜1](https://arxiv.org/html/2608.05714#Sx3.T1)\. Our results indicate that our complete method achieved the best results on most metrics, outperforming previous work in terms of geometric accuracy\. Specifically, for the CADFusion dataset, it reduced the Avg CD to 35\.44 and IR to 6\.20, and for the Text2CAD dataset, it reduced the Avg CD to 38\.86 and IR to 9\.44\.[Figure˜4](https://arxiv.org/html/2608.05714#Sx4.F4)exhibits the qualitative results\. We can observe that, compared with the powerful baselines Text2CAD and CADFusion, RA\-CAD has achieved significant improvements\. The optimization objective of RA\-CAD is more inclined towards global geometric consistency rather than simply mimicking the parameter distribution of the training set\. Although CADFusion is more aggressive in predicting extrusion tokens, RA\-CAD achieves a better overall performance between the final rendered geometry \(CD/JSD\) and invalidity ratio \(IR\)\. This indicates that RA\-CAD with the learnable post\-execution critique mechanism understands the geometric prior that parameter combinations determine shape, rather than merely memorizing the statistical frequencies of the parameters\.
Figure 4:Qualitative comparison of baseline methods and different model variants under different training policies\. Non\-executable outputs are marked\. The far\-right column displays the overall model of our method, which has the highest executability and best preserves the structure and geometry\.
### Proprietary LLMs Studies
We further evaluate its performance against several state\-of\-the\-art proprietary LLMs\. Specifically, considering that reasoning ability may have an additional impact on the generated results, to ensure comparative fairness, we adopt a uniform 8\-shot prompting strategy\. The quantitative results are presented in[Table˜2](https://arxiv.org/html/2608.05714#Sx4.T2)and the qualitative results are also shown in[Figure˜4](https://arxiv.org/html/2608.05714#Sx4.F4)\. Although these proprietary models exhibit remarkable capabilities in general\-purpose code generation and reasoning, they perform considerably worse on parametric CAD generation\. In particular, they frequently generate syntactically invalid CAD codes or geometrically inconsistent modeling operations, resulting in a high IR\.
### Ablation Studies
We also isolate the impact of each component in the experiment pipeline, and the final results are shown in[Table˜3](https://arxiv.org/html/2608.05714#Sx4.T3)\. We first consider that without CCB, the performance of the model would be so poor that even an effective model could not be generated, indicating the necessity of using prior knowledge in reinforcement learning based on execution results\. Then, we remove the FAO stage and only retain the model trained in the CCB stage, whose limited performance indicators indicate that SFT alone cannot fully capture the spatial reasoning of complex CAD structures\. However, even without GRPO training, the agent itself significantly improves the efficiency and accuracy of generation, confirming that introducing only agent\-based interaction frameworks has brought substantial improvements in both feasibility and geometric accuracy\. Similarly, we remove the Critique from the agent and simplify the framework to traditional reinforcement learning without critique\-correction generation\. In this case, compared to the complete RA\-CAD, the performance of all evaluation indicators continues to decline\. This observation confirms that performance gains are not only brought about by GRPO itself but also largely benefit from the post\-execution critique rewriting mechanism from the agent, providing richer optimization signals for policy learning\.
Overall, the complete RA\-CAD achieved the best performance in all evaluation metrics\. These results indicate that CCB provides reliable initialization for executable CAD generation, and FAO further enhances agents through trajectory\-level reinforcement learning\. These components complement each other and contribute to the outstanding performance of RA\-CAD\.
## Conclusion
In this paper, we presented a ReAct Agent for CAD generation \(RA\-CAD\), which learned not only to generate CAD codes but also to critique and revise them after execution\. Its central formulation factorized a complete code proposal/rewrite and an explicit post\-execution critique within one state\-aware policy, then jointly optimized their token sequences over complete trajectories\. CCB supplied executable CAD priors, and FAO used terminal sequence and geometry quality to improve critique\-guided rewriting without a separate value critic or reward model\. The reported results and ablations indicated improved geometric fidelity and validity ratio on CADFusion and Text2CAD, while leaving direct visual conditioning, per\-round convergence, and broader code\-space generalization for future evaluation\.
## References
- J\. An, J\. Zhao, F\. Chen, L\. Yang, Z\. Liu, H\. Wang, W\. An, M\. Zhang, and E\. Yang \(2026\)PR\-cad: progressive refinement for unified controllable and faithful text\-to\-cad generation with large language models\.External Links:2604\.19773,[Link](https://arxiv.org/abs/2604.19773)Cited by:[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- R\. E\. Bellman \(1957\)A markovian decision process\.\.RAND Corporation,Santa Monica, CA\.External Links:[Document](https://dx.doi.org/)Cited by:[Feedback\-driven Agent Optimization](https://arxiv.org/html/2608.05714#Sx3.SSx3.p1.1)\.
- C\. Chen, J\. Wei, T\. Chen, C\. Zhang, X\. Yang, S\. Zhang, B\. Yang, C\. Foo, G\. Lin, Q\. Huang, and F\. Liu \(2025\)CADCrafter: generating computer\-aided design models from unconstrained images\.InProceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition \(CVPR\),pp\. 11073–11082\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- Y\. Deng, J\. Chen, and A\. Olechowski \(2023\)What sets proficient and expert users apart? results of a computer\-aided design experiment\.Journal of Mechanical Design146\(1\),pp\. 011401\.External Links:ISSN 1050\-0472,[Document](https://dx.doi.org/10.1115/1.4063360),[Link](https://doi.org/10.1115/1.4063360),https://asmedigitalcollection\.asme\.org/mechanicaldesign/article\-pdf/146/1/011401/7048596/md\_146\_1\_011401\.pdfCited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p1.1)\.
- A\. C\. Doris, F\. Alam, A\. Heyrani Nobari, and F\. Ahmed \(2026\)CAD\-coder: an open\-source vision\-language model for computer\-aided design code generation\.Journal of Mechanical Design148\(7\),pp\. 071702\.External Links:ISSN 1050\-0472,[Document](https://dx.doi.org/10.1115/1.4071305),[Link](https://doi.org/10.1115/1.4071305),https://asmedigitalcollection\.asme\.org/mechanicaldesign/article\-pdf/148/7/071702/7598268/md\-25\-1707\.pdfCited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- F\. Fan, J\. Ni, X\. Yin, S\. Wang, X\. Lu, Q\. Zou, R\. Tong, M\. Tang, and P\. Du \(2026\)CADDesigner: conceptual cad model generation with a general\-purpose agent\.External Links:2508\.01031,[Link](https://arxiv.org/abs/2508.01031)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p3.1)\.
- Y\. Ganin, S\. Bartunov, Y\. Li, E\. Keller, and S\. Saliceti \(2021\)Computer\-aided design as language\.InAdvances in Neural Information Processing Systems,M\. Ranzato, A\. Beygelzimer, Y\. Dauphin, P\.S\. Liang, and J\. W\. Vaughan \(Eds\.\),Vol\.34,pp\. 5885–5897\.External Links:[Link](https://proceedings.neurips.cc/paper_files/paper/2021/file/2e92962c0b6996add9517e4242ea9bdc-Paper.pdf)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- Y\. Gong, X\. Wu, W\. Liu, and Tukang \(2026\)TOOLCAD: exploring tool\-using large language models in text\-to\-CAD generation with reinforcement learning\.InFindings of the Association for Computational Linguistics: ACL 2026,M\. Liakata, V\. P\. Moreira, J\. Zhang, and D\. Jurgens \(Eds\.\),San Diego, California, United States,pp\. 23161–23188\.External Links:[Link](https://aclanthology.org/2026.findings-acl.1160/),[Document](https://dx.doi.org/10.18653/v1/2026.findings-acl.1160),ISBN 979\-8\-89176\-395\-1Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p3.1),[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- P\. Govindarajan, D\. Baldelli, J\. Pathak, Q\. Fournier, and S\. Chandar \(2025\)CADmium: fine\-tuning code language models for text\-driven sequential cad design\.arXiv preprint arXiv:2507\.09792\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p2.1)\.
- Y\. Guan, X\. Wang, X\. Xing, J\. Zhang, D\. Xu, and Q\. Yu \(2025\)CAD\-coder: text\-to\-cad generation with chain\-of\-thought and geometric reward\.arXiv preprint arXiv:2505\.19713\.Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- C\. He, S\. Zhang, L\. Zhang, and J\. Miao \(2025\)CAD\-coder: text\-guided cad files code generation\.External Links:2505\.08686,[Link](https://arxiv.org/abs/2505.08686)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1)\.
- T\. Hu, J\. Ai, L\. Wen, X\. Li, S\. Zou, S\. Li, N\. Deng, X\. Cai, H\. Zhou, P\. Cai, D\. Fu, Y\. Yang, H\. Zhang, B\. Shi, and X\. Yang \(2026\)IterCAD: an iterative multimodal agent for visually\-grounded cad generation and editing\.External Links:2606\.13368,[Link](https://arxiv.org/abs/2606.13368)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p3.1),[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- P\. K\. Jayaraman, J\. G\. Lambourne, N\. Desai, K\. Willis, A\. Sanghi, and N\. J\. W\. Morris \(2023\)SolidGen: an autoregressive model for direct b\-rep synthesis\.Transactions on Machine Learning Research\.Note:Featured CertificationExternal Links:ISSN 2835\-8856,[Link](https://openreview.net/forum?id=ZR2CDgADRo)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- M\. S\. Khan, E\. Dupont, S\. A\. Ali, K\. Cherenkova, A\. Kacem, and D\. Aouada \(2024a\)CAD\-signet: cad language inference from point clouds using layer\-wise sketch instance guided attention\.InProceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition \(CVPR\),pp\. 4713–4722\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- M\. S\. Khan, S\. Sinha, S\. T\. Uddin, D\. Stricker, S\. A\. Ali, and M\. Z\. Afzal \(2024b\)Text2CAD: generating sequential cad designs from beginner\-to\-expert level text prompts\.InThe Thirty\-eighth Annual Conference on Neural Information Processing Systems,External Links:[Link](https://openreview.net/forum?id=5k9XeHIK3L)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[Baseline](https://arxiv.org/html/2608.05714#Sx4.SSx1.SSSx3.p1.1),[Main Results](https://arxiv.org/html/2608.05714#Sx4.SSx2.p1.1)\.
- C\. Li, H\. Pan, A\. Bousseau, and N\. J\. Mitra \(2022\)Free2CAD: parsing freehand drawings into cad commands\.ACM Trans\. Graph\.41\(4\)\.External Links:ISSN 0730\-0301,[Link](https://doi.org/10.1145/3528223.3530133),[Document](https://dx.doi.org/10.1145/3528223.3530133)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- J\. Li, Y\. Luo, Y\. Lou, and X\. Zhou \(2026a\)ReCAD: reinforcement learning enhanced parametric cad model generation with vision\-language models\.Proceedings of the AAAI Conference on Artificial Intelligence40\(8\),pp\. 6190–6198\.External Links:[Link](https://ojs.aaai.org/index.php/AAAI/article/view/37544),[Document](https://dx.doi.org/10.1609/aaai.v40i8.37544)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- J\. Li, W\. Ma, X\. Li, Y\. Lou, G\. Zhou, and X\. Zhou \(2025\)CAD\-llama: leveraging large language models for computer\-aided design parametric 3d model generation\.InProceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition \(CVPR\),pp\. 18563–18573\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p2.1)\.
- Q\. Li, J\. Ma, R\. Fan, and L\. Xia \(2019\)An overview for markov decision processes in queues and networks\.External Links:1907\.10243,[Link](https://arxiv.org/abs/1907.10243)Cited by:[Feedback\-driven Agent Optimization](https://arxiv.org/html/2608.05714#Sx3.SSx3.p1.1)\.
- X\. Li, J\. Li, Y\. Song, Y\. Lou, and X\. Zhou \(2026b\)Seek\-cad: a self\-refined generative modeling for 3d parametric CAD using local inference via deepseek\.InThe Fourteenth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=PzIc2TxhwN)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p3.1)\.
- Y\. Liu, A\. Obukhov, J\. D\. Wegner, and K\. Schindler \(2024\)Point2CAD: reverse engineering cad models from 3d point clouds\.InProceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition \(CVPR\),pp\. 3763–3772\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- X\. Luo, Y\. Zhang, Z\. He, Z\. Wang, S\. Zhao, D\. Li, L\. K\. Qiu, and Y\. Yang \(2025\)Agent lightning: train any ai agents with reinforcement learning\.External Links:2508\.03680,[Link](https://arxiv.org/abs/2508.03680)Cited by:[Implementation Details](https://arxiv.org/html/2608.05714#Sx4.SSx1.SSSx2.p1.11)\.
- K\. Niu, H\. Yu, Z\. Chen, Z\. Yao, W\. Jia, X\. Ge, J\. Tang, B\. Cui, B\. Li, and X\. Xue \(2026\)CME\-cad: heterogeneous collaborative multi\-expert reinforcement learning for cad code generation\.InProceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition,pp\. 39272–39281\.Cited by:[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- W\. Para, S\. Bhat, P\. Guerrero, T\. Kelly, N\. Mitra, L\. Guibas, and P\. Wonka \(2021\)SketchGen: generating constrained cad sketches\.InAdvances in Neural Information Processing Systems,M\. Ranzato, A\. Beygelzimer, Y\. Dauphin, P\.S\. Liang, and J\. W\. Vaughan \(Eds\.\),Vol\.34,pp\. 5077–5088\.External Links:[Link](https://proceedings.neurips.cc/paper_files/paper/2021/file/28891cb4ab421830acc36b1f5fd6c91e-Paper.pdf)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- R\. Rafailov, A\. Sharma, E\. Mitchell, C\. D\. Manning, S\. Ermon, and C\. Finn \(2023\)Direct preference optimization: your language model is secretly a reward model\.InAdvances in Neural Information Processing Systems,A\. Oh, T\. Naumann, A\. Globerson, K\. Saenko, M\. Hardt, and S\. Levine \(Eds\.\),Vol\.36,pp\. 53728–53741\.External Links:[Link](https://proceedings.neurips.cc/paper_files/paper/2023/file/a85b405ed65c6477a4fe8302b5e06ce7-Paper-Conference.pdf)Cited by:[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- D\. Rukhovich, E\. Dupont, D\. Mallis, K\. Cherenkova, A\. Kacem, and D\. Aouada \(2025\)CAD\-recode: reverse engineering cad code from point clouds\.InProceedings of the IEEE/CVF International Conference on Computer Vision \(ICCV\),pp\. 9801–9811\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- Z\. Shao, P\. Wang, Q\. Zhu, R\. Xu, J\. Song, X\. Bi, H\. Zhang, M\. Zhang, Y\. K\. Li, Y\. Wu, and D\. Guo \(2024\)DeepSeekMath: pushing the limits of mathematical reasoning in open language models\.External Links:2402\.03300,[Link](https://arxiv.org/abs/2402.03300)Cited by:[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- R\. Wang, Y\. Yuan, S\. Sun, and J\. Bian \(2025\)Text\-to\-cad generation through infusing visual feedback in large language models\.InInternational Conference on Machine Learning,Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1),[Baseline](https://arxiv.org/html/2608.05714#Sx4.SSx1.SSSx3.p1.1),[Main Results](https://arxiv.org/html/2608.05714#Sx4.SSx2.p1.1)\.
- J\. Wei, X\. Wang, D\. Schuurmans, M\. Bosma, B\. Ichter, F\. Xia, E\. Chi, Q\. V\. Le, and D\. Zhou \(2022\)Chain\-of\-thought prompting elicits reasoning in large language models\.InAdvances in Neural Information Processing Systems,S\. Koyejo, S\. Mohamed, A\. Agarwal, D\. Belgrave, K\. Cho, and A\. Oh \(Eds\.\),Vol\.35,pp\. 24824–24837\.External Links:[Link](https://proceedings.neurips.cc/paper_files/paper/2022/file/9d5609613524ecf4f15af0f7b31abca4-Paper-Conference.pdf)Cited by:[Feedback\-Guided CAD Refinement](https://arxiv.org/html/2608.05714#Sx2.SSx2.p1.1)\.
- R\. Wu, C\. Xiao, and C\. Zheng \(2021\)DeepCAD: a deep generative network for computer\-aided design models\.InProceedings of the IEEE/CVF International Conference on Computer Vision \(ICCV\),pp\. 6772–6782\.Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p1.1),[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- H\. Xie and F\. Ju \(2025\)Text\-to\-cadquery: a new paradigm for cad generation with scalable large model capabilities\.External Links:2505\.06507,[Link](https://arxiv.org/abs/2505.06507)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p2.1)\.
- X\. Xu, P\. K\. Jayaraman, J\. G\. Lambourne, K\. D\. Willis, and Y\. Furukawa \(2023\)Hierarchical neural coding for controllable cad model generation\.InInternational Conference on Machine Learning,pp\. 38443–38461\.Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1),[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- X\. Xu, J\. Lambourne, P\. Jayaraman, Z\. Wang, K\. Willis, and Y\. Furukawa \(2024\)Brepgen: a b\-rep generative diffusion model with structured latent geometry\.ACM Transactions on Graphics \(TOG\)43\(4\),pp\. 1–14\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- X\. Xu, K\. D\. Willis, J\. G\. Lambourne, C\. Cheng, P\. K\. Jayaraman, and Y\. Furukawa \(2022\)SkexGen: autoregressive generation of cad construction sequences with disentangled codebooks\.InInternational Conference on Machine Learning,pp\. 24698–24724\.Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p1.1),[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1),[Datasets](https://arxiv.org/html/2608.05714#Sx4.SSx1.SSSx1.p1.1)\.
- S\. Yao, J\. Zhao, D\. Yu, N\. Du, I\. Shafran, K\. Narasimhan, and Y\. Cao \(2022\)ReAct: synergizing reasoning and acting in language models\.arXiv preprint arXiv:2210\.03629\.Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p4.1)\.
- M\. Yavartanoo, S\. Hong, R\. Neshatavar, and K\. M\. Lee \(2024\)Text2CAD: text to 3d cad generation via technical drawings\.External Links:2411\.06206,[Link](https://arxiv.org/abs/2411.06206)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p2.1)\.
- Y\. You, M\. A\. Uy, J\. Han, R\. Thomas, H\. Zhang, Y\. Du, H\. Chen, F\. Engelmann, S\. You, and L\. Guibas \(2025\)Img2CAD: reverse engineering 3d cad models from images through vlm\-assisted conditional factorization\.InProceedings of the SIGGRAPH Asia 2025 Conference Papers,SA Conference Papers ’25,New York, NY, USA\.External Links:ISBN 9798400721373,[Link](https://doi.org/10.1145/3757377.3763891),[Document](https://dx.doi.org/10.1145/3757377.3763891)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- B\. Yuan, Z\. Zhao, P\. Molodyk, B\. Hu, and Y\. Chen \(2026\)Clarify before you draw: proactive agents for robust text\-to\-cad generation\.External Links:2602\.03045,[Link](https://arxiv.org/abs/2602.03045)Cited by:[Introduction](https://arxiv.org/html/2608.05714#Sx1.p2.1)\.
- Z\. Zhang, J\. Liu, W\. Wang, B\. Lin, L\. Xie, C\. Shen, D\. Cai,et al\.\(2026\)GeoCAD: local geometry\-controllable cad generation with large language models\.Advances in Neural Information Processing Systems38,pp\. 130989–131014\.Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
- Z\. Zhang, S\. Sun, W\. Wang, D\. Cai, and J\. Bian \(2025\)FlexCAD: unified and versatile controllable cad generation with fine\-tuned large language models\.InInternational Conference on Learning Representations,Y\. Yue, A\. Garg, N\. Peng, F\. Sha, and R\. Yu \(Eds\.\),Vol\.2025,pp\. 3204–3227\.External Links:[Link](https://proceedings.iclr.cc/paper_files/paper/2025/file/090b23d52bc2722eef2fbf79c5ebf9ec-Paper-Conference.pdf)Cited by:[CAD Generation](https://arxiv.org/html/2608.05714#Sx2.SSx1.p1.1)\.
## Appendix ADescription
1"Description":"\[Shape Overview\]The3Dshapeconsistsofarectangularprismextendingintoasemi\-cylinderwithacurvedend\.\[Shape Details\]Itfeaturesonelargecircularholeontherectangularpartandfoursmaller,equallysizedholesalignedalongthesemi\-cylindricalsection\.\[Shape Applications\]Theshapeissymmetricallyalignedalongitscentralaxisandpotentiallydesignedformountingorconnectingwithothercomponents\."
Listing 1A representative sample of CADFusion’s description structures\. The three\-stage structure has been highlighted in bold font\.1\{
2"L0":"Arectangularprismwithacylindricalholeinthecenter\.Theprismhasfourcircularcutoutsonitstopsurface\."
3"L1":"TheCADmodelfeaturesarectangularbarwithacylindricalholeinthecenterandfourcircularcutoutsectionsontop\."
4"L2":"TheCADmodelconsistsofarectangularprismwithacylindricalholeinthecenterandcircularcutoutsonthetopsurface\.Thispartiscreatedbysketchinginsideacoordinatesystemandextrudingandcuttingshapesin3D\.Theresultingparthasaheightofapproximately0\.2units\."
5"L3":"ThefirstpartoftheCADmodelisarectangularprismwithacylindricalholeinthecenterandfourcircularcutoutsonthetopsurface\.BeginbycreatinganewcoordinatesystemwithEuleranglesof\[0\.0,0\.0,0\.0\]andatranslationvectorof\[0\.0,0\.0,0\.0\]\.Inthefirst2Dsketch,drawarectanglebycreatingfourlineswiththefollowingendpoints:\*Line1:\[0\.0,0\.0\]and\[0\.3,0\.0\]\*Line2:\[0\.3,0\.0\]and\[0\.3,0\.3\]\.\.\.\.\.\."
6\}
Listing 2A representative sample of CADFusion’s description structures\. It can be seen that the descriptions from L0 to L3 become increasingly detailed\. The description of L3 is quite detailed, involving multiple curves and instructions for Boolean operations\. Due to the excessive amount of content, it has been omitted for the time being\.In the text\-to\-CAD generation task, the format and granularity of the input text description have a significant impact on the learning efficiency and generation quality of the model\. The description structures of the two datasets we selected follow the following rules\.
CADFusion adopts a three\-stage structured description paradigm, dividing the text expression of the CAD model into three levels:\(1\) Shape Overview, which is used to describe the overall geometric configuration and macroscopic features;\(2\) Shape Details, covering specific geometric attributes such as size ratios, component quantities, and spatial arrangement;\(3\) Shape Applications, which clarify the potential functions or usage scenarios of this shape\. As shown in[Listing˜1](https://arxiv.org/html/2608.05714#listing1), Shape Overview is a mandatory part, while the details and applications parts can be selected flexibly according to the complexity of the model\.
Text2CAD establishes a four\-level progressive description system, as shown in[Listing˜2](https://arxiv.org/html/2608.05714#listing2), dividing the information granularity and professional level from simple to complex into four grades:
- •L0 \(Abstract Level\):It automatically describes the overall shape of the CAD model from a visual perspective, focusing on category generalization\.
- •L1 \(Beginner Level\):It simplifies the description of design steps using non\-professional terms, avoiding complex parameters and measurement information, suitable for preliminary design or non\-professional users\.
- •L2 \(Intermediate Level\):While maintaining readability, introduces generalized descriptions of geometric shapes, balancing technical accuracy and expression universality\.
- •L3 \(Expert Level\):Provides precise geometric parameters and relative measurement information, including numerical descriptions such as coordinates, dimensions, and directions, meeting the refined modeling needs of professional designers\.
Considering that user descriptions in actual CAD design scenarios typically focus on high\-level semantics such as part functionality, structural features, and overall geometric attributes, it is difficult to accurately specify the specific geometric parameters corresponding to each edge and arc\. Moreover, due to the different construction of CAD code sequences, when converting the Text2CAD dataset, we mainly consider the L2 level description\.
Figure 5:A representative sample of CAD code and its corresponding descriptions\. The upper and middle areas respectively represent the descriptions of CADFusion and Text2CAD\. The lower left area represents the CAD code sequence, where all types of tokens are distinguished by different colors\. All of them correspond to the same CAD model, which is displayed in the lower right corner\.
## Appendix BCAD Code
To achieve the structured modeling and editability of CAD models, this paper adopts a serialized representation format based on "Sketch\-and\-Extrude"\. This sequence rule is derived from SkexGen and is further standardized by CADFusion into a unified textual CAD language\. Each CAD instance is composed of several sketches \(Sketch\) and extrusion operations in the order of design history\. The specific coding rules are as follows:
- •Topological Tokens:Topological Tokens are used to identify the basic geometric elements in 2D sketches, including three categories:\{line,arc,circle\}\\\{\\texttt\{line\},\\texttt\{arc\},\\texttt\{circle\}\\\}, representing line primitive, arc primitive, and circle primitive, respectively\.
- •Topological Parameter Tokens:Each type of Topological Token must be followed by a different number of coordinate parameters, in the following format: \(1\)line,x0,y0\\texttt\{line\},x\_\{0\},y\_\{0\}; \(2\)arc,x0,y0,x1,y1\\texttt\{arc\},x\_\{0\},y\_\{0\},x\_\{1\},y\_\{1\}; \(3\)circle,x0,y0,x1,y1,x2,y2,x3,y3\\texttt\{circle\},x\_\{0\},y\_\{0\},x\_\{1\},y\_\{1\},x\_\{2\},y\_\{2\},x\_\{3\},y\_\{3\}\. Among these,xxandyyrepresent the horizontal and vertical coordinates, respectively, and\(x0,y0\)\(x\_\{0\},y\_\{0\}\)represents the starting point coordinates of the curve\.
- •Extrusion Tokens:Extrusion Tokens are used to define the types of volume operations in 3D modeling, including three types of Boolean operations:\{add,cut,intersect\}\\\{\\texttt\{add\},\\texttt\{cut\},\\texttt\{intersect\}\\\}, representing adding the new entity to the existing entity \(which can be empty\), cutting the corresponding entity from the existing entity, and intersecting the new entity with the existing entity, respectively\.
- •Extrusion Parameter Tokens:Each type of Extrusion Token must be followed by a total of 17 numerical parameters, which are organized in order as follows: \(1\) Parameters 1–2:ext\_vext\\\_v\(extrusion height on the upper and lower planes\); \(2\) Parameters 3\-5:ext\_Text\\\_T\(3D extrusion translation vector\); \(3\) Parameters 6\-14:ext\_Rext\\\_R\(3\*3 rotation matrix\); \(4\) Parameter 15:scale\_quanscale\\\_quan\(quantized value of the normalized scale\); \(5\) Parameters 16\-17:offset\_quanoffset\\\_quan\(quantized value of the center offset\)\.
- •Hierarchical End Tokens:To clearly define the multi\-level nested boundaries of the CAD structure, the following Hierarchical End Tokens are defined:\{\\\{<curve\_end\>,\\texttt\{<curve\\\_end\>\},<loop\_end\>,\\texttt\{<loop\\\_end\>\},<face\_end\>,\\texttt\{<face\\\_end\>\},<sketch\_end\>,\\texttt\{<sketch\\\_end\>\},<extrude\_end\>\}\\\}, marking the end of the current curve, loop, face, sketch, and extrusion, respectively\.
Among them, each Topological Parameter Token only defines the starting point of the Topological Token and the intermediate control points along the path, while the coordinate of the endpoint is implicitly determined by the starting point of the next curve\. When it is necessary to close the current loop, the endpoint of the last curve points back to the starting point of the first curve in the loop, thus achieving the closure of the loop\. For sketches, each sketch is composed of multiple faces, and each face contains one or more loops\. The first loop defines the external boundary, and subsequent loops define the internal holes\. This hierarchical constraint ensures that the generated CAD sequence is geometrically and topologically legally closed\. All coordinate parameters and continuous parameters are uniformly quantized into 6\-bit discrete Tokens \(with a total of 64 possible values\), enabling the entire CAD sequence to be input into the LLM in a unified text Token form for processing\.
## Appendix CPrompt
### CCB Prompt
1Belowisadescriptionofa3Dshape:
2\{Description\}
3GenerateaComputer\-AidedDesign\(CAD\)commandsequenceofthe3Dshape:
4\{Ground\_Truth\_Code\[:i\]\}
Listing 3Prompt of the SFT training format\. The model receives the full description and partial code sequence as input, while the loss is computed only on the next tokens \(the part after the prompt\)\.As the first training stage of RA\-CAD, CCB initializes the agent’s parametric CAD coding ability through supervised fine\-tuning\. The SFT prompt format is shown in[Listing˜3](https://arxiv.org/html/2608.05714#listing3)\. Each training sample is an instruction\-style prompt that first presents the natural\-language description of the target shape and then requests the corresponding CAD command sequence\. To train the model in a next\-token prediction manner, the prompt is constructed with only the firstiitokens of the ground\-truth code \(Ground\_Truth\_Code\[:i\]\), and the cross\-entropy loss is computed exclusively on the subsequent tokens that follow the prompt\. This formulation teaches the model to continue a partially generated CAD sequence rather than to re\-predict the prefix it has already observed\. At the same time, all training samples share the same description format and the same token\-level CAD code used in the subsequent FAO stage\.
### FAO Prompt
1"system":"
2YouareaprofessionalCADcodegenerationexpert,usingtokensequencestorepresentCADmodels\.
3Basedontheuser’sdescriptionoftheCADmodel,directlygenerateavalidtokensequence\.Strictlyadheretothecontinuouscontourandhierarchicalstructure\.
4",
5"user":"
6Belowisadescriptionofa3Dshape:
7\{Description\}
8GenerateaComputer\-AidedDesign\(CAD\)commandsequenceofthe3Dshape:
9"
Listing 4Prompt of the Generation module\.1"system":"
2YouareaprofessionalCADcoderegenerationexpert,usingtokensequencestorepresentCADmodels\.
3RewritetheCADcodesequencebasedonthefeedback\.
4Pleasefixtheissuesinthecodeandgenerateacorrectcompactformatsequence\.
5",
6"user":"
7Belowisadescriptionofa3Dshape:
8\{Description\}
9Originalcode:
10\{Code\}
11Executionresult:
12\{Execution\}
13Feedback:
14\{Feedback\}
15PleaseregenerateaComputer\-AidedDesign\(CAD\)commandsequenceofthe3Dshape:
16"
Listing 5Prompt of the Rewriting module\.1Input:
2\{CAD\_Code\}
3
4Output \- Success:
5Codeexecutedsuccessfully\.Thegeneratedmodelisstructurallysound\.
6Validationpassed\-\{L\}token\(s\),\{I\}sketch/extrudepair\(s\),
7\{J\}face\(s\),\{K\}loop\(s\),\{H\}curve\(s\)
8
9Output \- Failure:
10Codeexecutionfailedwitherror:Cannotbeparsedorrenderedintoanactual3Dmodel\.
11Found\{N\}error\(s\):
121\.Sketch\-Extrude\{i\}Face\{j\}Loop\{k\}Curve\{h\}:\{specificerror\}
132\.\.\.\.
Listing 6Execution module\. The execution module returns either a success message with structural validation statistics, or a failure message containing the exact error location and description\.1"system":"
2YouareaCADcodecritiqueexpertwhopaysgreatattentiontodetailsofthefollowingtokensthatrepresentCADmodels\.
3Token types:
41\)Topologicaltokens:line,arc,circle
52\)Extrusiontokens:add,cut,intersect
63\)Hierarchicalendtokens:<curve\_end\>,<loop\_end\>,<face\_end\>,<sketch\_end\>,<extrude\_end\>
7PleasereviewthecurrentCADcodeitembyitemfromthefollowingthreedimensions:
81\. Program Executability
9\-CanthecodebecompiledandrunwithouterrorsthroughtheCADexecutionenvironment?
10\-Iftheexecutionfails,whatisthespecificerrortypeandonwhichline/parameterdidtheerroroccur?
112\. Design Intent Consistency
12\-DoesthegeneratedCADmodelfullycoverallgeometricfeaturesandfunctionalrequirementsinthedesigndescription?
13\-Arethefeatures\(stretch,rotation,hole,chamfer,array,etc\.\)appearinginthecorrectpositionandsize?
14\-Arethereanymissingorredundantfeaturesthatdonotconformtothedesigndescription?
153\. Geometric Reasonability
16\-Istheoverallscaleofthemodelcoordinated?Isthereaclearlyunreasonableaspectratioorwallthickness?
17\-Arethereanyunexpectedintersections,penetrations,orgapsbetweengeometricentities?
18\-Istheredegenerategeometry\(zerovolume,coplanarity,selfintersection,etc\.\)?
19\#\#\#Output Format\#\#\#
20Youalwaysfirstperformyourvalidationreasoningbywrappingyouranalysisin<think\>and</think\>\.Inyourreasoning,examinethecodeitembyitemagainstthespecificationandtheexecutionresult\.
21Aftercompletingyourreasoning,provideyourfinalvalidationresultwithin<result\>and</result\>tags:
22\-Iferrorsarefound:Abulletedlistofspecificissues,eachonanewline\.
23\-Ifnoerrorsarefound:Theexactphrase"THE CODE IS CORRECT"\.
24",
25"user":"
26CADdescription:
27\{Description\}
28Generatedcode:
29\{Code\}
30Executionresult:
31\{Execution\}
32"
Listing 7Prompt of the Critique module\.During the FAO stage, the agent is organized as a Generate–Execute–Critique–Rewrite loop, in which each module is driven by a dedicated role\-specific prompt\. The Generation module, as shown in[Listing˜4](https://arxiv.org/html/2608.05714#listing4), is instructed as a professional CAD code generation expert and is required to directly produce a valid token sequence while strictly adhering to the continuous contour and hierarchical structure of the CAD language\. The Rewriting module, as shown in[Listing˜5](https://arxiv.org/html/2608.05714#listing5), is prompted as a professional CAD code regeneration expert and takes the description, the original code, the execution result, and the critique feedback as input, with the instruction to fix the identified issues and regenerate a correct and compact sequence\. The Execution module acts as the bridge between the agent and the CAD environment\. As shown in[Listing˜6](https://arxiv.org/html/2608.05714#listing6), it receives the CAD code generated or rewritten by the Generation/Rewriting modules, parses the token sequence, validates the hierarchical structure, and instantiates the corresponding 3D model\. When execution succeeds, it returns a success message together with the structural validation statistics, including the total number of tokens, sketch/extrude pairs, faces, loops, and curves\. When execution fails, it returns a failure message and reports the specific error location, such as the affected Sketch\-Extrude, Face, Loop, and Curve indices, so that the agent can identify exactly where the problem occurred\. The Critique module receives the CAD description, the generated code, and its execution result\. As shown in[Listing˜7](https://arxiv.org/html/2608.05714#listing7), its system prompt enumerates the topological tokens, extrusion tokens, and hierarchical end tokens of the CAD representation, and asks the model to review the code item by item along three dimensions: program executability, design intent consistency, and geometric reasonability\. Its output format requires the model to first perform validation reasoning and then return a structured verdict, which standardizes the feedback consumed by the subsequent module\. The same prompts are reused consistently throughout FAO training and inference\. During GRPO, each complete interaction trajectory is produced by rolling out these four modules in turn against the real CAD execution environment, and all policy\-generated code and critique tokens are jointly optimized under terminal F1 and Chamfer Distance rewards\. The role prompts thus provide a stable interface between the environment, the critique decision, and the rewrite, ensuring that the policy learns to turn execution feedback into explicit corrective actions rather than relying on fixed or unoptimized textual guidance\.
### Few\-shot Prompt
1Belowisadescriptionofa3Dshape:
2\{Description\}
3GenerateaComputer\-AidedDesign\(CAD\)commandsequenceofthe3Dshape\.Thecommandsequenceinvolvessketchessuchaslines,arcs,andcircles,eachmarkedbytheendpoints,andextrusionsthatmakethesketchinto3Dvolumes\.
4Herearesomeexamplesandtheirvaluerangeis0\-63
51\.Description:\{Description\[0\]\},CADCommandSequence:\{Ground\_Truth\_Code\[0\]\}
62\.Description:\{Description\[1\]\},CADCommandSequence:\{Ground\_Truth\_Code\[1\]\}
73\.Description:\{Description\[2\]\},CADCommandSequence:\{Ground\_Truth\_Code\[2\]\}
84\.Description:\{Description\[3\]\},CADCommandSequence:\{Ground\_Truth\_Code\[3\]\}
95\.Description:\{Description\[4\]\},CADCommandSequence:\{Ground\_Truth\_Code\[4\]\}
106\.Description:\{Description\[5\]\},CADCommandSequence:\{Ground\_Truth\_Code\[5\]\}
117\.Description:\{Description\[6\]\},CADCommandSequence:\{Ground\_Truth\_Code\[6\]\}
128\.Description:\{Description\[7\]\},CADCommandSequence:\{Ground\_Truth\_Code\[7\]\}
13Nowit’syourturn\.Remindthatthisisyourdescription:\{Description\}\.
14Noexplanationisneeded\.Onlyreturnyourfinalsequence,andinoneline\.
Listing 8Prompt of the few\-shot\. For different datasets, we respectively selected 8 distinct samples as the few\-shot examples\.To evaluate RA\-CAD against strong proprietary language models under a fair and reproducible protocol, we use the few\-shot prompt shown in[Listing˜8](https://arxiv.org/html/2608.05714#listing8)for all closed\-source baselines\. The prompt first states the task of generating a CAD command sequence from a shape description and briefly explains the structure of the sequence, namely sketches composed of lines, arcs, and circles together with the extrusions that turn a sketch into a 3D volume\. It then provides eight complete description\-code demonstration pairs and explicitly indicates that the tokenized values range from 0 to 63, which corresponds to the 6\-bit quantization of all coordinate and continuous parameters\. Finally, the model is asked to generate the sequence for the target description without providing any explanation and to return only the final sequence in a single line\.
Considering that there are differences in the description methods between the CADFusion and Text2CAD datasets, we selected 8 representative samples from each of the two datasets as the few\-shot examples, as shown in[Table˜4](https://arxiv.org/html/2608.05714#A3.T4)and[Table˜5](https://arxiv.org/html/2608.05714#A3.T5)respectively\. When selecting, we took into account the difficulty gradient and structural complexity of the samples, and ensured that the examples covered as many diverse types of CAD tokens as possible, thereby more comprehensively reflecting the generation characteristics of the corresponding datasets\.
Table 4:Few\-shot samples from the CADFusion dataset\. We used the descriptions and true values of these eight samples as the input for the closed\-source model for its reasoning\.Table 5:Few\-shot samples from the Text2CAD dataset\. We used the descriptions and true values of these eight samples as the input for the closed\-source model for its reasoning\.Figure 6:The text\-to\-CAD generation process case\. The first loop model is missing a cylinder, while the second loop adds the circle feature for correction\.
## Appendix DImplementation Details
The FAO stage is implemented with the verl framework on a single node with two GPUs, and the agent is initialized from Meta\-Llama\-3\-8B\-Instruct\. Rollouts are generated with the asynchronous vLLM engine at a temperature of 0\.7, samplingn=8n=8candidate trajectories per prompt; prompts and per\-turn responses are capped at 512 and 1,024 tokens, respectively, and truncation is disabled so that any over\-length sequence raises an error instead of being silently cut\. Since the agent operates as a Generate–Execute–Critique–Rewrite loop, multi\-turn rollouts use the Hermes tool\-calling format, which allows each module’s structured output to be parsed and routed through the CAD execution environment\. Each training step samples 16 prompts \(128 trajectories in total\), with a mini\-batch size of 8 and a micro\-batch size of 4 per GPU\. The policy and reference models are trained with FSDP and parameter offloading; gradient checkpointing is enabled, and the reference model is kept frozen for computing reference log probabilities\. GRPO is applied with group\-normalized advantages, a fixed KL penalty with coefficient 0\.001 incorporated into the reward, policy clipping ratios of 0\.2 and 0\.3, and a learning rate of10−610^\{\-6\}, for a single epoch over the training prompts\.
As for the assessment, generated CAD sequences are first parsed into sketch\-and\-extrude operations using the same 6\-bit quantization as training, where each quantized valueqqis dequantized as
x^=q⋅\(max−min\)/\(26−1\)\+min,\\hat\{x\}=q\\cdot\(\\max\-\\min\)/\(2^\{6\}\-1\)\+\\min,with sketch coordinates in\[−1,1\]\[\-1,1\], extrusion heights and translations in\[−1,1\]\[\-1,1\], scale in\[0,1\.4\]\[0,1\.4\], and center offset in\[−0\.9,0\.9\]\[\-0\.9,0\.9\]\. A sequence is counted as valid only if it parses into a consistent sequence of sketches and extrusions, passes the structural checks of the parser \(correct token counts, closed loops, non\-degenerate curves, and valid Boolean operations\), and can be rendered through the CAD execution environment\. The invalidity ratio is computed as
IR=\(1−Nvalid/Ntotal\)×100%\.IR=\(1\-N\_\{\\text\{valid\}\}/N\_\{\\text\{total\}\}\)\\times 100\\%\.For geometric evaluation, 2,000 points are sampled from the surface of each rendered mesh \(downsampled from denser point clouds when necessary\) and normalized by the maximum absolute coordinate\. The Chamfer distance between a generated point cloudPPand its ground\-truth point cloudQQis defined as
CD\(P,Q\)=1\|P\|∑p∈Pminq∈Q‖p−q‖22\+1\|Q\|∑q∈Qminp∈P‖p−q‖22CD\(P,Q\)=\\frac\{1\}\{\|P\|\}\\sum\_\{p\\in P\}\\min\_\{q\\in Q\}\\\|p\-q\\\|\_\{2\}^\{2\}\+\\frac\{1\}\{\|Q\|\}\\sum\_\{q\\in Q\}\\min\_\{p\\in P\}\\\|p\-q\\\|\_\{2\}^\{2\}and the reported Avg CD is the mean of the diagonal entries of the pairwise distance matrix, i\.e\., each generated model is compared only with its corresponding ground\-truth model\. For sequence\-level accuracy, F1 scores are computed per primitive type \(line, arc, and circle\) within each sketch\-extrude segment: for typett, with occurrence countsctgtc\_\{t\}^\{\\text\{gt\}\}andctpredc\_\{t\}^\{\\text\{pred\}\},
mt=min\(ctgt,ctpred\),m\_\{t\}=\\min\(c\_\{t\}^\{\\text\{gt\}\},c\_\{t\}^\{\\text\{pred\}\}\),Precisiont=mt/ctpred,\\text\{Precision\}\_\{t\}=m\_\{t\}/c\_\{t\}^\{\\text\{pred\}\},Recallt=mt/ctgt,\\text\{Recall\}\_\{t\}=m\_\{t\}/c\_\{t\}^\{\\text\{gt\}\},F1t=2⋅Precisiont⋅Recallt/\(Precisiont\+Recallt\),F1\_\{t\}=2\\cdot\\text\{Precision\}\_\{t\}\\cdot\\text\{Recall\}\_\{t\}/\(\\text\{Precision\}\_\{t\}\+\\text\{Recall\}\_\{t\}\),where per\-type scores are averaged over the evaluated samples, and Avg F1 is the mean of the line, arc, and circle F1 scores\. The same pipeline additionally computes the Jensen–Shannon divergence \(JSD\) between the per\-cell occupancy probabilities of the generated and ground\-truth point clouds on a28×28×2828\\times 28\\times 28grid in the unit cube\.
## Appendix ECase Studies
Figure 7:The text\-to\-CAD generation process case\. The first loop fails execution due to an arc with duplicate points, the second loop executes but forms a curved triangle rather than a ring, and the third loop correctly builds the shape from two concentric arcs and two straight sides\.Figure 8:Qualitative comparison of baseline methods and different LLM variants under different training policies\. Non\-executable outputs are marked\.We further provide qualitative case studies to illustrate how RA\-CAD improves CAD code in the closed\-loop Generate–Execute–Critique–Rewrite paradigm using execution feedback and explicit critique\.[Figure˜6](https://arxiv.org/html/2608.05714#A3.F6)and[Figure˜7](https://arxiv.org/html/2608.05714#A5.F7)show the text\-to\-CAD generation process: the first process shows how RA\-CAD corrects a missing structural feature through feedback\-driven rewriting, while the second process shows how RA\-CAD leverages the detailed failure messages returned by the CAD execution environment to locate and repair errors\.
[Figure˜8](https://arxiv.org/html/2608.05714#A5.F8)further presents qualitative comparisons of the final outputs on several representative cases\. Compared with strong proprietary models \(DeepSeek\-V4\-Flash, Qwen3\.7\-Flash, GLM\-5\.2, Kimi\-K2\.6\-Pro, and GPT\-4o\) and existing methods \(Text2CAD and CADFusion\), RA\-CAD best preserves the requested structures and geometric relations while remaining executable, whereas most baselines produce non\-executable or geometrically inconsistent outputs\.
## Appendix FLimitations and Future Work
Despite the promising results, RA\-CAD has several limitations\. First, it currently takes only a natural\-language description as input, and direct visual conditioning on images, sketches, or point clouds is not supported, which limits its applicability to reverse engineering and visually grounded editing tasks\. Second, the code space is restricted to the sketch\-and\-extrude DSL used by the training datasets, i\.e\., line, arc, and circle primitives with add/cut/intersect operations and 6\-bit quantized parameters\. Uncommon industrial operations, as well as continuous\-parameter precision, are not covered, so generalization to broader CAD code spaces remains an open problem\.
In future work, we plan to extend RA\-CAD to multimodal inputs and interactive user feedback, enabling the agent to condition on images, sketches, or point clouds and to incorporate user edits during the design session\. We will broaden the supported CAD code space to more diverse operations and finer quantization, and adapt the framework to additional execution environments and datasets\.Similar Articles
PR-CAD: Progressive Refinement for Unified Controllable and Faithful Text-to-CAD Generation with Large Language Models
PR-CAD introduces a unified framework using LLMs for iterative text-to-CAD generation and editing, achieving state-of-the-art controllability and faithfulness via reinforcement learning and a curated high-fidelity dataset.
Self-Improving CAD Generation Agents with Finite Element Analysis as Feedback
This paper introduces a new task formulation for CAD generation that incorporates finite element analysis as feedback, along with improved supervision signals like a text-only blueprint schema and multi-view image renderer, leading to better geometric reconstruction on benchmarks.
Memory-Augmented Reinforcement Learning Agent for CAD Generation
This paper proposes a memory-augmented reinforcement learning framework for CAD generation agents that integrates geometric kernel toolchains, dual-track memory, and dynamic utility retrieval to handle complex CAD models with long operation sequences and geometric constraints, achieving improved success rate and geometric consistency.
ArtisanCAD: An Industrial-Level CAD Agent with Expert-Grounded Knowledge Distillation
ArtisanCAD is a skill-guided industrial CAD agent that uses expert-grounded knowledge distillation to convert ambiguous prompts into executable CAD procedures, improving performance on the Text2CAD benchmark and enabling editable B-Rep models for complex automotive components.
TraceCAD: Trace-Guided Repair for Agentic CAD Generation
TraceCAD is a persistent recovery layer for LLM-based CAD agents, diagnosing faulty operations and performing localized, reusable repairs to improve final geometric quality and repair reliability.