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