dtzx commited on
Commit
3fa7af5
1 Parent(s): d68b4f1

Upload folder using huggingface_hub

Browse files
Files changed (8) hide show
  1. README.md +107 -0
  2. config.json +28 -0
  3. generation_config.json +13 -0
  4. merges.txt +0 -0
  5. model.safetensors +3 -0
  6. tokenizer.json +0 -0
  7. tokenizer_config.json +40 -0
  8. vocab.json +0 -0
README.md ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pipeline_tag: text-generation
6
+ tags:
7
+ - chat
8
+ ---
9
+
10
+
11
+ # Qwen2-Math-1.5B-Instruct
12
+
13
+ > [!Warning]
14
+ > <div align="center">
15
+ > <b>
16
+ > 🚨 Temporarily this model mainly supports English. We will release bilingual (English & Chinese) models soon!
17
+ > </b>
18
+ > </div>
19
+
20
+ ## Introduction
21
+
22
+ 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.
23
+
24
+
25
+ ## Model Details
26
+
27
+
28
+ 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).
29
+
30
+
31
+ ## Requirements
32
+ * `transformers>=4.40.0` for Qwen2-Math models. The latest version is recommended.
33
+
34
+ > [!Warning]
35
+ > <div align="center">
36
+ > <b>
37
+ > 🚨 This is a must because `transformers` integrated Qwen2 codes since `4.37.0`.
38
+ > </b>
39
+ > </div>
40
+
41
+ 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).
42
+
43
+ ## Quick Start
44
+
45
+ > [!Important]
46
+ >
47
+ > **Qwen2-Math-1.5B-Instruct** is an instruction model for chatting;
48
+ >
49
+ > **Qwen2-Math-1.5B** is a base model typically used for completion and few-shot inference, serving as a better starting point for fine-tuning.
50
+ >
51
+
52
+ ### 🤗 Hugging Face Transformers
53
+
54
+ Qwen2-Math can be deployed and inferred 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`:
55
+
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer
58
+
59
+ model_name = "Qwen/Qwen2-Math-1.5B-Instruct"
60
+ device = "cuda" # the device to load the model onto
61
+
62
+ model = AutoModelForCausalLM.from_pretrained(
63
+ model_name,
64
+ torch_dtype="auto",
65
+ device_map="auto"
66
+ )
67
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
68
+
69
+ prompt = "Find the value of $x$ that satisfies the equation $4x+5 = 6x+7$."
70
+ messages = [
71
+ {"role": "system", "content": "You are a helpful assistant."},
72
+ {"role": "user", "content": prompt}
73
+ ]
74
+ text = tokenizer.apply_chat_template(
75
+ messages,
76
+ tokenize=False,
77
+ add_generation_prompt=True
78
+ )
79
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
80
+
81
+ generated_ids = model.generate(
82
+ **model_inputs,
83
+ max_new_tokens=512
84
+ )
85
+ generated_ids = [
86
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
87
+ ]
88
+
89
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
90
+ ```
91
+
92
+ ### 🤖 ModelScope
93
+ We strongly advise users, especially those in mainland China, to use ModelScope. `snapshot_download` can help you solve issues concerning downloading checkpoints.
94
+
95
+
96
+ ## Citation
97
+
98
+ If you find our work helpful, feel free to give us a citation.
99
+
100
+ ```
101
+ @article{yang2024qwen2,
102
+ title={Qwen2 technical report},
103
+ 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},
104
+ journal={arXiv preprint arXiv:2407.10671},
105
+ year={2024}
106
+ }
107
+ ```
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "architectures": [
3
+ "Qwen2ForCausalLM"
4
+ ],
5
+ "attention_dropout": 0.0,
6
+ "bos_token_id": 151643,
7
+ "eos_token_id": 151645,
8
+ "hidden_act": "silu",
9
+ "hidden_size": 1536,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 8960,
12
+ "max_position_embeddings": 4096,
13
+ "max_window_layers": 21,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 12,
16
+ "num_hidden_layers": 28,
17
+ "num_key_value_heads": 2,
18
+ "rms_norm_eps": 1e-06,
19
+ "rope_theta": 10000.0,
20
+ "sliding_window": 32768,
21
+ "tie_word_embeddings": true,
22
+ "torch_dtype": "bfloat16",
23
+ "transformers_version": "4.43.1",
24
+ "use_cache": true,
25
+ "use_mrope": false,
26
+ "use_sliding_window": false,
27
+ "vocab_size": 151936
28
+ }
generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "pad_token_id": 151643,
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 151645,
7
+ 151643
8
+ ],
9
+ "top_p": 1.0,
10
+ "temperature": 0.0,
11
+ "transformers_version": "4.37.0"
12
+ }
13
+
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:de3b544c2ebbe5143f09498728c1b0786b1b4816255258da5549d482e7e38539
3
+ size 3087467144
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "add_prefix_space": false,
3
+ "added_tokens_decoder": {
4
+ "151643": {
5
+ "content": "<|endoftext|>",
6
+ "lstrip": false,
7
+ "normalized": false,
8
+ "rstrip": false,
9
+ "single_word": false,
10
+ "special": true
11
+ },
12
+ "151644": {
13
+ "content": "<|im_start|>",
14
+ "lstrip": false,
15
+ "normalized": false,
16
+ "rstrip": false,
17
+ "single_word": false,
18
+ "special": true
19
+ },
20
+ "151645": {
21
+ "content": "<|im_end|>",
22
+ "lstrip": false,
23
+ "normalized": false,
24
+ "rstrip": false,
25
+ "single_word": false,
26
+ "special": true
27
+ }
28
+ },
29
+ "additional_special_tokens": ["<|im_start|>", "<|im_end|>"],
30
+ "bos_token": null,
31
+ "chat_template": "{% for message in messages %}{% if loop.first and messages[0]['role'] != 'system' %}{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}{% endif %}{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n'}}{% endfor %}{% if add_generation_prompt %}{{ '<|im_start|>assistant\n' }}{% endif %}",
32
+ "clean_up_tokenization_spaces": false,
33
+ "eos_token": "<|im_end|>",
34
+ "errors": "replace",
35
+ "model_max_length": 32768,
36
+ "pad_token": "<|endoftext|>",
37
+ "split_special_tokens": false,
38
+ "tokenizer_class": "Qwen2Tokenizer",
39
+ "unk_token": null
40
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff