gudo7208 commited on
Commit
3c0347b
·
verified ·
1 Parent(s): 14230a6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +23 -18
README.md CHANGED
@@ -17,7 +17,7 @@ library_name: transformers
17
 
18
  **CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward**
19
 
20
- [![arXiv](https://img.shields.io/badge/arXiv-2505.19713-b31b1b.svg)](https://arxiv.org/abs/2505.19713)
21
 
22
  ## Model Description
23
 
@@ -31,9 +31,21 @@ CAD-Coder reformulates text-to-CAD as the generation of CadQuery scripts—a Pyt
31
  - Generates executable CadQuery Python code from natural language
32
  - Chain-of-Thought (CoT) reasoning for complex CAD structures
33
  - Geometric reward optimization for accurate 3D model generation
 
34
 
35
  ## Usage
36
 
 
 
 
 
 
 
 
 
 
 
 
37
  ```python
38
  from transformers import AutoModelForCausalLM, AutoTokenizer
39
 
@@ -41,20 +53,16 @@ model_name = "gudo7208/CAD-Coder"
41
  tokenizer = AutoTokenizer.from_pretrained(model_name)
42
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
43
 
44
- # Example prompt
45
- prompt = """Create a cylinder with radius 10mm and height 20mm, with a central hole of radius 5mm."""
46
-
47
- messages = [
48
- {"role": "system", "content": "You are a helpful assistant."},
49
- {"role": "user", "content": prompt}
50
- ]
51
 
52
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
 
 
 
 
53
  inputs = tokenizer([text], return_tensors="pt").to(model.device)
54
-
55
- outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.8, top_k=20)
56
- response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
57
- print(response)
58
  ```
59
 
60
  ## Performance
@@ -90,8 +98,5 @@ This model is released under the Apache 2.0 License, following the base model (Q
90
 
91
  ## Acknowledgements
92
 
93
- We thank the following works for their contributions:
94
-
95
- - [Qwen2.5](https://github.com/QwenLM/Qwen2.5) - Base model for CAD-Coder
96
- - [Text2CAD](https://github.com/sadilkhan/Text2CAD) - Text-to-CAD dataset and benchmark
97
- - [DeepCAD](https://github.com/ChrisWu1997/DeepCAD) - Pioneering work on deep generative models for CAD
 
17
 
18
  **CAD-Coder: Text-to-CAD Generation with Chain-of-Thought and Geometric Reward**
19
 
20
+ This is the reinforcement learning (GRPO) fine-tuned model for generating CadQuery code from natural language descriptions.
21
 
22
  ## Model Description
23
 
 
31
  - Generates executable CadQuery Python code from natural language
32
  - Chain-of-Thought (CoT) reasoning for complex CAD structures
33
  - Geometric reward optimization for accurate 3D model generation
34
+ - Supports diverse CAD operations beyond simple sketch-extrusion
35
 
36
  ## Usage
37
 
38
+ For complete inference scripts, please visit our [GitHub repository](https://github.com/gudo7208/CAD-Coder).
39
+
40
+ ### Installation
41
+
42
+ ```bash
43
+ pip install transformers
44
+ pip install "numpy<2.0" cadquery==2.3.1 # Optional: for code execution
45
+ ```
46
+
47
+ ### Quick Start
48
+
49
  ```python
50
  from transformers import AutoModelForCausalLM, AutoTokenizer
51
 
 
53
  tokenizer = AutoTokenizer.from_pretrained(model_name)
54
  model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype="auto", device_map="auto")
55
 
56
+ prompt = "Create a cylinder with radius 10mm and height 20mm, with a central hole of radius 5mm."
 
 
 
 
 
 
57
 
58
+ text = tokenizer.apply_chat_template(
59
+ [{"role": "user", "content": prompt}],
60
+ tokenize=False,
61
+ add_generation_prompt=True
62
+ )
63
  inputs = tokenizer([text], return_tensors="pt").to(model.device)
64
+ outputs = model.generate(**inputs, max_new_tokens=2048)
65
+ print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
 
 
66
  ```
67
 
68
  ## Performance
 
98
 
99
  ## Acknowledgements
100
 
101
+ - Base model: [Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct)
102
+ - Training data derived from [Text2CAD](https://github.com/sadilkhan/Text2CAD) dataset