CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward
Paper
•
2505.19713
•
Published
•
2
CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward
Accepted at NeurIPS 2025 (Poster)
This is the reinforcement learning (GRPO) fine-tuned model for generating CadQuery code from natural language descriptions.
CAD-Coder reformulates text-to-CAD as the generation of CadQuery scripts—a Python-based, parametric CAD language. The model is trained with a two-stage pipeline:
For complete inference scripts, please visit our GitHub repository.
pip install transformers
pip install "numpy<2.0" cadquery==2.3.1 # Optional: for code execution
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "gudo7208/CAD-Coder"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
prompt = "Create a cylinder with radius 10mm and height 20mm, with a central hole of radius 5mm."
text = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
tokenize=False,
add_generation_prompt=True
)
inputs = tokenizer([text], return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=2048)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
| Method | Mean CD | Median CD | IR% |
|---|---|---|---|
| Text2CAD | 29.29 | 0.37 | 3.75 |
| CAD-Coder (Ours) | 6.54 | 0.17 | 1.45 |
CD metrics are ×10³. Lower is better.
@article{guan2025cadcoder,
title={CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward},
author={Guan, Yandong and Wang, Xilin and Xing, Ximing and Zhang, Jing and Xu, Dong and Yu, Qian},
journal={arXiv preprint arXiv:2505.19713},
year={2025}
}
This model is released under the Apache 2.0 License, following the base model (Qwen2.5-7B-Instruct) license terms.