ZhihongShao
commited on
Commit
•
d16cb8a
1
Parent(s):
dafda4a
Add cot instruction
Browse files
README.md
CHANGED
@@ -28,19 +28,24 @@ Here give some examples of how to use our model.
|
|
28 |
|
29 |
**Chat Completion**
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
|
32 |
```python
|
33 |
import torch
|
34 |
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
35 |
|
36 |
-
model_name = "deepseek-ai/deepseek-math-7b-
|
37 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
38 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
39 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
40 |
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
41 |
|
42 |
messages = [
|
43 |
-
{"role": "user", "content": "what is the integral of x^2 from 0 to 2
|
44 |
]
|
45 |
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
46 |
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|
|
|
28 |
|
29 |
**Chat Completion**
|
30 |
|
31 |
+
❗❗❗ **Please use chain-of-thought prompt to test DeepSeekMath-Instruct and DeepSeekMath-RL:**
|
32 |
+
|
33 |
+
- English questions: **{question}\nPlease reason step by step, and put your final answer within \\boxed{}.**
|
34 |
+
|
35 |
+
- Chinese questions: **{question}\n请通过逐步推理来解答问题,并把最终答案放置于\\boxed{}中。**
|
36 |
|
37 |
```python
|
38 |
import torch
|
39 |
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
40 |
|
41 |
+
model_name = "deepseek-ai/deepseek-math-7b-instruct"
|
42 |
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
43 |
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
44 |
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
45 |
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
46 |
|
47 |
messages = [
|
48 |
+
{"role": "user", "content": "what is the integral of x^2 from 0 to 2?\nPlease reason step by step, and put your final answer within \\boxed{}."}
|
49 |
]
|
50 |
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
51 |
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|