ThiloteE commited on
Commit
b73777f
1 Parent(s): 665c4e8

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +273 -2
README.md CHANGED
@@ -1,7 +1,31 @@
1
  ---
2
  license: apache-2.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
4
 
 
 
5
  > [!NOTE]
6
  > This is a model that is assumed to perform well, but may require more testing and user feedback. Be aware, only models featured within the GUI of GPT4All, are curated and officially supported by Nomic. Use at your own risk.
7
 
@@ -11,5 +35,252 @@ license: apache-2.0
11
  - Static quants of https://huggingface.co/Qwen/Qwen2-7B-Instruct at commit [41c66b0](https://huggingface.co/Qwen/Qwen2-7B-Instruct/commit/41c66b0be1c3081f13defc6bdf946c2ef240d6a6)
12
  - Quantized by [ThiloteE](https://huggingface.co/ThiloteE) with llama.cpp commit [e09a800](https://github.com/ggerganov/llama.cpp/commit/e09a800f9a9b19c73aa78e03b4c4be8ed988f3e6)
13
 
14
- These quants were created with a customized configuration that have been proven to not cause visible end of string (eos) tokens during inference with [GPT4All](https://www.nomic.ai/gpt4all).
15
- The config.json, generation_config.json and tokenizer_config.json differ from the original configuration as can be found in the original model's repository at the time of creation of these quants.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+ base_model: Qwen/Qwen2-7B-Instruct
4
+ pipeline_tag: text-generation
5
+ inference: false
6
+ model_creator: Qwen
7
+ model_name: Qwen2-7B-Instruct
8
+ model_type: qwen2
9
+ language:
10
+ - en
11
+ - zh
12
+ library_name: transformers
13
+ quantized_by: ThiloteE
14
+ tags:
15
+ - text-generation-inference
16
+ - transformers
17
+ - GGUF
18
+ - GPT4All-community
19
+ - GPT4All
20
+ - chat
21
+ - aligned
22
+ - instruct
23
+
24
+
25
  ---
26
 
27
+
28
+
29
  > [!NOTE]
30
  > This is a model that is assumed to perform well, but may require more testing and user feedback. Be aware, only models featured within the GUI of GPT4All, are curated and officially supported by Nomic. Use at your own risk.
31
 
 
35
  - Static quants of https://huggingface.co/Qwen/Qwen2-7B-Instruct at commit [41c66b0](https://huggingface.co/Qwen/Qwen2-7B-Instruct/commit/41c66b0be1c3081f13defc6bdf946c2ef240d6a6)
36
  - Quantized by [ThiloteE](https://huggingface.co/ThiloteE) with llama.cpp commit [e09a800](https://github.com/ggerganov/llama.cpp/commit/e09a800f9a9b19c73aa78e03b4c4be8ed988f3e6)
37
 
38
+ These quants were created with a customized configuration that have been proven to be compatible with [GPT4All](https://www.nomic.ai/gpt4all) and that fixes issues with bos and eos after [feedback](https://huggingface.co/Qwen/Qwen2-7B-Instruct/discussions/15) by Qwen developers.
39
+
40
+
41
+
42
+ # Prompt Template (for GPT4All)
43
+
44
+ Example System Prompt:
45
+ ```
46
+ <|im_start|>system
47
+ You are a helpful assistant.<|im_end|>
48
+ ```
49
+
50
+ Chat Template:
51
+ ```
52
+ <|im_start|>User
53
+ %1<|im_end|>
54
+ <|im_start|>assistant
55
+ %2<|im_end|>
56
+ ```
57
+
58
+
59
+ # Context Length
60
+
61
+ `32768`
62
+
63
+ Use a lower value during inference, if you do not have enough RAM or VRAM.
64
+
65
+ # Provided Quants
66
+
67
+
68
+ | Link | Type | Size/GB | Notes |
69
+ |:-----|:-----|--------:|:------|
70
+ | [GGUF](https://huggingface.co/GPT4All-Community/Qwen2-7B-Instruct-GGUF/resolve/main/Qwen2-7B-Instruct-Q4_0.gguf?download=true) | Q4_0 | 4.43 | fast, recommended |
71
+
72
+
73
+
74
+
75
+ # About GGUF
76
+
77
+ If you are unsure how to use GGUF files, refer to one of [TheBloke's
78
+ READMEs](https://huggingface.co/TheBloke/DiscoLM_German_7b_v1-GGUF) for
79
+ more details, including on how to concatenate multi-part files.
80
+
81
+ Here is a handy graph by ikawrakow comparing some quant types (lower is better):
82
+
83
+ ![image.png](https://www.nethype.de/huggingface_embed/quantpplgraph.png)
84
+
85
+ And here are Artefact2's thoughts on the matter:
86
+ https://gist.github.com/Artefact2/b5f810600771265fc1e39442288e8ec9
87
+
88
+ # Thanks
89
+
90
+ I thank Mradermacher and TheBloke for Inspiration to this model card and their contributions to open source. Also 3Simplex for lots of help along the way.
91
+ Shoutout to the GPT4All and llama.cpp communities :-)
92
+
93
+
94
+
95
+
96
+ <br>
97
+ <br>
98
+ <br>
99
+ <br>
100
+
101
+ ------
102
+
103
+ <!-- footer end -->
104
+ <!-- original-model-card start -->
105
+
106
+ # Original Model card:
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
116
+
117
+ >
118
+ > ---
119
+ > license: apache-2.0
120
+ > language:
121
+ > - en
122
+ > pipeline_tag: text-generation
123
+ > tags:
124
+ > - chat
125
+ > ---
126
+ >
127
+ > # Qwen2-7B-Instruct
128
+ >
129
+ > ## Introduction
130
+ >
131
+ > Qwen2 is the new series of Qwen large language models. For Qwen2, we release a number of base language models and instruction-tuned language models ranging from 0.5 to 72 billion parameters, including a Mixture-of-Experts model. This repo contains the instruction-tuned 7B Qwen2 model.
132
+ >
133
+ > Compared with the state-of-the-art opensource language models, including the previous released Qwen1.5, Qwen2 has generally surpassed most opensource models and demonstrated competitiveness against proprietary models across a series of benchmarks targeting for language understanding, language generation, multilingual capability, coding, mathematics, reasoning, etc.
134
+ >
135
+ > Qwen2-7B-Instruct supports a context length of up to 131,072 tokens, enabling the processing of extensive inputs. Please refer to [this section](#processing-long-texts) for detailed instructions on how to deploy Qwen2 for handling long texts.
136
+ >
137
+ > For more details, please refer to our [blog](https://qwenlm.github.io/blog/qwen2/), [GitHub](https://github.com/QwenLM/Qwen2), and [Documentation](https://qwen.readthedocs.io/en/latest/).
138
+ > <br>
139
+ >
140
+ > ## Model Details
141
+ > Qwen2 is a language model series including decoder language models of different model sizes. For each size, we release the base language model and the aligned chat model. It is based on the Transformer architecture with SwiGLU activation, attention QKV bias, group query attention, etc. Additionally, we have an improved tokenizer adaptive to multiple natural languages and codes.
142
+ >
143
+ > ## Training details
144
+ > We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
145
+ >
146
+ >
147
+ > ## Requirements
148
+ > The code of Qwen2 has been in the latest Hugging face transformers and we advise you to install `transformers>=4.37.0`, or you might encounter the following error:
149
+ > ```
150
+ > KeyError: 'qwen2'
151
+ > ```
152
+ >
153
+ > ## Quickstart
154
+ >
155
+ > Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
156
+ >
157
+ > ```python
158
+ > from transformers import AutoModelForCausalLM, AutoTokenizer
159
+ > device = "cuda" # the device to load the model onto
160
+ >
161
+ > model = AutoModelForCausalLM.from_pretrained(
162
+ > "Qwen/Qwen2-7B-Instruct",
163
+ > torch_dtype="auto",
164
+ > device_map="auto"
165
+ > )
166
+ > tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-7B-Instruct")
167
+ >
168
+ > prompt = "Give me a short introduction to large language model."
169
+ > messages = [
170
+ > {"role": "system", "content": "You are a helpful assistant."},
171
+ > {"role": "user", "content": prompt}
172
+ > ]
173
+ > text = tokenizer.apply_chat_template(
174
+ > messages,
175
+ > tokenize=False,
176
+ > add_generation_prompt=True
177
+ > )
178
+ > model_inputs = tokenizer([text], return_tensors="pt").to(device)
179
+ >
180
+ > generated_ids = model.generate(
181
+ > model_inputs.input_ids,
182
+ > max_new_tokens=512
183
+ > )
184
+ > generated_ids = [
185
+ > output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
186
+ > ]
187
+ >
188
+ > response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
189
+ > ```
190
+ >
191
+ > ### Processing Long Texts
192
+ >
193
+ > To handle extensive inputs exceeding 32,768 tokens, we utilize [YARN](https://arxiv.org/abs/2309.00071), a technique for enhancing model length extrapolation, ensuring optimal performance on lengthy texts.
194
+ >
195
+ > For deployment, we recommend using vLLM. You can enable the long-context capabilities by following these steps:
196
+ >
197
+ > 1. **Install vLLM**: You can install vLLM by running the following command.
198
+ >
199
+ > ```bash
200
+ > pip install "vllm>=0.4.3"
201
+ > ```
202
+ >
203
+ > Or you can install vLLM from [source](https://github.com/vllm-project/vllm/).
204
+ >
205
+ > 2. **Configure Model Settings**: After downloading the model weights, modify the `config.json` file by including the below snippet:
206
+ > ```json
207
+ > {
208
+ > "architectures": [
209
+ > "Qwen2ForCausalLM"
210
+ > ],
211
+ > // ...
212
+ > "vocab_size": 152064,
213
+ >
214
+ > // adding the following snippets
215
+ > "rope_scaling": {
216
+ > "factor": 4.0,
217
+ > "original_max_position_embeddings": 32768,
218
+ > "type": "yarn"
219
+ > }
220
+ > }
221
+ > ```
222
+ > This snippet enable YARN to support longer contexts.
223
+ >
224
+ > 3. **Model Deployment**: Utilize vLLM to deploy your model. For instance, you can set up an openAI-like server using the command:
225
+ >
226
+ > ```bash
227
+ > python -m vllm.entrypoints.openai.api_server --served-model-name Qwen2-7B-Instruct --model path/to/weights
228
+ > ```
229
+ >
230
+ > Then you can access the Chat API by:
231
+ >
232
+ > ```bash
233
+ > curl http://localhost:8000/v1/chat/completions \
234
+ > -H "Content-Type: application/json" \
235
+ > -d '{
236
+ > "model": "Qwen2-7B-Instruct",
237
+ > "messages": [
238
+ > {"role": "system", "content": "You are a helpful assistant."},
239
+ > {"role": "user", "content": "Your Long Input Here."}
240
+ > ]
241
+ > }'
242
+ > ```
243
+ >
244
+ > For further usage instructions of vLLM, please refer to our [Github](https://github.com/QwenLM/Qwen2).
245
+ >
246
+ > **Note**: Presently, vLLM only supports static YARN, which means the scaling factor remains constant regardless of input length, **potentially impacting performance on shorter texts**. We advise adding the `rope_scaling` configuration only when processing long contexts is required.
247
+ >
248
+ > ## Evaluation
249
+ >
250
+ > We briefly compare Qwen2-7B-Instruct with similar-sized instruction-tuned LLMs, including Qwen1.5-7B-Chat. The results are shown below:
251
+ >
252
+ > | Datasets | Llama-3-8B-Instruct | Yi-1.5-9B-Chat | GLM-4-9B-Chat | Qwen1.5-7B-Chat | Qwen2-7B-Instruct |
253
+ > | :--- | :---: | :---: | :---: | :---: | :---: |
254
+ > | _**English**_ | | | | | |
255
+ > | MMLU | 68.4 | 69.5 | **72.4** | 59.5 | 70.5 |
256
+ > | MMLU-Pro | 41.0 | - | - | 29.1 | **44.1** |
257
+ > | GPQA | **34.2** | - | **-** | 27.8 | 25.3 |
258
+ > | TheroemQA | 23.0 | - | - | 14.1 | **25.3** |
259
+ > | MT-Bench | 8.05 | 8.20 | 8.35 | 7.60 | **8.41** |
260
+ > | _**Coding**_ | | | | | |
261
+ > | Humaneval | 62.2 | 66.5 | 71.8 | 46.3 | **79.9** |
262
+ > | MBPP | **67.9** | - | - | 48.9 | 67.2 |
263
+ > | MultiPL-E | 48.5 | - | - | 27.2 | **59.1** |
264
+ > | Evalplus | 60.9 | - | - | 44.8 | **70.3** |
265
+ > | LiveCodeBench | 17.3 | - | - | 6.0 | **26.6** |
266
+ > | _**Mathematics**_ | | | | | |
267
+ > | GSM8K | 79.6 | **84.8** | 79.6 | 60.3 | 82.3 |
268
+ > | MATH | 30.0 | 47.7 | **50.6** | 23.2 | 49.6 |
269
+ > | _**Chinese**_ | | | | | |
270
+ > | C-Eval | 45.9 | - | 75.6 | 67.3 | **77.2** |
271
+ > | AlignBench | 6.20 | 6.90 | 7.01 | 6.20 | **7.21** |
272
+ >
273
+ > ## Citation
274
+ >
275
+ > If you find our work helpful, feel free to give us a cite.
276
+ >
277
+ > ```
278
+ > @article{qwen2,
279
+ > title={Qwen2 Technical Report},
280
+ > year={2024}
281
+ > }
282
+ > ```
283
+ >
284
+
285
+ <!-- original-model-card end -->
286
+ <!-- end -->