wenhuach commited on
Commit
86a7577
1 Parent(s): cb9f534

first commit

Browse files

Signed-off-by: wenhuach <[email protected]>

README.md CHANGED
@@ -1,3 +1,98 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Model Details
2
+
3
+ This model is an int4 model with group_size 32 sym of [Qwen/Qwen2-0.5B-Instruct](https://huggingface.co/Qwen/Qwen2-0.5B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round), we will generate group_size 128 later
4
+
5
+ ## How To Use
6
+
7
+ ### INT4 Inference with AutoGPTQ
8
+
9
+
10
+
11
+ ```python
12
+ ##pip install auto-gptq==0.7.1
13
+ from transformers import AutoModelForCausalLM,AutoTokenizer
14
+ quantized_model_dir = "Intel/Qwen2-0.5B-int4-inc"
15
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
16
+ model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
17
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
18
+ text = "There is a girl who likes adventure,"
19
+ text = "Once upon a time,"
20
+ inputs = tokenizer(text, return_tensors="pt").to(model.device)
21
+ print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50, do_sample=False)[0]))
22
+ ##There is a girl who likes adventure, and she is a bit of a dreamer. She is a dreamer who dreams of adventure. She is a dreamer who dreams of adventure. She is a dreamer who dreams of adventure. She is a dreamer who dreams of adventure.
23
+
24
+ ##Once upon a time, I was a very busy person. I had a full-time job, a family, and a full schedule. I was always on the go, and I was always trying to do everything. I was always trying to be the best at everything. I
25
+ ```
26
+
27
+
28
+
29
+ ### Evaluate the model
30
+
31
+ pip3 install lm-eval==0.4.2
32
+
33
+ ```bash
34
+ lm_eval --model hf --model_args pretrained="Intel/Qwen2-0.5B-Instuct-int4-inc" --device cuda:0 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu --batch_size 16
35
+ ```
36
+
37
+ | Metric0.5B-instruct | BF16 | W4G32 asym |
38
+ | ------------------- | ------ | ---------- |
39
+ | Avg | 0.4562 | 0.4506 |
40
+ | mmlu | 0.4342 | 0.4205 |
41
+ | lambada_openai | 0.5057 | 0.4890 |
42
+ | hellaswag | 0.3899 | 0.3843 |
43
+ | winogrande | 0.5549 | 0.5643 |
44
+ | piqa | 0.6926 | 0.6861 |
45
+ | truthfulqa_mc1 | 0.2607 | 0.2460 |
46
+ | openbookqa | 0.242 | 0.2440 |
47
+ | boolq | 0.6306 | 0.6257 |
48
+ | arc_easy | 0.5871 | 0.5867 |
49
+ | arc_challenge | 0.2645 | 0.2594 |
50
+
51
+ ### Reproduce the model
52
+
53
+ Here is the sample command to reproduce the model
54
+
55
+ ```bash
56
+ git clone https://github.com/intel/auto-round
57
+ cd auto-round/examples/language-modeling
58
+ pip install -r requirements.txt
59
+ python3 main.py \
60
+ --model_name Qwen/Qwen2-0.5B-Instruct \
61
+ --device 0 \
62
+ --group_size 32 \
63
+ --bits 4 \
64
+ --sym \
65
+ --iter 1000 \
66
+ --minmax_lr 2e-3 \
67
+ --deployment_device 'gpu' \
68
+ --output_dir "./tmp_autoround"
69
+ ```
70
+
71
+
72
+
73
+ ## Ethical Considerations and Limitations
74
+
75
+ The model can produce factually incorrect output, and should not be relied on to produce factually accurate information. Because of the limitations of the pretrained model and the finetuning datasets, it is possible that this model could generate lewd, biased or otherwise offensive outputs.
76
+
77
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
78
+
79
+ ## Caveats and Recommendations
80
+
81
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
82
+
83
+ Here are a couple of useful links to learn more about Intel's AI software:
84
+
85
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
86
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
87
+
88
+ ## Disclaimer
89
+
90
+ The license on this model does not constitute legal advice. We are not responsible for the actions of third parties who use this model. Please consult an attorney before using this model for commercial purposes.
91
+
92
+
93
+
94
+ ## Cite
95
+
96
+ @article{cheng2023optimize, title={Optimize weight rounding via signed gradient descent for the quantization of llms}, author={Cheng, Wenhua and Zhang, Weiwei and Shen, Haihao and Cai, Yiyang and He, Xin and Lv, Kaokao and Liu, Yi}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
97
+
98
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
added_tokens.json ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {
2
+ "<|endoftext|>": 151643,
3
+ "<|im_end|>": 151645,
4
+ "<|im_start|>": 151644
5
+ }
config.json ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_name_or_path": "/models/Qwen2-0.5B-Instruct",
3
+ "architectures": [
4
+ "Qwen2ForCausalLM"
5
+ ],
6
+ "attention_dropout": 0.0,
7
+ "bos_token_id": 151643,
8
+ "eos_token_id": 151645,
9
+ "hidden_act": "silu",
10
+ "hidden_size": 896,
11
+ "initializer_range": 0.02,
12
+ "intermediate_size": 4864,
13
+ "max_position_embeddings": 32768,
14
+ "max_window_layers": 21,
15
+ "model_type": "qwen2",
16
+ "num_attention_heads": 14,
17
+ "num_hidden_layers": 24,
18
+ "num_key_value_heads": 2,
19
+ "quantization_config": {
20
+ "autoround_version": "0.2.1.dev",
21
+ "bits": 4,
22
+ "damp_percent": 0.01,
23
+ "desc_act": false,
24
+ "enable_minmax_tuning": true,
25
+ "enable_quanted_input": true,
26
+ "group_size": 32,
27
+ "is_marlin_format": false,
28
+ "iters": 1000,
29
+ "lr": 0.001,
30
+ "minmax_lr": 0.002,
31
+ "model_file_base_name": "model",
32
+ "model_name_or_path": null,
33
+ "quant_method": "gptq",
34
+ "scale_dtype": "float16",
35
+ "static_groups": false,
36
+ "sym": true,
37
+ "true_sequential": false
38
+ },
39
+ "rms_norm_eps": 1e-06,
40
+ "rope_theta": 1000000.0,
41
+ "sliding_window": 32768,
42
+ "tie_word_embeddings": true,
43
+ "torch_dtype": "bfloat16",
44
+ "transformers_version": "4.40.0",
45
+ "use_cache": true,
46
+ "use_sliding_window": false,
47
+ "vocab_size": 151936
48
+ }
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:b01ae3316495f28bf1ac6c20baafca5131761477bd34877df198c5f0b58accc7
3
+ size 753182960
quantize_config.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bits": 4,
3
+ "group_size": 32,
4
+ "damp_percent": 0.01,
5
+ "desc_act": false,
6
+ "static_groups": false,
7
+ "sym": true,
8
+ "true_sequential": false,
9
+ "model_name_or_path": null,
10
+ "model_file_base_name": "model",
11
+ "is_marlin_format": false,
12
+ "quant_method": "intel/auto-round",
13
+ "autoround_version": "0.2.1.dev",
14
+ "iters": 1000,
15
+ "lr": 0.001,
16
+ "minmax_lr": 0.002,
17
+ "enable_minmax_tuning": true,
18
+ "enable_quanted_input": true,
19
+ "scale_dtype": "float16"
20
+ }
special_tokens_map.json ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "additional_special_tokens": [
3
+ "<|im_start|>",
4
+ "<|im_end|>"
5
+ ],
6
+ "eos_token": {
7
+ "content": "<|im_end|>",
8
+ "lstrip": false,
9
+ "normalized": false,
10
+ "rstrip": false,
11
+ "single_word": false
12
+ },
13
+ "pad_token": {
14
+ "content": "<|endoftext|>",
15
+ "lstrip": false,
16
+ "normalized": false,
17
+ "rstrip": false,
18
+ "single_word": false
19
+ }
20
+ }
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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": [
30
+ "<|im_start|>",
31
+ "<|im_end|>"
32
+ ],
33
+ "bos_token": null,
34
+ "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 %}",
35
+ "clean_up_tokenization_spaces": false,
36
+ "eos_token": "<|im_end|>",
37
+ "errors": "replace",
38
+ "model_max_length": 32768,
39
+ "pad_token": "<|endoftext|>",
40
+ "split_special_tokens": false,
41
+ "tokenizer_class": "Qwen2Tokenizer",
42
+ "unk_token": null
43
+ }
vocab.json ADDED
The diff for this file is too large to render. See raw diff