sudhanshu746
commited on
Commit
•
b91be4e
1
Parent(s):
8b8fc62
Update README.md
Browse files
README.md
CHANGED
@@ -1,5 +1,77 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
4 |
-
|
5 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
PeFT Fine-tuned on custom data by Sudhanshu Sharma
|
2 |
+
---
|
3 |
+
license: MIT
|
4 |
+
license_name: deepseek
|
5 |
+
license_link: https://github.com/deepseek-ai/DeepSeek-Math/blob/main/LICENSE-MODEL
|
6 |
+
---
|
7 |
+
|
8 |
+
|
9 |
+
<p align="center">
|
10 |
+
<img width="500px" alt="DeepSeek Chat" src="https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/images/logo.png?raw=true">
|
11 |
+
</p>
|
12 |
+
<p align="center"><a href="https://www.deepseek.com/">[🏠Homepage]</a> | <a href="https://chat.deepseek.com/">[🤖 Chat with DeepSeek LLM]</a> | <a href="https://discord.gg/Tc7c45Zzu5">[Discord]</a> | <a href="https://github.com/deepseek-ai/DeepSeek-LLM/blob/main/images/qr.jpeg">[Wechat(微信)]</a> </p>
|
13 |
+
|
14 |
+
<p align="center">
|
15 |
+
<a href="https://arxiv.org/pdf/2402.03300.pdf"><b>Paper Link</b>👁️</a>
|
16 |
+
</p>
|
17 |
+
|
18 |
+
<hr>
|
19 |
+
|
20 |
+
|
21 |
+
|
22 |
+
|
23 |
+
|
24 |
+
### 1. Introduction to DeepSeekMath
|
25 |
+
See the [Introduction](https://github.com/deepseek-ai/DeepSeek-Math) for more details.
|
26 |
+
|
27 |
+
### 2. How to Use
|
28 |
+
Here give some examples of how to use our model.
|
29 |
+
|
30 |
+
**Chat Completion**
|
31 |
+
|
32 |
+
❗❗❗ **Please use chain-of-thought prompt to test DeepSeekMath-Instruct and DeepSeekMath-RL:**
|
33 |
+
|
34 |
+
- English questions: **{question}\nPlease reason step by step, and put your final answer within \\boxed{}.**
|
35 |
+
|
36 |
+
- Chinese questions: **{question}\n请通过逐步推理来解答问题,并把最终答案放置于\\boxed{}中。**
|
37 |
+
|
38 |
+
```python
|
39 |
+
import torch
|
40 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig
|
41 |
+
|
42 |
+
model_name = "deepseek-ai/deepseek-math-7b-instruct"
|
43 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
44 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.bfloat16, device_map="auto")
|
45 |
+
model.generation_config = GenerationConfig.from_pretrained(model_name)
|
46 |
+
model.generation_config.pad_token_id = model.generation_config.eos_token_id
|
47 |
+
|
48 |
+
messages = [
|
49 |
+
{"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{}."}
|
50 |
+
]
|
51 |
+
input_tensor = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt")
|
52 |
+
outputs = model.generate(input_tensor.to(model.device), max_new_tokens=100)
|
53 |
+
|
54 |
+
result = tokenizer.decode(outputs[0][input_tensor.shape[1]:], skip_special_tokens=True)
|
55 |
+
print(result)
|
56 |
+
```
|
57 |
+
|
58 |
+
Avoiding the use of the provided function `apply_chat_template`, you can also interact with our model following the sample template. Note that `messages` should be replaced by your input.
|
59 |
+
|
60 |
+
```
|
61 |
+
User: {messages[0]['content']}
|
62 |
+
|
63 |
+
Assistant: {messages[1]['content']}<|end▁of▁sentence|>User: {messages[2]['content']}
|
64 |
+
|
65 |
+
Assistant:
|
66 |
+
```
|
67 |
+
|
68 |
+
**Note:** By default (`add_special_tokens=True`), our tokenizer automatically adds a `bos_token` (`<|begin▁of▁sentence|>`) before the input text. Additionally, since the system prompt is not compatible with this version of our models, we DO NOT RECOMMEND including the system prompt in your input.
|
69 |
+
|
70 |
+
### 3. License
|
71 |
+
This code repository is licensed under the MIT License. The use of DeepSeekMath models is subject to the Model License. DeepSeekMath supports commercial use.
|
72 |
+
|
73 |
+
See the [LICENSE-MODEL](https://github.com/deepseek-ai/DeepSeek-Math/blob/main/LICENSE-MODEL) for more details.
|
74 |
+
|
75 |
+
### 4. Contact
|
76 |
+
|
77 |
+
If you have any questions, please raise an issue or contact us at [[email protected]](mailto:[email protected]).
|