Update README.md
Browse files
README.md
CHANGED
@@ -19,18 +19,40 @@ It has been trained using [TRL](https://github.com/huggingface/trl).
|
|
19 |
## Quick start
|
20 |
|
21 |
```python
|
22 |
-
from transformers import
|
23 |
-
|
24 |
-
model_id = "tyfeng1997/Qwen2.5-1.5B-Open-R1-Distill"
|
25 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda")
|
26 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
{
|
31 |
-
|
32 |
-
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
```
|
35 |
#### output
|
36 |
``` text
|
|
|
19 |
## Quick start
|
20 |
|
21 |
```python
|
22 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
23 |
+
model_id = "tyfeng1997/Qwen2.5-1.5B-Open-R1-Distill" #instruct
|
|
|
24 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda")
|
25 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
26 |
+
|
27 |
+
# Prepare the messages
|
28 |
+
messages = [
|
29 |
+
{
|
30 |
+
"role": "system",
|
31 |
+
"content": """Your role as an assistant involves thoroughly exploring questions through a systematic long thinking process before providing the final precise and accurate solutions. This requires engaging in a comprehensive cycle of analysis, summarizing, exploration, reassessment, reflection, backtracing, and iteration to develop well-considered thinking process. Please structure your response into two main sections: Thought and Solution. In the Thought section, detail your reasoning process using the specified format: <|begin_of_thought|> {thought with steps separated with '\n\n'} <|end_of_thought|> Each step should include detailed considerations such as analisying questions, summarizing relevant findings, brainstorming new ideas, verifying the accuracy of the current steps, refining any errors, and revisiting previous steps. In the Solution section, based on various attempts, explorations, and reflections from the Thought section, systematically present the final solution that you deem correct. The solution should remain a logical, accurate, concise expression style and detail necessary step needed to reach the conclusion, formatted as follows: <|begin_of_solution|> {final formatted, precise, and clear solution} <|end_of_solution|> Now, try to solve the following question through the above guidelines:"""
|
32 |
+
},
|
33 |
+
{
|
34 |
+
"role": "user",
|
35 |
+
"content": """A regular hexagon can be divided into six equilateral triangles. If the perimeter of one of the triangles is 21 inches, what is the perimeter, in inches, of the regular hexagon?"""
|
36 |
+
}
|
37 |
+
]
|
38 |
+
|
39 |
+
# Apply chat template
|
40 |
+
prompt = tokenizer.apply_chat_template(messages, tokenize=False)
|
41 |
+
|
42 |
+
# Tokenize the prompt
|
43 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
44 |
+
|
45 |
+
# Generate
|
46 |
+
outputs = model.generate(
|
47 |
+
inputs.input_ids,
|
48 |
+
max_new_tokens=10000,
|
49 |
+
pad_token_id=tokenizer.pad_token_id,
|
50 |
+
eos_token_id=tokenizer.eos_token_id
|
51 |
+
)
|
52 |
+
|
53 |
+
# Decode and print the response
|
54 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
55 |
+
print(response)
|
56 |
```
|
57 |
#### output
|
58 |
``` text
|