chenhanqi commited on
Commit
4cc46c4
·
1 Parent(s): 5294344

Improve SVGThinker model card and add MIT license

Browse files
Files changed (2) hide show
  1. LICENSE +21 -0
  2. README.md +103 -166
LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ MIT License
2
+
3
+ Copyright (c) 2025 SVGThinker authors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
README.md CHANGED
@@ -4,199 +4,136 @@ language:
4
  - en
5
  base_model:
6
  - deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
 
 
7
  pipeline_tag: text-generation
 
 
 
 
 
 
 
 
 
 
 
 
 
8
  ---
9
- # Model Card for Model ID
10
 
11
- <!-- Provide a quick summary of what the model is/does. -->
12
 
13
- This modelcard aims to be a base template for new models. It has been generated using [this raw template](https://github.com/huggingface/huggingface_hub/blob/main/src/huggingface_hub/templates/modelcard_template.md?plain=1).
 
 
 
14
 
15
- ## Model Details
 
 
16
 
17
- ### Model Description
18
 
19
- <!-- Provide a longer summary of what this model is. -->
 
 
20
 
 
21
 
 
22
 
23
- - **Developed by:** [More Information Needed]
24
- - **Funded by [optional]:** [More Information Needed]
25
- - **Shared by [optional]:** [More Information Needed]
26
- - **Model type:** [More Information Needed]
27
- - **Language(s) (NLP):** [More Information Needed]
28
- - **License:** [More Information Needed]
29
- - **Finetuned from model [optional]:** [More Information Needed]
30
 
31
- ### Model Sources [optional]
 
32
 
33
- <!-- Provide the basic links for the model. -->
34
 
35
- - **Repository:** [More Information Needed]
36
- - **Paper [optional]:** [More Information Needed]
37
- - **Demo [optional]:** [More Information Needed]
38
 
39
- ## Uses
 
 
 
40
 
41
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
42
 
43
- ### Direct Use
 
 
 
 
 
 
44
 
45
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
 
46
 
47
- [More Information Needed]
 
 
 
 
 
48
 
49
- ### Downstream Use [optional]
 
 
 
 
 
 
 
 
50
 
51
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
 
 
 
52
 
53
- [More Information Needed]
 
54
 
55
- ### Out-of-Scope Use
56
 
57
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
 
 
58
 
59
- [More Information Needed]
60
 
61
- ## Bias, Risks, and Limitations
62
 
63
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
64
 
65
- [More Information Needed]
 
 
66
 
67
- ### Recommendations
68
 
69
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
 
 
 
 
70
 
71
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
72
-
73
- ## How to Get Started with the Model
74
-
75
- Use the code below to get started with the model.
76
-
77
- [More Information Needed]
78
-
79
- ## Training Details
80
-
81
- ### Training Data
82
-
83
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
84
-
85
- [More Information Needed]
86
-
87
- ### Training Procedure
88
-
89
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
90
-
91
- #### Preprocessing [optional]
92
-
93
- [More Information Needed]
94
-
95
-
96
- #### Training Hyperparameters
97
-
98
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
99
-
100
- #### Speeds, Sizes, Times [optional]
101
-
102
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
103
-
104
- [More Information Needed]
105
-
106
- ## Evaluation
107
-
108
- <!-- This section describes the evaluation protocols and provides the results. -->
109
-
110
- ### Testing Data, Factors & Metrics
111
-
112
- #### Testing Data
113
-
114
- <!-- This should link to a Dataset Card if possible. -->
115
-
116
- [More Information Needed]
117
-
118
- #### Factors
119
-
120
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
121
-
122
- [More Information Needed]
123
-
124
- #### Metrics
125
-
126
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
127
-
128
- [More Information Needed]
129
-
130
- ### Results
131
-
132
- [More Information Needed]
133
-
134
- #### Summary
135
-
136
-
137
-
138
- ## Model Examination [optional]
139
-
140
- <!-- Relevant interpretability work for the model goes here -->
141
-
142
- [More Information Needed]
143
-
144
- ## Environmental Impact
145
-
146
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
147
-
148
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
149
-
150
- - **Hardware Type:** [More Information Needed]
151
- - **Hours used:** [More Information Needed]
152
- - **Cloud Provider:** [More Information Needed]
153
- - **Compute Region:** [More Information Needed]
154
- - **Carbon Emitted:** [More Information Needed]
155
-
156
- ## Technical Specifications [optional]
157
-
158
- ### Model Architecture and Objective
159
-
160
- [More Information Needed]
161
-
162
- ### Compute Infrastructure
163
-
164
- [More Information Needed]
165
-
166
- #### Hardware
167
-
168
- [More Information Needed]
169
-
170
- #### Software
171
-
172
- [More Information Needed]
173
-
174
- ## Citation [optional]
175
-
176
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
177
-
178
- **BibTeX:**
179
-
180
- [More Information Needed]
181
-
182
- **APA:**
183
-
184
- [More Information Needed]
185
-
186
- ## Glossary [optional]
187
-
188
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
189
-
190
- [More Information Needed]
191
-
192
- ## More Information [optional]
193
-
194
- [More Information Needed]
195
-
196
- ## Model Card Authors [optional]
197
-
198
- [More Information Needed]
199
-
200
- ## Model Card Contact
201
-
202
- [More Information Needed]
 
4
  - en
5
  base_model:
6
  - deepseek-ai/DeepSeek-R1-Distill-Qwen-7B
7
+ base_model_relation: finetune
8
+ library_name: transformers
9
  pipeline_tag: text-generation
10
+ tags:
11
+ - svg
12
+ - text-to-svg
13
+ - vector-graphics
14
+ - code-generation
15
+ - reasoning
16
+ - qwen2
17
+ - safetensors
18
+ - arxiv:2509.24299
19
+ widget:
20
+ - text: "Generate an SVG icon of a yellow rubber duck facing right on a shallow blue oval of water."
21
+ - text: "Generate a minimalist calendar icon with a checkmark below it."
22
+ - text: "Generate a flat vector icon of a delivery truck using bold solid colors."
23
  ---
 
24
 
25
+ # SVGThinker-7B
26
 
27
+ SVGThinker-7B is a text-to-SVG generation model introduced in
28
+ [SVGThinker: Instruction-Aligned and Reasoning-Driven Text-to-SVG Generation](https://arxiv.org/abs/2509.24299).
29
+ It generates editable SVG code from natural-language descriptions, with a focus on
30
+ compact icon-style vector graphics.
31
 
32
+ The model is fine-tuned from
33
+ [`deepseek-ai/DeepSeek-R1-Distill-Qwen-7B`](https://huggingface.co/deepseek-ai/DeepSeek-R1-Distill-Qwen-7B)
34
+ and is released as BF16 sharded safetensors.
35
 
36
+ ## Links
37
 
38
+ - Paper: [arXiv:2509.24299](https://arxiv.org/abs/2509.24299)
39
+ - Demo Space: [Caffin/SVGThinker-7B](https://huggingface.co/spaces/Caffin/SVGThinker-7B)
40
+ - License: MIT
41
 
42
+ ## Intended Use
43
 
44
+ This model is intended for:
45
 
46
+ - generating SVG icons from English text prompts
47
+ - prototyping simple vector graphics
48
+ - producing editable SVG markup rather than raster images
49
+ - research on text-to-SVG and structured code generation
 
 
 
50
 
51
+ Generated SVG should be reviewed and sanitized before being rendered in production
52
+ web pages or downstream applications.
53
 
54
+ ## Quick Start
55
 
56
+ ```bash
57
+ pip install "transformers>=4.51.0" torch accelerate safetensors
58
+ ```
59
 
60
+ ```python
61
+ import re
62
+ import torch
63
+ from transformers import AutoModelForCausalLM, AutoTokenizer
64
 
65
+ model_id = "Caffin/SVGThinker-7B"
66
 
67
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
68
+ model = AutoModelForCausalLM.from_pretrained(
69
+ model_id,
70
+ torch_dtype=torch.bfloat16,
71
+ device_map="auto",
72
+ use_safetensors=True,
73
+ )
74
 
75
+ description = "A minimalist calendar icon with two black tabs and a bold checkmark below it."
76
+ prompt = "Review the given information below and generate a svg according to it.\n" + description
77
 
78
+ messages = [{"role": "user", "content": prompt}]
79
+ inputs = tokenizer.apply_chat_template(
80
+ messages,
81
+ add_generation_prompt=True,
82
+ return_tensors="pt",
83
+ ).to(model.device)
84
 
85
+ with torch.no_grad():
86
+ output = model.generate(
87
+ inputs,
88
+ max_new_tokens=4096,
89
+ do_sample=True,
90
+ temperature=0.8,
91
+ top_p=0.6,
92
+ repetition_penalty=1.05,
93
+ )
94
 
95
+ text = tokenizer.decode(output[0], skip_special_tokens=False)
96
+ match = re.search(r"<svg.*?</svg>", text, flags=re.DOTALL)
97
+ print(match.group(0) if match else text)
98
+ ```
99
 
100
+ The model may emit reasoning text before the final SVG. For most applications,
101
+ extract the `<svg>...</svg>` block before rendering.
102
 
103
+ ## Model Notes
104
 
105
+ SVGThinker is trained directly in SVG code space. The paper describes a sequential
106
+ annotation pipeline that aligns natural-language descriptions with the step-by-step
107
+ construction of SVG primitives, helping the model generate more editable SVG code.
108
 
109
+ For full training data, annotation, and evaluation details, see the paper.
110
 
111
+ ## Evaluation Snapshot
112
 
113
+ On the paper's 1,000 held-out text-to-SVG prompts, SVGThinker reports:
114
 
115
+ | Model | FID lower is better | CLIP higher is better | FID-CLIP lower is better | Primitive support |
116
+ | --- | ---: | ---: | ---: | --- |
117
+ | SVGThinker-7B | 34.06 | 0.2765 | 21.08 | all |
118
 
119
+ ## Limitations
120
 
121
+ - Outputs may be malformed, incomplete, or visually inconsistent with the prompt.
122
+ - The model is best suited for simple to moderately complex icon-style graphics.
123
+ - It may struggle with photorealistic scenes, dense layouts, and text-heavy SVGs.
124
+ - SVG is executable markup in browser contexts; treat generated SVG as untrusted.
125
+ - The model primarily targets English prompts.
126
 
127
+ ## Citation
128
+
129
+ ```bibtex
130
+ @inproceedings{chen2025svgthinker,
131
+ title = {SVGThinker: Instruction-Aligned and Reasoning-Driven Text-to-SVG Generation},
132
+ author = {Chen, Hanqi and Zhao, Zhongyin and Chen, Ye and Liang, Zhujin and Ni, Bingbing},
133
+ booktitle = {Proceedings of the 33rd ACM International Conference on Multimedia},
134
+ year = {2025},
135
+ publisher = {ACM},
136
+ doi = {10.1145/3746027.3755392},
137
+ url = {https://arxiv.org/abs/2509.24299}
138
+ }
139
+ ```