Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,106 @@
|
|
1 |
-
---
|
2 |
-
license: mit
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: mit
|
3 |
+
datasets:
|
4 |
+
- NeelNanda/pile-10k
|
5 |
+
language:
|
6 |
+
- en
|
7 |
+
---
|
8 |
+
|
9 |
+
|
10 |
+
## Model Details
|
11 |
+
|
12 |
+
This model is an int4 model with group_size 128 of [microsoft/Phi-3-mini-128k-instruct](https://huggingface.co/microsoft/Phi-3-mini-128k-instruct) generated by [intel/auto-round](https://github.com/intel/auto-round).
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
### INT4 Inference with AutoGPTQ's Kernel
|
17 |
+
|
18 |
+
```python
|
19 |
+
##pip install auto-gptq[triton]
|
20 |
+
##pip install triton==2.2.0
|
21 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
22 |
+
quantized_model_dir = "Intel/Phi-3-mini-128k-instruct-int4-inc"
|
23 |
+
model = AutoModelForCausalLM.from_pretrained(quantized_model_dir,
|
24 |
+
device_map="auto",
|
25 |
+
trust_remote_code=False,
|
26 |
+
)
|
27 |
+
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir, use_fast=True)
|
28 |
+
print(tokenizer.decode(model.generate(**tokenizer("There is a girl who likes adventure,", return_tensors="pt").to(model.device),max_new_tokens=50)[0]))
|
29 |
+
```
|
30 |
+
|
31 |
+
|
32 |
+
|
33 |
+
### Evaluate the model
|
34 |
+
|
35 |
+
Install [lm-eval-harness](https://github.com/EleutherAI/lm-evaluation-harness.git) from source, we used the git id 96d185fa6232a5ab685ba7c43e45d1dbb3bb906d
|
36 |
+
|
37 |
+
```bash
|
38 |
+
lm_eval --model hf --model_args pretrained="Intel/Phi-3-mini-128k-instruct-int4-inc",autogptq=True,gptq_use_triton=True --device cuda:0 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu --batch_size 32
|
39 |
+
```
|
40 |
+
|
41 |
+
| Metric | BF16 | INT4 |
|
42 |
+
| -------------- | ------ | ------ |
|
43 |
+
| Avg. | 0.6365 | 0.6300 |
|
44 |
+
| mmlu | 0.6247 | 0.6237 |
|
45 |
+
| lambada_openai | 0.6652 | 0.6433 |
|
46 |
+
| hellaswag | 0.5978 | 0.5859 |
|
47 |
+
| winogrande | 0.7277 | 0.7230 |
|
48 |
+
| piqa | 0.7895 | 0.7846 |
|
49 |
+
| truthfulqa_mc1 | 0.3562 | 0.3562 |
|
50 |
+
| openbookqa | 0.3900 | 0.3800 |
|
51 |
+
| boolq | 0.8557 | 0.8489 |
|
52 |
+
| arc_easy | 0.8140 | 0.8199 |
|
53 |
+
| arc_challenge | 0.5444 | 0.5350 |
|
54 |
+
|
55 |
+
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
+
### Reproduce the model
|
60 |
+
|
61 |
+
Here is the sample command to reproduce the model
|
62 |
+
|
63 |
+
```bash
|
64 |
+
git clone https://github.com/intel/auto-round
|
65 |
+
cd auto-round/examples/language-modeling
|
66 |
+
pip install -r requirements.txt
|
67 |
+
python3 main.py \
|
68 |
+
--model_name microsoft/Phi-3-mini-128k-instruct \
|
69 |
+
--device 0 \
|
70 |
+
--group_size 128 \
|
71 |
+
--bits 4 \
|
72 |
+
--iters 200 \
|
73 |
+
--seqlen 4096 \
|
74 |
+
--minmax_lr 0.01 \
|
75 |
+
--deployment_device 'gpu' \
|
76 |
+
--gradient_accumulate_steps 2 \
|
77 |
+
--train_bs 4 \
|
78 |
+
--output_dir "./tmp_autoround" \
|
79 |
+
|
80 |
+
```
|
81 |
+
|
82 |
+
|
83 |
+
|
84 |
+
|
85 |
+
## Caveats and Recommendations
|
86 |
+
|
87 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
88 |
+
|
89 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
90 |
+
|
91 |
+
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
92 |
+
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
93 |
+
|
94 |
+
|
95 |
+
|
96 |
+
## Disclaimer
|
97 |
+
|
98 |
+
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.
|
99 |
+
|
100 |
+
|
101 |
+
|
102 |
+
## Cite
|
103 |
+
|
104 |
+
@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}, journal={arXiv preprint arXiv:2309.05516}, year={2023} }
|
105 |
+
|
106 |
+
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
|