junshim commited on
Commit
a064854
·
verified ·
1 Parent(s): f75a7c6

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +297 -2
README.md CHANGED
@@ -1,6 +1,4 @@
1
  ---
2
- # library_name: when2think
3
- arxiv: 2609.19671
4
  pipeline_tag: text-generation
5
  library_name: transformers
6
  datasets:
@@ -20,3 +18,300 @@ tags:
20
  - reinforcement-learning
21
  - rlvr
22
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
 
 
2
  pipeline_tag: text-generation
3
  library_name: transformers
4
  datasets:
 
18
  - reinforcement-learning
19
  - rlvr
20
  ---
21
+
22
+
23
+ # When2Think
24
+
25
+ <!-- Provide a quick summary of what the model is/does. -->
26
+
27
+ 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).
28
+
29
+ ## Model Details
30
+
31
+ ### Model Description
32
+
33
+ <!-- Provide a longer summary of what this model is. -->
34
+
35
+
36
+
37
+ - **Developed by:** [More Information Needed]
38
+ - **Funded by [optional]:** [More Information Needed]
39
+ - **Shared by [optional]:** [More Information Needed]
40
+ - **Model type:** [More Information Needed]
41
+ - **Language(s) (NLP):** [More Information Needed]
42
+ - **License:** [More Information Needed]
43
+ - **Finetuned from model [optional]:** [More Information Needed]
44
+
45
+ ### Model Sources [optional]
46
+
47
+ <!-- Provide the basic links for the model. -->
48
+
49
+ - **Repository:** [More Information Needed]
50
+ - **Paper [optional]:** [More Information Needed]
51
+ - **Demo [optional]:** [More Information Needed]
52
+
53
+ ## Uses
54
+
55
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
56
+
57
+ ### Direct Use
58
+
59
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
60
+
61
+
62
+
63
+ ```py
64
+ from transformers import pipeline
65
+
66
+ model_path = "junshim/When2Think-1.5B"
67
+
68
+ prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$."
69
+ messages = [
70
+ {"role": "system", "content": "You are a helpful assistant."},
71
+ {"role": "user", "content": prompt}
72
+ ]
73
+
74
+ generator = pipeline(
75
+ "text-generation",
76
+ model=model_path,
77
+ device_map="auto",
78
+ dtype="auto"
79
+ )
80
+ outputs = generator(
81
+ text,
82
+ max_new_tokens=512,
83
+ clean_up_tokenization_spaces=False
84
+ )
85
+ ```
86
+
87
+ ```py
88
+ from accelerate import Accelerator
89
+ from transformers import AutoModelForCausalLM, AutoTokenizer
90
+
91
+ accelerator = Accelerator()
92
+ device = accelerator.device
93
+
94
+ model = AutoModelForCausalLM.from_pretrained(
95
+ model_path,
96
+ torch_dtype="auto",
97
+ device_map=device
98
+ )
99
+ tokenizer = AutoTokenizer.from_pretrained(model_path)
100
+
101
+ print(model.generation_config, device)
102
+ ```
103
+
104
+ ```py
105
+ text = tokenizer.apply_chat_template(
106
+ messages,
107
+ tokenize=False,
108
+ add_generation_prompt=True
109
+ )
110
+ inputs = tokenizer([text], return_tensors="pt").to(device)
111
+
112
+ generated_ids = model.generate(
113
+ **inputs,
114
+ max_new_tokens=512
115
+ )
116
+ output_text = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
117
+ ```
118
+
119
+ ```py
120
+ import re
121
+
122
+ ASSISTANT_RE = re.compile(
123
+ r"<|Assistant|>(.*?)(?=<|User|>|<|end of sentence|>|$)",
124
+ re.DOTALL,
125
+ )
126
+ THINK_RE = re.compile(r"<think>(.*?)</think>", re.DOTALL)
127
+
128
+
129
+ def parse_deepseek_r1(text: str) -> list[dict]:
130
+ dialogue = []
131
+
132
+ for match in ASSISTANT_RE.finditer(text):
133
+ assistant = match.group(1).strip()
134
+ think = THINK_RE.search(assistant)
135
+
136
+ if think:
137
+ reasoning = think.group(1).strip()
138
+ content = (
139
+ assistant[:think.start()] + assistant[think.end():]
140
+ ).strip()
141
+ else:
142
+ reasoning = None
143
+ content = assistant
144
+
145
+ dialogue.append({
146
+ "reasoning": reasoning,
147
+ "content": content,
148
+ })
149
+
150
+ return dialogue
151
+
152
+
153
+ parse_deepseek_r1(output_text)
154
+ ```
155
+
156
+ ### Downstream Use [optional]
157
+
158
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
159
+
160
+ [More Information Needed]
161
+
162
+ ### Out-of-Scope Use
163
+
164
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
165
+
166
+ [More Information Needed]
167
+
168
+ ## Bias, Risks, and Limitations
169
+
170
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
171
+
172
+ [More Information Needed]
173
+
174
+ ### Recommendations
175
+
176
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
177
+
178
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
179
+
180
+ ## How to Get Started with the Model
181
+
182
+ Use the code below to get started with the model.
183
+
184
+ [More Information Needed]
185
+
186
+ ## Training Details
187
+
188
+ ### Training Data
189
+
190
+ <!-- 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. -->
191
+
192
+ [More Information Needed]
193
+
194
+ ### Training Procedure
195
+
196
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
197
+
198
+ #### Preprocessing [optional]
199
+
200
+ [More Information Needed]
201
+
202
+
203
+ #### Training Hyperparameters
204
+
205
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
206
+
207
+ #### Speeds, Sizes, Times [optional]
208
+
209
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
210
+
211
+ [More Information Needed]
212
+
213
+ ## Evaluation
214
+
215
+ <!-- This section describes the evaluation protocols and provides the results. -->
216
+
217
+ ### Testing Data, Factors & Metrics
218
+
219
+ #### Testing Data
220
+
221
+ <!-- This should link to a Dataset Card if possible. -->
222
+
223
+ [More Information Needed]
224
+
225
+ #### Factors
226
+
227
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
228
+
229
+ [More Information Needed]
230
+
231
+ #### Metrics
232
+
233
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
234
+
235
+ [More Information Needed]
236
+
237
+ ### Results
238
+
239
+ [More Information Needed]
240
+
241
+ #### Summary
242
+
243
+
244
+
245
+ ## Model Examination [optional]
246
+
247
+ <!-- Relevant interpretability work for the model goes here -->
248
+
249
+ [More Information Needed]
250
+
251
+ ## Environmental Impact
252
+
253
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
254
+
255
+ 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).
256
+
257
+ - **Hardware Type:** [More Information Needed]
258
+ - **Hours used:** [More Information Needed]
259
+ - **Cloud Provider:** [More Information Needed]
260
+ - **Compute Region:** [More Information Needed]
261
+ - **Carbon Emitted:** [More Information Needed]
262
+
263
+ ## Technical Specifications [optional]
264
+
265
+ ### Model Architecture and Objective
266
+
267
+ [More Information Needed]
268
+
269
+ ### Compute Infrastructure
270
+
271
+ [More Information Needed]
272
+
273
+ #### Hardware
274
+
275
+ [More Information Needed]
276
+
277
+ #### Software
278
+
279
+ [More Information Needed]
280
+
281
+ ## Citation [optional]
282
+
283
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
284
+
285
+ **BibTeX:**
286
+
287
+ ```bibtex
288
+ @misc{shim2026when2thinklearningdifficultyawarelength,
289
+ title = {When2Think: Learning Difficulty-Aware Length Control for Efficient Hybrid Reasoning Models},
290
+ author = {Jaejun Shim and HyunJin Kim and Young Jin Kim and JinYeong Bak},
291
+ year = {2026},
292
+ eprint = {2609.19671},
293
+ url = {https://arxiv.org/abs/2609.19671}
294
+ }
295
+ ```
296
+
297
+ **APA:**
298
+
299
+ [More Information Needed]
300
+
301
+ ## Glossary [optional]
302
+
303
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
304
+
305
+ [More Information Needed]
306
+
307
+ ## More Information [optional]
308
+
309
+ [More Information Needed]
310
+
311
+ ## Model Card Authors [optional]
312
+
313
+ [More Information Needed]
314
+
315
+ ## Model Card Contact
316
+
317
+ [More Information Needed]