wenhuach commited on
Commit
4ea3d16
·
1 Parent(s): 3516d2e

add readme

Browse files

Signed-off-by: wenhuach <wenhuach87@gmail.com>

Files changed (1) hide show
  1. README.md +102 -3
README.md CHANGED
@@ -1,3 +1,102 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+
5
+
6
+
7
+ ## Model Details
8
+
9
+ This model is an int4 model with group_size 128 of [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) generated by [intel/auto-round](https://github.com/intel/auto-round).
10
+
11
+ ## How To Use
12
+
13
+ ### Reproduce the model
14
+
15
+ Here is the sample command to reproduce the model
16
+
17
+ ```bash
18
+ git clone https://github.com/intel/auto-round
19
+ cd auto-round/examples/language-modeling
20
+ pip install -r requirements.txt
21
+ python3 main.py \
22
+ --model_name microsoft/phi-2 \
23
+ --device 0 \
24
+ --group_size 128 \
25
+ --bits 4 \
26
+ --iters 1000 \
27
+ --enable_minmax_tuning \
28
+ --low_gpu_mem_usage \
29
+ --deployment_device 'gpu' \
30
+ --scale_dtype 'fp32' \
31
+ --eval_bs 32 \
32
+ --output_dir "./tmp_autoround" \
33
+ --amp
34
+
35
+ ```
36
+
37
+
38
+
39
+ ### Use the model
40
+
41
+ ### INT4 Inference with AutoGPTQ
42
+
43
+ Install [AutoGPTQ](https://github.com/AutoGPTQ/AutoGPTQ) from source first
44
+
45
+ ```python
46
+ from transformers import AutoModelForCausalLM, AutoTokenizer
47
+ quantized_model_dir = "Intel/phi-2-int4-inc"
48
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
49
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True)
50
+ text = "There is a girl who likes adventure,"
51
+ inputs = tokenizer(text, return_tensors="pt", return_attention_mask=False).to(model.device)
52
+ outputs = model.generate(**inputs, max_length=50)
53
+ text = tokenizer.batch_decode(outputs)[0]
54
+ ```
55
+
56
+
57
+
58
+ ### Evaluate the model
59
+
60
+ Install [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness.git) from source, and the git id f3b7917091afba325af3980a35d8a6dcba03dc3f is used
61
+
62
+ Since we encountered an issue evaluating this model with lm-eval, we opted to evaluate the qdq model instead. In our assessment, we found that its accuracy closely matches that of the real quantized model in most cases except for some small models like opt-125m.
63
+
64
+
65
+
66
+ | Metric | FP16 | INT4 |
67
+ | -------------- | ------ | ------ |
68
+ | Avg. | 0.6155 | 0.6163 |
69
+ | mmlu | 0.5448 | 0.5417 |
70
+ | lambada_openai | 0.6268 | 0.6225 |
71
+ | hellaswag | 0.5585 | 0.5498 |
72
+ | winogrande | 0.7530 | 0.7545 |
73
+ | piqa | 0.7867 | 0.7824 |
74
+ | truthfulqa_mc1 | 0.3133 | 0.3060 |
75
+ | openbookqa | 0.4000 | 0.4100 |
76
+ | boolq | 0.8339 | 0.8327 |
77
+ | rte | 0.6245 | 0.6643 |
78
+ | arc_easy | 0.7997 | 0.7955 |
79
+ | arc_challenge | 0.5290 | 0.5196 |
80
+
81
+
82
+
83
+ ## Ethical Considerations and Limitations
84
+
85
+ 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.
86
+
87
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
88
+
89
+ ## Caveats and Recommendations
90
+
91
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
92
+
93
+ Here are a couple of useful links to learn more about Intel's AI software:
94
+
95
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
96
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
97
+
98
+ ## Disclaimer
99
+
100
+ 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.
101
+
102
+