Amyww commited on
Commit
5a874b6
1 Parent(s): e097a40

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +109 -0
README.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: tongyi-qianwen
4
+ license_link: https://huggingface.co/Qwen/Qwen2-Math-72B-Instruct/blob/main/LICENSE
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - chat
10
+ ---
11
+
12
+
13
+ # Qwen2-Math-72B-Instruct
14
+
15
+ > [!Warning]
16
+ > <div align="center">
17
+ > <b>
18
+ > 🚨 Temporarily this model mainly supports English. We will release bilingual (English & Chinese) models soon!
19
+ > </b>
20
+ > </div>
21
+
22
+ ## Introduction
23
+
24
+ Over the past year, we have dedicated significant effort to researching and enhancing the reasoning capabilities of large language models, with a particular focus on their ability to solve arithmetic and mathematical problems. Today, we are delighted to introduce a serise of math-specific large language models of our Qwen2 series, Qwen2-Math and Qwen2-Math-Instruct-1.5B/7B/72B. Qwen2-Math is a series of specialized math language models built upon the Qwen2 LLMs, which significantly outperforms the mathematical capabilities of open-source models and even closed-source models (e.g., GPT4o). We hope that Qwen2-Math can contribute to the scientific community for solving advanced mathematical problems that require complex, multi-step logical reasoning.
25
+
26
+
27
+ ## Model Details
28
+
29
+
30
+ For more details, please refer to our [blog post](https://qwenlm.github.io/blog/qwen2-math/) and [GitHub repo](https://github.com/QwenLM/Qwen2-Math).
31
+
32
+
33
+ ## Requirements
34
+ * `transformers>=4.40.0` for Qwen2-Math models. The latest version is recommended.
35
+
36
+ > [!Warning]
37
+ > <div align="center">
38
+ > <b>
39
+ > 🚨 This is a must because `transformers` integrated Qwen2 codes since `4.37.0`.
40
+ > </b>
41
+ > </div>
42
+
43
+ For requirements on GPU memory and the respective throughput, see similar results of Qwen2 [here](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
44
+
45
+ ## Quick Start
46
+
47
+ > [!Important]
48
+ >
49
+ > **Qwen2-Math-72B-Instruct** is an instruction model for chatting;
50
+ >
51
+ > **Qwen2-Math-72B** is a base model typically used for completion and few-shot inference, serving as a better starting point for fine-tuning.
52
+ >
53
+
54
+ ### 🤗 Hugging Face Transformers
55
+
56
+ Qwen2-Math can be deployed and infered in the same way as [Qwen2](https://github.com/QwenLM/Qwen2). Here we show a code snippet to show you how to use the chat model with `transformers`:
57
+
58
+ ```python
59
+ from transformers import AutoModelForCausalLM, AutoTokenizer
60
+
61
+ model_name = "Qwen/Qwen2-Math-72B-Instruct"
62
+ device = "cuda" # the device to load the model onto
63
+
64
+ model = AutoModelForCausalLM.from_pretrained(
65
+ model_name,
66
+ torch_dtype="auto",
67
+ device_map="auto"
68
+ )
69
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
70
+
71
+ prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$."
72
+ messages = [
73
+ {"role": "system", "content": "You are a helpful assistant."},
74
+ {"role": "user", "content": prompt}
75
+ ]
76
+ text = tokenizer.apply_chat_template(
77
+ messages,
78
+ tokenize=False,
79
+ add_generation_prompt=True
80
+ )
81
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
82
+
83
+ generated_ids = model.generate(
84
+ **model_inputs,
85
+ max_new_tokens=512
86
+ )
87
+ generated_ids = [
88
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
89
+ ]
90
+
91
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
92
+ ```
93
+
94
+ ### 🤖 ModelScope
95
+ We strongly advise users especially those in mainland China to use ModelScope. `snapshot_download` can help you solve issues concerning downloading checkpoints.
96
+
97
+
98
+ ## Citation
99
+
100
+ If you find our work helpful, feel free to give us a citation.
101
+
102
+ ```
103
+ @article{yang2024qwen2,
104
+ title={Qwen2 technical report},
105
+ author={Yang, An and Yang, Baosong and Hui, Binyuan and Zheng, Bo and Yu, Bowen and Zhou, Chang and Li, Chengpeng and Li, Chengyuan and Liu, Dayiheng and Huang, Fei and others},
106
+ journal={arXiv preprint arXiv:2407.10671},
107
+ year={2024}
108
+ }
109
+ ```