OPEA
/

Safetensors
llama
2-bit
intel/auto-round
cicdatopea commited on
Commit
6616a74
·
verified ·
1 Parent(s): 192d2db

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +165 -3
README.md CHANGED
@@ -1,3 +1,165 @@
1
- ---
2
- license: llama3.3
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.3
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ ---
6
+
7
+
8
+ ## Model Details
9
+
10
+ This model is an int2 model with group_size 32and symmetric quantization of [meta-llama/Llama-3.3-70B-Instruct](https://huggingface.co/meta-llama/Llama-3.3-70B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision `3ba7fab` to use AutoGPTQ format. We may consider changing the group_size or adopting mixed-bit quantization in the future to address the significant accuracy gap observed in certain tasks
11
+
12
+ ## How To Use
13
+
14
+ ### Inference on CPU/HPU/CUDA
15
+
16
+ HPU: docker image with Gaudi Software Stack is recommended, please refer to following script for environment setup. More details can be found in [Gaudi Guide](https://docs.habana.ai/en/latest/Installation_Guide/Bare_Metal_Fresh_OS.html#launch-docker-image-that-was-built).
17
+
18
+ ```python
19
+ from auto_round import AutoHfQuantizer ##must import for auto-round format
20
+ import torch
21
+ from transformers import AutoModelForCausalLM,AutoTokenizer
22
+ quantized_model_dir = "OPEA/Llama-3.3-70B-Instruct-int4-sym-inc"
23
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
24
+
25
+ model = AutoModelForCausalLM.from_pretrained(
26
+ quantized_model_dir,
27
+ torch_dtype='auto',
28
+ device_map="auto",
29
+ ##revision="3ba7fab", ##AutoGPTQ format
30
+ )
31
+
32
+ ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
33
+ ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
34
+ ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
35
+
36
+ prompt = "There is a girl who likes adventure,"
37
+ messages = [
38
+ {"role": "system", "content": "You are a helpful assistant."},
39
+ {"role": "user", "content": prompt}
40
+ ]
41
+
42
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
43
+ text = tokenizer.apply_chat_template(
44
+ messages,
45
+ tokenize=False,
46
+ add_generation_prompt=True
47
+ )
48
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
49
+
50
+ generated_ids = model.generate(
51
+ model_inputs.input_ids,
52
+ max_new_tokens=200, ##change this to align with the official usage
53
+ do_sample=False ##change this to align with the official usage
54
+ )
55
+ generated_ids = [
56
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
57
+ ]
58
+
59
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
60
+ print(response)
61
+ ##INT2:
62
+ ## That sounds exciting! What kind of adventures does she enjoy? Is she into hiking, traveling, trying new foods, or something else? Tell me more about her!
63
+
64
+ ##BF16:
65
+ ## That sounds like the start of an exciting story. The girl who likes adventure, let's call her Alex, is probably always looking for her next thrill. She might enjoy activities like hiking, rock climbing, or exploring new places. Perhaps she's always been drawn to the unknown and loves to challenge herself to try new things.
66
+
67
+ prompt = "Which one is larger, 9.11 or 9.8"
68
+ ##INT2:
69
+ ## 9.11 is larger than 9.8.
70
+
71
+ ##BF16:
72
+ ## 9.11 is larger than 9.8.
73
+
74
+ prompt = "How many r in strawberry."
75
+ ##INT2:
76
+ ## There are 2 R's in the word "strawberry".
77
+
78
+ ##BF16:
79
+ ## There are 2 R's in the word "strawberry".
80
+
81
+ prompt = "Once upon a time,"
82
+ ##INT2:
83
+ ## It seems like you're starting a story! I'd love to hear more. Please go on...
84
+
85
+ ##BF16:
86
+ ## ...in a far-off kingdom, where the sun dipped into the horizon and painted the sky with hues of crimson and gold, there lived a young adventurer named Sophia. She had hair as black as the night and eyes as blue as the clearest summer sky. Sophia was known throughout the land for her bravery, kindness, and insatiable curiosity.
87
+ ## What would you like to happen next in the story? Would you like Sophia to:
88
+ ## A) Embark on a quest to find a legendary treasure
89
+ ## B) Encounter a mysterious stranger with a hidden agenda
90
+ ## C) Discover a magical forest filled with ancient secrets
91
+ ## D) Something entirely different (please specify)
92
+ ## Choose your response to progress the story!
93
+ ```
94
+
95
+
96
+
97
+ ### Evaluate the model
98
+
99
+ pip3 install lm-eval==0.4.5
100
+
101
+ ```bash
102
+ auto-round --eval --model "OPEA/Llama-3.3-70B-Instruct-int4-sym-inc" --eval_bs 64 --tasks leaderboard_mmlu_pro,leaderboard_ifeval,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k
103
+ ```
104
+
105
+ | Metric | BF16 | INT2G32 |
106
+ | :------------------------: | :----------------------: | :---------------: |
107
+ | avg | 0.7023 | |
108
+ | leaderboard_mmlu_pro 5shot | 0.5484 | 0.4384 |
109
+ | mmlu | 0.8195 | 0.7142 |
110
+ | lambada_openai | 0.7528 | 0.7013 |
111
+ | hellaswag | 0.6575 | 0.5576 |
112
+ | winogrande | 0.7869 | 0.7080 |
113
+ | piqa | 0.8303 | 0.7797 |
114
+ | truthfulqa_mc1 | 0.4284 | 0.3586 |
115
+ | openbookqa | 0.3720 | 0.3000 |
116
+ | boolq | 0.8865 | 0.8339 |
117
+ | arc_easy | 0.8624 | 0.8064 |
118
+ | arc_challenge | 0.6109 | 0.5188 |
119
+ | leaderboard_ifeval | 0.6661=(0.7110+0.6211)/2 | (0.5959+0.4603)/2 |
120
+ | gsm8k(5shot) strict match | 0.9083 | |
121
+
122
+ ## Generate the model
123
+
124
+ Here is the sample command to generate the model. We found that AutoRound is highly unstable for 2-bit quantization of this model, requiring careful tuning of certain hyperparameters. We recommend mixed-bits quantization or trying some other more complex tuning algorithms.
125
+
126
+ ```bash
127
+ auto-round \
128
+ --model meta-llama/Llama-3.3-70B-Instruct \
129
+ --device 0 \
130
+ --group_size 32 \
131
+ --nsamples 1024 \
132
+ --bits 4 \
133
+ --iter 2000 \
134
+ --disable_eval \
135
+ --enable_norm_bias_tuning \
136
+ --low_gpu_mem_usage \
137
+ --format 'auto_gptq,auto_round' \
138
+ --output_dir "./tmp_autoround"
139
+ ```
140
+
141
+
142
+
143
+ ## Ethical Considerations and Limitations
144
+
145
+ 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.
146
+
147
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
148
+
149
+ ## Caveats and Recommendations
150
+
151
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
152
+
153
+ Here are a couple of useful links to learn more about Intel's AI software:
154
+
155
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
156
+
157
+ ## Disclaimer
158
+
159
+ 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.
160
+
161
+ ## Cite
162
+
163
+ @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} }
164
+
165
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)