qwp4w3hyb commited on
Commit
016ed0c
1 Parent(s): 1e93b68

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +183 -0
README.md ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: tongyi-qianwen
4
+ license_link: https://huggingface.co/Qwen/Qwen2-72B-Instruct/blob/main/LICENSE
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - chat
10
+ base_model: Qwen/Qwen2-72B-Instruct
11
+ ---
12
+
13
+ # Quant Infos
14
+
15
+ - quants done with an importance matrix for improved quantization loss
16
+ - ggufs & imatrix generated from bf16 for "optimal" accuracy loss
17
+ - Wide coverage of different gguf quant types from Q\_8\_0 down to IQ1\_S
18
+ - Quantized with [llama.cpp](https://github.com/ggerganov/llama.cpp) commit [d62e4aaa02540c89be8b59426340b909d02bbc9e](https://github.com/ggerganov/llama.cpp/commit/d62e4aaa02540c89be8b59426340b909d02bbc9e) (master as of 2024-06-24)
19
+ - Imatrix generated with [this](https://gist.github.com/bartowski1182/eb213dccb3571f863da82e99418f81e8) multi-purpose dataset by [bartowski](https://huggingface.co/bartowski).
20
+ ```
21
+ ./imatrix -c 512 -m $model_name-bf16.gguf -f calibration_datav3.txt -o $model_name.imatrix
22
+ ```
23
+
24
+ # Original Model Card:
25
+
26
+ # Qwen2-72B-Instruct
27
+
28
+ ## Introduction
29
+
30
+ 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 72B Qwen2 model.
31
+
32
+ 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.
33
+
34
+ Qwen2-72B-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.
35
+
36
+ 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/).
37
+ <br>
38
+
39
+ ## Model Details
40
+ 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.
41
+
42
+ ## Training details
43
+ We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
44
+
45
+
46
+ ## Requirements
47
+ 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:
48
+ ```
49
+ KeyError: 'qwen2'
50
+ ```
51
+
52
+ ## Quickstart
53
+
54
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
55
+
56
+ ```python
57
+ from transformers import AutoModelForCausalLM, AutoTokenizer
58
+ device = "cuda" # the device to load the model onto
59
+
60
+ model = AutoModelForCausalLM.from_pretrained(
61
+ "Qwen/Qwen2-72B-Instruct",
62
+ torch_dtype="auto",
63
+ device_map="auto"
64
+ )
65
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-72B-Instruct")
66
+
67
+ prompt = "Give me a short introduction to large language model."
68
+ messages = [
69
+ {"role": "system", "content": "You are a helpful assistant."},
70
+ {"role": "user", "content": prompt}
71
+ ]
72
+ text = tokenizer.apply_chat_template(
73
+ messages,
74
+ tokenize=False,
75
+ add_generation_prompt=True
76
+ )
77
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
78
+
79
+ generated_ids = model.generate(
80
+ model_inputs.input_ids,
81
+ max_new_tokens=512
82
+ )
83
+ generated_ids = [
84
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
85
+ ]
86
+
87
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
88
+ ```
89
+
90
+ ### Processing Long Texts
91
+
92
+ 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.
93
+
94
+ For deployment, we recommend using vLLM. You can enable the long-context capabilities by following these steps:
95
+
96
+ 1. **Install vLLM**: You can install vLLM by running the following command.
97
+
98
+ ```bash
99
+ pip install "vllm>=0.4.3"
100
+ ```
101
+
102
+ Or you can install vLLM from [source](https://github.com/vllm-project/vllm/).
103
+
104
+ 2. **Configure Model Settings**: After downloading the model weights, modify the `config.json` file by including the below snippet:
105
+ ```json
106
+ {
107
+ "architectures": [
108
+ "Qwen2ForCausalLM"
109
+ ],
110
+ // ...
111
+ "vocab_size": 152064,
112
+
113
+ // adding the following snippets
114
+ "rope_scaling": {
115
+ "factor": 4.0,
116
+ "original_max_position_embeddings": 32768,
117
+ "type": "yarn"
118
+ }
119
+ }
120
+ ```
121
+ This snippet enable YARN to support longer contexts.
122
+
123
+ 3. **Model Deployment**: Utilize vLLM to deploy your model. For instance, you can set up an openAI-like server using the command:
124
+
125
+ ```bash
126
+ python -m vllm.entrypoints.openai.api_server --served-model-name Qwen2-72B-Instruct --model path/to/weights
127
+ ```
128
+
129
+ Then you can access the Chat API by:
130
+
131
+ ```bash
132
+ curl http://localhost:8000/v1/chat/completions \
133
+ -H "Content-Type: application/json" \
134
+ -d '{
135
+ "model": "Qwen2-72B-Instruct",
136
+ "messages": [
137
+ {"role": "system", "content": "You are a helpful assistant."},
138
+ {"role": "user", "content": "Your Long Input Here."}
139
+ ]
140
+ }'
141
+ ```
142
+
143
+ For further usage instructions of vLLM, please refer to our [Github](https://github.com/QwenLM/Qwen2).
144
+
145
+ **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.
146
+
147
+ ## Evaluation
148
+
149
+ We briefly compare Qwen2-72B-Instruct with similar-sized instruction-tuned LLMs, including our previous Qwen1.5-72B-Chat. The results are shown as follows:
150
+
151
+ | Datasets | Llama-3-70B-Instruct | Qwen1.5-72B-Chat | **Qwen2-72B-Instruct** |
152
+ | :--- | :---: | :---: | :---: |
153
+ | _**English**_ | | | |
154
+ | MMLU | 82.0 | 75.6 | **82.3** |
155
+ | MMLU-Pro | 56.2 | 51.7 | **64.4** |
156
+ | GPQA | 41.9 | 39.4 | **42.4** |
157
+ | TheroemQA | 42.5 | 28.8 | **44.4** |
158
+ | MT-Bench | 8.95 | 8.61 | **9.12** |
159
+ | Arena-Hard | 41.1 | 36.1 | **48.1** |
160
+ | IFEval (Prompt Strict-Acc.) | 77.3 | 55.8 | **77.6** |
161
+ | _**Coding**_ | | | |
162
+ | HumanEval | 81.7 | 71.3 | **86.0** |
163
+ | MBPP | **82.3** | 71.9 | 80.2 |
164
+ | MultiPL-E | 63.4 | 48.1 | **69.2** |
165
+ | EvalPlus | 75.2 | 66.9 | **79.0** |
166
+ | LiveCodeBench | 29.3 | 17.9 | **35.7** |
167
+ | _**Mathematics**_ | | | |
168
+ | GSM8K | **93.0** | 82.7 | 91.1 |
169
+ | MATH | 50.4 | 42.5 | **59.7** |
170
+ | _**Chinese**_ | | | |
171
+ | C-Eval | 61.6 | 76.1 | **83.8** |
172
+ | AlignBench | 7.42 | 7.28 | **8.27** |
173
+
174
+ ## Citation
175
+
176
+ If you find our work helpful, feel free to give us a cite.
177
+
178
+ ```
179
+ @article{qwen2,
180
+ title={Qwen2 Technical Report},
181
+ year={2024}
182
+ }
183
+ ```