billatsectorflow commited on
Commit
bad14b8
·
1 Parent(s): 19bf1c5
README.md CHANGED
@@ -1,5 +1,148 @@
1
- ---
2
- license: other
3
- license_name: tongyi-qianwen
4
- license_link: https://huggingface.co/Qwen/Qwen2-72B-Instruct-GPTQ-Int4/blob/main/LICENSE
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: tongyi-qianwen
4
+ license_link: https://huggingface.co/Qwen/Qwen2-72B-Instruct-GPTQ-Int4/blob/main/LICENSE
5
+ language:
6
+ - en
7
+ pipeline_tag: text-generation
8
+ tags:
9
+ - chat
10
+ ---
11
+
12
+ # Qwen2-72B-Instruct-GPTQ-Int4
13
+
14
+ ## Introduction
15
+
16
+ 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.
17
+
18
+ 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.
19
+
20
+ Qwen2-72B-Instruct-GPTQ-Int4 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.
21
+
22
+ 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/).
23
+ <br>
24
+
25
+ ## Model Details
26
+ 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.
27
+
28
+ ## Training details
29
+ We pretrained the models with a large amount of data, and we post-trained the models with both supervised finetuning and direct preference optimization.
30
+
31
+
32
+ ## Requirements
33
+ 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:
34
+ ```
35
+ KeyError: 'qwen2'
36
+ ```
37
+
38
+ ## Quickstart
39
+
40
+ Here provides a code snippet with `apply_chat_template` to show you how to load the tokenizer and model and how to generate contents.
41
+
42
+ ```python
43
+ from transformers import AutoModelForCausalLM, AutoTokenizer
44
+ device = "cuda" # the device to load the model onto
45
+
46
+ model = AutoModelForCausalLM.from_pretrained(
47
+ "Qwen/Qwen2-72B-Instruct-GPTQ-Int4",
48
+ torch_dtype="auto",
49
+ device_map="auto"
50
+ )
51
+ tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen2-72B-Instruct-GPTQ-Int4")
52
+
53
+ prompt = "Give me a short introduction to large language model."
54
+ messages = [
55
+ {"role": "system", "content": "You are a helpful assistant."},
56
+ {"role": "user", "content": prompt}
57
+ ]
58
+ text = tokenizer.apply_chat_template(
59
+ messages,
60
+ tokenize=False,
61
+ add_generation_prompt=True
62
+ )
63
+ model_inputs = tokenizer([text], return_tensors="pt").to(device)
64
+
65
+ generated_ids = model.generate(
66
+ model_inputs.input_ids,
67
+ max_new_tokens=512
68
+ )
69
+ generated_ids = [
70
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
71
+ ]
72
+
73
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
74
+ ```
75
+
76
+ ### Processing Long Texts
77
+
78
+ 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.
79
+
80
+ For deployment, we recommend using vLLM. You can enable the long-context capabilities by following these steps:
81
+
82
+ 1. **Install vLLM**: You can install vLLM by running the following command.
83
+
84
+ ```bash
85
+ pip install "vllm>=0.4.3"
86
+ ```
87
+
88
+ Or you can install vLLM from [source](https://github.com/vllm-project/vllm/).
89
+
90
+ 2. **Configure Model Settings**: After downloading the model weights, modify the `config.json` file by including the below snippet:
91
+ ```json
92
+ {
93
+ "architectures": [
94
+ "Qwen2ForCausalLM"
95
+ ],
96
+ // ...
97
+ "vocab_size": 152064,
98
+
99
+ // adding the following snippets
100
+ "rope_scaling": {
101
+ "factor": 4.0,
102
+ "original_max_position_embeddings": 32768,
103
+ "type": "yarn"
104
+ }
105
+ }
106
+ ```
107
+ This snippet enable YARN to support longer contexts.
108
+
109
+ 3. **Model Deployment**: Utilize vLLM to deploy your model. For instance, you can set up an openAI-like server using the command:
110
+
111
+ ```bash
112
+ python -m vllm.entrypoints.openai.api_server --served-model-name Qwen2-72B-Instruct-GPTQ-Int4 --model path/to/weights
113
+ ```
114
+
115
+ Then you can access the Chat API by:
116
+
117
+ ```bash
118
+ curl http://localhost:8000/v1/chat/completions \
119
+ -H "Content-Type: application/json" \
120
+ -d '{
121
+ "model": "Qwen2-72B-Instruct-GPTQ-Int4",
122
+ "messages": [
123
+ {"role": "system", "content": "You are a helpful assistant."},
124
+ {"role": "user", "content": "Your Long Input Here."}
125
+ ]
126
+ }'
127
+ ```
128
+
129
+ For further usage instructions of vLLM, please refer to our [Github](https://github.com/QwenLM/Qwen2).
130
+
131
+ **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.
132
+
133
+ ## Benchmark and Speed
134
+
135
+ To compare the generation performance between bfloat16 (bf16) and quantized models such as GPTQ-Int8, GPTQ-Int4, and AWQ, please consult our [Benchmark of Quantized Models](https://qwen.readthedocs.io/en/latest/benchmark/quantization_benchmark.html). This benchmark provides insights into how different quantization techniques affect model performance.
136
+
137
+ For those interested in understanding the inference speed and memory consumption when deploying these models with either ``transformer`` or ``vLLM``, we have compiled an extensive [Speed Benchmark](https://qwen.readthedocs.io/en/latest/benchmark/speed_benchmark.html).
138
+
139
+ ## Citation
140
+
141
+ If you find our work helpful, feel free to give us a cite.
142
+
143
+ ```
144
+ @article{qwen2,
145
+ title={Qwen2 Technical Report},
146
+ year={2024}
147
+ }
148
+ ```
config.json ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": 8192,
10
+ "initializer_range": 0.02,
11
+ "intermediate_size": 29696,
12
+ "max_position_embeddings": 32768,
13
+ "max_window_layers": 80,
14
+ "model_type": "qwen2",
15
+ "num_attention_heads": 64,
16
+ "num_hidden_layers": 80,
17
+ "num_key_value_heads": 8,
18
+ "quantization_config": {
19
+ "batch_size": 1,
20
+ "bits": 4,
21
+ "block_name_to_quantize": null,
22
+ "cache_block_outputs": true,
23
+ "damp_percent": 0.01,
24
+ "dataset": null,
25
+ "desc_act": false,
26
+ "exllama_config": {
27
+ "version": 2
28
+ },
29
+ "group_size": 128,
30
+ "max_input_length": null,
31
+ "model_seqlen": null,
32
+ "module_name_preceding_first_block": null,
33
+ "modules_in_block_to_quantize": null,
34
+ "pad_token_id": null,
35
+ "quant_method": "gptq",
36
+ "sym": true,
37
+ "tokenizer": null,
38
+ "true_sequential": true,
39
+ "use_cuda_fp16": false,
40
+ "use_exllama": true
41
+ },
42
+ "rms_norm_eps": 1e-06,
43
+ "rope_theta": 1000000.0,
44
+ "sliding_window": 131072,
45
+ "tie_word_embeddings": false,
46
+ "torch_dtype": "float16",
47
+ "transformers_version": "4.37.0",
48
+ "use_cache": true,
49
+ "use_sliding_window": false,
50
+ "vocab_size": 152064,
51
+
52
+ "rope_scaling": {
53
+ "factor": 4.0,
54
+ "original_max_position_embeddings": 32768,
55
+ "type": "yarn"
56
+ }
57
+ }
generation_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 151643,
3
+ "do_sample": true,
4
+ "eos_token_id": [
5
+ 151645,
6
+ 151643
7
+ ],
8
+ "pad_token_id": 151643,
9
+ "repetition_penalty": 1.05,
10
+ "temperature": 0.7,
11
+ "top_k": 20,
12
+ "top_p": 0.8,
13
+ "transformers_version": "4.40.2"
14
+ }
huggingface-metadata.txt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ url: https://huggingface.co/Qwen/Qwen2-72B-Instruct-GPTQ-Int4
2
+ branch: main
3
+ download date: 2024-07-10 06:11:46
4
+ sha256sum:
5
+ 262ce9325acdea17c564be7933cb6456955945efc0b286607d867934fadaca8a model-00001-of-00011.safetensors
6
+ 7c2de142222d1a8e87054442cb3e3acc3b26a93774e0adf6f30ae49bdcc17d76 model-00002-of-00011.safetensors
7
+ ee1f768f7a4e4de5dccb8a6e61cd0a8172e4f363daed9f607e11aa5b59fb167e model-00003-of-00011.safetensors
8
+ e4a0c0a0c8aaa9915935d07b42aa0d3e834459d6092828fd9a248ba48c367d38 model-00004-of-00011.safetensors
9
+ b80e95dd6478e8350ff6773eac6fed77ec4e05f980e8e38136e6e40d494ca1e0 model-00005-of-00011.safetensors
10
+ 9ccd338387671eba52a02fa30157c3fe3e83bbd48bed3f2d92e7ab8b3a4a8cbe model-00006-of-00011.safetensors
11
+ 30a2a735013bffa5d2c921e402bdfbdfecb57773ea076bc5c1daa119a330958d model-00007-of-00011.safetensors
12
+ d23b3bb7f6c3915dbb56d784a82cfcdf5b561c610e392256ccc8f857bd99d0e3 model-00008-of-00011.safetensors
13
+ 2b975c12e8355b067d77c719f268f7fc22c216e90851846ab74fd82d8560a1c8 model-00009-of-00011.safetensors
14
+ ba89ea9571a1810e0dc30ea0bd4f62534d12ef893014ce39c568af261fbbbce5 model-00010-of-00011.safetensors
15
+ a2daf3b842c34c1935313c44d1cedda4ac3fe209bb4fb2d6d22c48ed03febf56 model-00011-of-00011.safetensors
merges.txt ADDED
The diff for this file is too large to render. See raw diff
 
model-00001-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:262ce9325acdea17c564be7933cb6456955945efc0b286607d867934fadaca8a
3
+ size 3944421728
model-00002-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c2de142222d1a8e87054442cb3e3acc3b26a93774e0adf6f30ae49bdcc17d76
3
+ size 3918036320
model-00003-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ee1f768f7a4e4de5dccb8a6e61cd0a8172e4f363daed9f607e11aa5b59fb167e
3
+ size 3996686352
model-00004-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e4a0c0a0c8aaa9915935d07b42aa0d3e834459d6092828fd9a248ba48c367d38
3
+ size 3996643360
model-00005-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b80e95dd6478e8350ff6773eac6fed77ec4e05f980e8e38136e6e40d494ca1e0
3
+ size 3918036576
model-00006-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ccd338387671eba52a02fa30157c3fe3e83bbd48bed3f2d92e7ab8b3a4a8cbe
3
+ size 3996686352
model-00007-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:30a2a735013bffa5d2c921e402bdfbdfecb57773ea076bc5c1daa119a330958d
3
+ size 3996643360
model-00008-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d23b3bb7f6c3915dbb56d784a82cfcdf5b561c610e392256ccc8f857bd99d0e3
3
+ size 3918036576
model-00009-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b975c12e8355b067d77c719f268f7fc22c216e90851846ab74fd82d8560a1c8
3
+ size 3996686352
model-00010-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ba89ea9571a1810e0dc30ea0bd4f62534d12ef893014ce39c568af261fbbbce5
3
+ size 3459913552
model-00011-of-00011.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a2daf3b842c34c1935313c44d1cedda4ac3fe209bb4fb2d6d22c48ed03febf56
3
+ size 2491416704
model.safetensors.index.json ADDED
The diff for this file is too large to render. See raw diff
 
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