add readme
Browse filesSigned-off-by: wenhuach <[email protected]>
README.md
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Model Details
|
2 |
+
|
3 |
+
This model is an int4 model with group_size128 and sym quantization of [microsoft/phi-2](https://huggingface.co/microsoft/phi-2) generated by [intel/auto-round](https://github.com/intel/auto-round). We found there is a large accuracy drop of asym kernel for this model.
|
4 |
+
|
5 |
+
|
6 |
+
|
7 |
+
### Use the model
|
8 |
+
|
9 |
+
### INT4 Inference with AutoGPTQ
|
10 |
+
|
11 |
+
pip install auto-gptq
|
12 |
+
|
13 |
+
```python
|
14 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
15 |
+
quantized_model_dir = "Intel/phi-2-int4-inc"
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
|
17 |
+
model = AutoModelForCausalLM.from_pretrained(quantized_model_dir, device_map="auto", trust_remote_code=True)
|
18 |
+
text = "There is a girl who likes adventure,"
|
19 |
+
inputs = tokenizer(text, return_tensors="pt", return_attention_mask=False).to(model.device)
|
20 |
+
outputs = model.generate(**inputs, max_new_tokens=50)
|
21 |
+
text = tokenizer.batch_decode(outputs)[0]
|
22 |
+
print(text)
|
23 |
+
"""
|
24 |
+
There is a girl who likes adventure,
|
25 |
+
She loves to explore and to venture.
|
26 |
+
She travels to faraway lands,
|
27 |
+
And meets people from different lands.
|
28 |
+
She learns new languages and cultures,
|
29 |
+
And makes friends with all kinds of people.
|
30 |
+
She is curious and brave and
|
31 |
+
"""
|
32 |
+
```
|
33 |
+
|
34 |
+
|
35 |
+
|
36 |
+
### Evaluate the model
|
37 |
+
|
38 |
+
pip install lm-eval==0.4.2
|
39 |
+
|
40 |
+
~~bash
|
41 |
+
lm_eval --model hf --model_args pretrained="Intel/phi-2-int4-inc" --device cuda:0 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu --batch_size 16
|
42 |
+
~~
|
43 |
+
|
44 |
+
|
45 |
+
|
46 |
+
| Metric | FP16 | INT4 |
|
47 |
+
| -------------- | ------ | ------ |
|
48 |
+
| Avg. | 0.6131 | 0.6062 |
|
49 |
+
| mmlu | 0.5334 | 0.5241 |
|
50 |
+
| lambada_openai | 0.6243 | 0.6039 |
|
51 |
+
| hellaswag | 0.5581 | 0.5487 |
|
52 |
+
| winogrande | 0.7522 | 0.7585 |
|
53 |
+
| piqa | 0.7867 | 0.7840 |
|
54 |
+
| truthfulqa_mc1 | 0.3097 | 0.2974 |
|
55 |
+
| openbookqa | 0.4040 | 0.3960 |
|
56 |
+
| boolq | 0.8346 | 0.8346 |
|
57 |
+
| arc_easy | 0.8001 | 0.8013 |
|
58 |
+
| arc_challenge | 0.5282 | 0.5137 |
|
59 |
+
|
60 |
+
##
|
61 |
+
|
62 |
+
### Reproduce the model
|
63 |
+
|
64 |
+
Here is the sample command to reproduce the model
|
65 |
+
|
66 |
+
```bash
|
67 |
+
git clone https://github.com/intel/auto-round
|
68 |
+
cd auto-round/examples/language-modeling
|
69 |
+
pip install -r requirements.txt
|
70 |
+
python3 main.py \
|
71 |
+
--model_name microsoft/phi-2 \
|
72 |
+
--device 0 \
|
73 |
+
--group_size 128 \
|
74 |
+
--bits 4 \
|
75 |
+
--iters 1000 \
|
76 |
+
--sym \
|
77 |
+
--deployment_device 'gpu' \
|
78 |
+
--disable_low_gpu_mem_usage \
|
79 |
+
--output_dir "./tmp_autoround" \
|
80 |
+
```
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
## Ethical Considerations and Limitations
|
85 |
+
|
86 |
+
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.
|
87 |
+
|
88 |
+
Therefore, before deploying any applications of the model, developers should perform safety testing.
|
89 |
+
|
90 |
+
## Caveats and Recommendations
|
91 |
+
|
92 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
93 |
+
|
94 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
95 |
+
|
96 |
+
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
97 |
+
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
98 |
+
|
99 |
+
## Disclaimer
|
100 |
+
|
101 |
+
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.
|
102 |
+
|
103 |
+
|