lbourdois commited on
Commit
a45f1bf
·
verified ·
1 Parent(s): 4df9696

Improve language tag

Browse files

Hi! As the model is multilingual, this is a PR to add other languages than English to the language tag to improve the referencing. Note that 29 languages are announced in the README, but only 13 are explicitly listed. I was therefore only able to add these 13 languages.

Files changed (1) hide show
  1. README.md +235 -223
README.md CHANGED
@@ -1,223 +1,235 @@
1
- ---
2
- license: apache-2.0
3
- license_link: https://huggingface.co/Qwen/Qwen2.5-7B/blob/main/LICENSE
4
- language:
5
- - en
6
- pipeline_tag: text-generation
7
- base_model: Qwen/Qwen2.5-7B
8
- tags:
9
- - chat
10
- - neuralmagic
11
- - llmcompressor
12
- - int4
13
- ---
14
-
15
- # Qwen2.5-7B-quantized.w4a16
16
-
17
- ## Model Overview
18
- - **Model Architecture:** Qwen2
19
- - **Input:** Text
20
- - **Output:** Text
21
- - **Model Optimizations:**
22
- - **Weight quantization:** INT4
23
- - **Intended Use Cases:** Intended for commercial and research use multiple languages. Similarly to [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B), this models is intended for assistant-like chat.
24
- - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws).
25
- - **Release Date:** 10/18/2024
26
- - **Version:** 1.0
27
- - **License(s):** [apache-2.0](https://huggingface.co/Qwen/Qwen2.5-7B/blob/main/LICENSE)
28
- - **Model Developers:** Neural Magic
29
-
30
- ### Model Optimizations
31
-
32
- This model was obtained by quantizing the weights of [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B) to INT4 data type.
33
- This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%.
34
-
35
- Only the weights of the linear operators within transformers blocks are quantized.
36
- Weights are quantized using a symmetric per-group scheme, with group size 128.
37
- The [GPTQ](https://arxiv.org/abs/2210.17323) algorithm is applied for quantization, as implemented in the [llm-compressor](https://github.com/vllm-project/llm-compressor) library.
38
-
39
- ## Deployment
40
-
41
- This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
42
-
43
- ```python
44
- from vllm import LLM, SamplingParams
45
- from transformers import AutoTokenizer
46
-
47
- model_id = "RedHatAI/Qwen2.5-7B-quantized.w4a16"
48
- number_gpus = 1
49
- max_model_len = 8192
50
-
51
- sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
52
-
53
- tokenizer = AutoTokenizer.from_pretrained(model_id)
54
-
55
- prompt = "Give me a short introduction to large language model."
56
-
57
- llm = LLM(model=model_id, tensor_parallel_size=number_gpus, max_model_len=max_model_len)
58
-
59
- outputs = llm.generate(prompt, sampling_params)
60
-
61
- generated_text = outputs[0].outputs[0].text
62
- print(generated_text)
63
- ```
64
-
65
- vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
66
-
67
- ## Creation
68
-
69
- <details>
70
- <summary>Creation details</summary>
71
- This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
72
-
73
-
74
- ```python
75
- from transformers import AutoModelForCausalLM, AutoTokenizer
76
- from llmcompressor.modifiers.quantization import GPTQModifier
77
- from llmcompressor.transformers import oneshot
78
- from datasets import load_dataset
79
-
80
- # Load model
81
- model_stub = "Qwen/Qwen2.5-7B"
82
- model_name = model_stub.split("/")[-1]
83
-
84
- num_samples = 3072
85
- max_seq_len = 8192
86
-
87
- tokenizer = AutoTokenizer.from_pretrained(model_stub)
88
-
89
- model = AutoModelForCausalLM.from_pretrained(
90
- model_stub,
91
- device_map="auto",
92
- torch_dtype="auto",
93
- )
94
-
95
- def preprocess_fn(example):
96
- return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)}
97
-
98
- ds = load_dataset("neuralmagic/LLM_compression_calibration", split="train")
99
- ds = ds.map(preprocess_fn)
100
-
101
- # Configure the quantization algorithm and scheme
102
- recipe = GPTQModifier(
103
- targets="Linear",
104
- scheme="W4A16",
105
- ignore=["lm_head"],
106
- sequential_targets=["Qwen2DecoderLayer"],
107
- dampening_frac=0.1,
108
- )
109
-
110
- # Apply quantization
111
- oneshot(
112
- model=model,
113
- dataset=ds,
114
- recipe=recipe,
115
- max_seq_length=max_seq_len,
116
- num_calibration_samples=num_samples,
117
- )
118
-
119
- # Save to disk in compressed-tensors format
120
- save_path = model_name + "-quantized.w4a16"
121
- model.save_pretrained(save_path)
122
- tokenizer.save_pretrained(save_path)
123
- print(f"Model and tokenizer saved to: {save_path}")
124
- ```
125
- </details>
126
-
127
- ## Evaluation
128
-
129
- The model was evaluated on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) leaderboard tasks (version 1) with the [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/387Bbd54bc621086e05aa1b030d8d4d5635b25e6) (commit 387Bbd54bc621086e05aa1b030d8d4d5635b25e6) and the [vLLM](https://docs.vllm.ai/en/stable/) engine, using the following command:
130
- ```
131
- lm_eval \
132
- --model vllm \
133
- --model_args pretrained="neuralmagic/Qwen2.5-7B-quantized.w4a16",dtype=auto,gpu_memory_utilization=0.9,add_bos_token=True,max_model_len=4096,enable_chunk_prefill=True,tensor_parallel_size=1 \
134
- --tasks openllm \
135
- --batch_size auto
136
- ```
137
-
138
- ### Accuracy
139
-
140
- #### Open LLM Leaderboard evaluation scores
141
- <table>
142
- <tr>
143
- <th>Benchmark
144
- </th>
145
- <th>Qwen2.5-7B
146
- </th>
147
- <th>Qwen2.5-7B-quantized.w4a16<br>(this model)
148
- </th>
149
- <th>Recovery
150
- </th>
151
- </tr>
152
- <tr>
153
- <td>MMLU (5-shot)
154
- </td>
155
- <td>74.15
156
- </td>
157
- <td>73.47
158
- </td>
159
- <td>99.1%
160
- </td>
161
- </tr>
162
- <tr>
163
- <td>ARC Challenge (25-shot)
164
- </td>
165
- <td>59.39
166
- </td>
167
- <td>58.70
168
- </td>
169
- <td>98.9%
170
- </td>
171
- </tr>
172
- <tr>
173
- <td>GSM-8K (5-shot, strict-match)
174
- </td>
175
- <td>79.76
176
- </td>
177
- <td>79.08
178
- </td>
179
- <td>99.1%
180
- </td>
181
- </tr>
182
- <tr>
183
- <td>Hellaswag (10-shot)
184
- </td>
185
- <td>80.17
186
- </td>
187
- <td>79.39
188
- </td>
189
- <td>99.0%
190
- </td>
191
- </tr>
192
- <tr>
193
- <td>Winogrande (5-shot)
194
- </td>
195
- <td>75.69
196
- </td>
197
- <td>76.01
198
- </td>
199
- <td>100.4%
200
- </td>
201
- </tr>
202
- <tr>
203
- <td>TruthfulQA (0-shot, mc2)
204
- </td>
205
- <td>56.38
206
- </td>
207
- <td>55.48
208
- </td>
209
- <td>98.4%
210
- </td>
211
- </tr>
212
- <tr>
213
- <td><strong>Average</strong>
214
- </td>
215
- <td><strong>70.92</strong>
216
- </td>
217
- <td><strong>70.35</strong>
218
- </td>
219
- <td><strong>99.2%</strong>
220
- </td>
221
- </tr>
222
- </table>
223
-
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ license_link: https://huggingface.co/Qwen/Qwen2.5-7B/blob/main/LICENSE
4
+ language:
5
+ - zho
6
+ - eng
7
+ - fra
8
+ - spa
9
+ - por
10
+ - deu
11
+ - ita
12
+ - rus
13
+ - jpn
14
+ - kor
15
+ - vie
16
+ - tha
17
+ - ara
18
+ pipeline_tag: text-generation
19
+ base_model: Qwen/Qwen2.5-7B
20
+ tags:
21
+ - chat
22
+ - neuralmagic
23
+ - llmcompressor
24
+ - int4
25
+ ---
26
+
27
+ # Qwen2.5-7B-quantized.w4a16
28
+
29
+ ## Model Overview
30
+ - **Model Architecture:** Qwen2
31
+ - **Input:** Text
32
+ - **Output:** Text
33
+ - **Model Optimizations:**
34
+ - **Weight quantization:** INT4
35
+ - **Intended Use Cases:** Intended for commercial and research use multiple languages. Similarly to [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B), this models is intended for assistant-like chat.
36
+ - **Out-of-scope:** Use in any manner that violates applicable laws or regulations (including trade compliance laws).
37
+ - **Release Date:** 10/18/2024
38
+ - **Version:** 1.0
39
+ - **License(s):** [apache-2.0](https://huggingface.co/Qwen/Qwen2.5-7B/blob/main/LICENSE)
40
+ - **Model Developers:** Neural Magic
41
+
42
+ ### Model Optimizations
43
+
44
+ This model was obtained by quantizing the weights of [Qwen2.5-7B](https://huggingface.co/Qwen/Qwen2.5-7B) to INT4 data type.
45
+ This optimization reduces the number of bits per parameter from 16 to 4, reducing the disk size and GPU memory requirements by approximately 75%.
46
+
47
+ Only the weights of the linear operators within transformers blocks are quantized.
48
+ Weights are quantized using a symmetric per-group scheme, with group size 128.
49
+ The [GPTQ](https://arxiv.org/abs/2210.17323) algorithm is applied for quantization, as implemented in the [llm-compressor](https://github.com/vllm-project/llm-compressor) library.
50
+
51
+ ## Deployment
52
+
53
+ This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend, as shown in the example below.
54
+
55
+ ```python
56
+ from vllm import LLM, SamplingParams
57
+ from transformers import AutoTokenizer
58
+
59
+ model_id = "RedHatAI/Qwen2.5-7B-quantized.w4a16"
60
+ number_gpus = 1
61
+ max_model_len = 8192
62
+
63
+ sampling_params = SamplingParams(temperature=0.7, top_p=0.8, max_tokens=256)
64
+
65
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
66
+
67
+ prompt = "Give me a short introduction to large language model."
68
+
69
+ llm = LLM(model=model_id, tensor_parallel_size=number_gpus, max_model_len=max_model_len)
70
+
71
+ outputs = llm.generate(prompt, sampling_params)
72
+
73
+ generated_text = outputs[0].outputs[0].text
74
+ print(generated_text)
75
+ ```
76
+
77
+ vLLM aslo supports OpenAI-compatible serving. See the [documentation](https://docs.vllm.ai/en/latest/) for more details.
78
+
79
+ ## Creation
80
+
81
+ <details>
82
+ <summary>Creation details</summary>
83
+ This model was created with [llm-compressor](https://github.com/vllm-project/llm-compressor) by running the code snippet below.
84
+
85
+
86
+ ```python
87
+ from transformers import AutoModelForCausalLM, AutoTokenizer
88
+ from llmcompressor.modifiers.quantization import GPTQModifier
89
+ from llmcompressor.transformers import oneshot
90
+ from datasets import load_dataset
91
+
92
+ # Load model
93
+ model_stub = "Qwen/Qwen2.5-7B"
94
+ model_name = model_stub.split("/")[-1]
95
+
96
+ num_samples = 3072
97
+ max_seq_len = 8192
98
+
99
+ tokenizer = AutoTokenizer.from_pretrained(model_stub)
100
+
101
+ model = AutoModelForCausalLM.from_pretrained(
102
+ model_stub,
103
+ device_map="auto",
104
+ torch_dtype="auto",
105
+ )
106
+
107
+ def preprocess_fn(example):
108
+ return {"text": tokenizer.apply_chat_template(example["messages"], add_generation_prompt=False, tokenize=False)}
109
+
110
+ ds = load_dataset("neuralmagic/LLM_compression_calibration", split="train")
111
+ ds = ds.map(preprocess_fn)
112
+
113
+ # Configure the quantization algorithm and scheme
114
+ recipe = GPTQModifier(
115
+ targets="Linear",
116
+ scheme="W4A16",
117
+ ignore=["lm_head"],
118
+ sequential_targets=["Qwen2DecoderLayer"],
119
+ dampening_frac=0.1,
120
+ )
121
+
122
+ # Apply quantization
123
+ oneshot(
124
+ model=model,
125
+ dataset=ds,
126
+ recipe=recipe,
127
+ max_seq_length=max_seq_len,
128
+ num_calibration_samples=num_samples,
129
+ )
130
+
131
+ # Save to disk in compressed-tensors format
132
+ save_path = model_name + "-quantized.w4a16"
133
+ model.save_pretrained(save_path)
134
+ tokenizer.save_pretrained(save_path)
135
+ print(f"Model and tokenizer saved to: {save_path}")
136
+ ```
137
+ </details>
138
+
139
+ ## Evaluation
140
+
141
+ The model was evaluated on the [OpenLLM](https://huggingface.co/spaces/open-llm-leaderboard/open_llm_leaderboard) leaderboard tasks (version 1) with the [lm-evaluation-harness](https://github.com/EleutherAI/lm-evaluation-harness/tree/387Bbd54bc621086e05aa1b030d8d4d5635b25e6) (commit 387Bbd54bc621086e05aa1b030d8d4d5635b25e6) and the [vLLM](https://docs.vllm.ai/en/stable/) engine, using the following command:
142
+ ```
143
+ lm_eval \
144
+ --model vllm \
145
+ --model_args pretrained="neuralmagic/Qwen2.5-7B-quantized.w4a16",dtype=auto,gpu_memory_utilization=0.9,add_bos_token=True,max_model_len=4096,enable_chunk_prefill=True,tensor_parallel_size=1 \
146
+ --tasks openllm \
147
+ --batch_size auto
148
+ ```
149
+
150
+ ### Accuracy
151
+
152
+ #### Open LLM Leaderboard evaluation scores
153
+ <table>
154
+ <tr>
155
+ <th>Benchmark
156
+ </th>
157
+ <th>Qwen2.5-7B
158
+ </th>
159
+ <th>Qwen2.5-7B-quantized.w4a16<br>(this model)
160
+ </th>
161
+ <th>Recovery
162
+ </th>
163
+ </tr>
164
+ <tr>
165
+ <td>MMLU (5-shot)
166
+ </td>
167
+ <td>74.15
168
+ </td>
169
+ <td>73.47
170
+ </td>
171
+ <td>99.1%
172
+ </td>
173
+ </tr>
174
+ <tr>
175
+ <td>ARC Challenge (25-shot)
176
+ </td>
177
+ <td>59.39
178
+ </td>
179
+ <td>58.70
180
+ </td>
181
+ <td>98.9%
182
+ </td>
183
+ </tr>
184
+ <tr>
185
+ <td>GSM-8K (5-shot, strict-match)
186
+ </td>
187
+ <td>79.76
188
+ </td>
189
+ <td>79.08
190
+ </td>
191
+ <td>99.1%
192
+ </td>
193
+ </tr>
194
+ <tr>
195
+ <td>Hellaswag (10-shot)
196
+ </td>
197
+ <td>80.17
198
+ </td>
199
+ <td>79.39
200
+ </td>
201
+ <td>99.0%
202
+ </td>
203
+ </tr>
204
+ <tr>
205
+ <td>Winogrande (5-shot)
206
+ </td>
207
+ <td>75.69
208
+ </td>
209
+ <td>76.01
210
+ </td>
211
+ <td>100.4%
212
+ </td>
213
+ </tr>
214
+ <tr>
215
+ <td>TruthfulQA (0-shot, mc2)
216
+ </td>
217
+ <td>56.38
218
+ </td>
219
+ <td>55.48
220
+ </td>
221
+ <td>98.4%
222
+ </td>
223
+ </tr>
224
+ <tr>
225
+ <td><strong>Average</strong>
226
+ </td>
227
+ <td><strong>70.92</strong>
228
+ </td>
229
+ <td><strong>70.35</strong>
230
+ </td>
231
+ <td><strong>99.2%</strong>
232
+ </td>
233
+ </tr>
234
+ </table>
235
+