OPEA
/

Safetensors
llama
4-bit precision
intel/auto-round
cicdatopea commited on
Commit
7b5bbcd
·
verified ·
1 Parent(s): 2252808

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +156 -3
README.md CHANGED
@@ -1,3 +1,156 @@
1
- ---
2
- license: llama3.1
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: llama3.1
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+ ---
6
+ ## Model Card Details
7
+
8
+ This model is an int4 model with group_size 128 and symmetric quantization of [meta-llama/Meta-Llama-3.1-70B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-70B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round). Load the model with revision `90c15db` to use AutoGPTQ format
9
+
10
+ ## Inference on CPU/HPU/CUDA
11
+
12
+ 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).
13
+
14
+ ```python
15
+ from auto_round import AutoHfQuantizer ##must import for auto-round format
16
+ import torch
17
+ from transformers import AutoModelForCausalLM,AutoTokenizer
18
+ quantized_model_dir = "OPEA/Meta-Llama-3.1-70B-Instruct-int4-sym-inc"
19
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
20
+
21
+ model = AutoModelForCausalLM.from_pretrained(
22
+ quantized_model_dir,
23
+ torch_dtype='auto',
24
+ device_map="auto",
25
+ ##revision="90c15db", ##AutoGPTQ format
26
+ )
27
+
28
+ ##import habana_frameworks.torch.core as htcore ## uncommnet it for HPU
29
+ ##import habana_frameworks.torch.hpu as hthpu ## uncommnet it for HPU
30
+ ##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
31
+
32
+ prompt = "There is a girl who likes adventure,"
33
+ messages = [
34
+ {"role": "system", "content": "You are a helpful assistant."},
35
+ {"role": "user", "content": prompt}
36
+ ]
37
+
38
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
39
+ text = tokenizer.apply_chat_template(
40
+ messages,
41
+ tokenize=False,
42
+ add_generation_prompt=True
43
+ )
44
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
45
+
46
+ generated_ids = model.generate(
47
+ model_inputs.input_ids,
48
+ max_new_tokens=200, ##change this to align with the official usage
49
+ do_sample=False ##change this to align with the official usage
50
+ )
51
+ generated_ids = [
52
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
53
+ ]
54
+
55
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
56
+ print(response)
57
+
58
+ ##prompt = "There is a girl who likes adventure,"
59
+ ##BF16
60
+ """That sounds exciting. What kind of adventures is she interested in? Is she more into outdoor activities like hiking, rock climbing, or exploring new places, or does she enjoy indoor adventures like solving puzzles, playing escape rooms, or reading fantasy novels?
61
+ """
62
+ ##INT4
63
+ """That sounds exciting. What kind of adventures is she interested in? Is she more into outdoor activities like hiking, camping, or exploring new places, or is she drawn to thrilling experiences like skydiving, bungee jumping, or trying new extreme sports?
64
+ """
65
+
66
+ ##prompt = "Which one is larger, 9.11 or 9.8"
67
+ ## INT4
68
+ """9.11 is larger than 9.8."""
69
+
70
+ ## BF16
71
+ """9.11 is larger than 9.8."""
72
+
73
+ prompt = "How many r in strawberry."
74
+ ## INT4
75
+ """There are 2 R's in the word "strawberry""
76
+ ## BF16
77
+ """There are 2 R's in the word "strawberry"."""
78
+
79
+ ##prompt = "Once upon a time,"
80
+ ## INT4
81
+ """It sounds like you're starting a story. Would you like me to continue it, or would you like to tell me the rest of the story yourself?
82
+ """
83
+ ## BF16
84
+ """it seems like we're about to start a classic fairy tale. Would you like to continue the story, or would you like me to take over and spin a yarn for you?
85
+ """
86
+
87
+ ```
88
+
89
+ ### Evaluate the model
90
+
91
+ pip3 install lm-eval==0.4.5
92
+
93
+ ```bash
94
+ auto-round --eval --model_name "OPEA/Meta-Llama-3.1-70B-Instruct-int4-sym-inc" --eval_bs 16 --tasks leaderboard_mmlu_pro,leaderboard_ifeval,lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k
95
+ ```
96
+
97
+ | Metric | BF16 | INT4 |
98
+ | --------------------------- | ------ | ------------- |
99
+ | avg | | |
100
+ | leaderboard_mmlu_pro 5shot | | 0.5226 |
101
+ | leaderboard_ifeval | | 0.8010+0.7135 |
102
+ | mmlu | 0.8232 | |
103
+ | lambada_openai | 0.7557 | 0.7572 |
104
+ | hellaswag | 0.6516 | 0.6467 |
105
+ | winogrande | 0.7861 | 0.8098 |
106
+ | piqa | 0.8313 | 0.8243 |
107
+ | truthfulqa_mc1 | 0.4064 | 0.4027 |
108
+ | openbookqa | 0.3700 | 0.3620 |
109
+ | boolq | 0.8783 | 0.8761 |
110
+ | arc_easy | 0.8670 | 0.8590 |
111
+ | arc_challenge | 0.6237 | 0.6101 |
112
+ | gsm8k(5shot) strict match | | 0.9067 |
113
+
114
+ ## Reproduce the model
115
+
116
+ Here is the sample command to reproduce the model. We found auto-round is not stable for this model, please do not use --model_dtype "fp16" and symmetric quantization.
117
+
118
+ ```bash
119
+ auto-round \
120
+ --model meta-llama/Meta-Llama-3.1-70B-Instruct \
121
+ --device 0 \
122
+ --group_size 128 \
123
+ --nsamples 512 \
124
+ --bits 4 \
125
+ --iter 1000 \
126
+ --disable_eval \
127
+ --low_gpu_mem_usage \
128
+ --format 'auto_round' \
129
+ --output_dir "./tmp_autoround"
130
+ ```
131
+
132
+ ##
133
+
134
+ ## Ethical Considerations and Limitations
135
+
136
+ 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.
137
+
138
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
139
+
140
+ ## Caveats and Recommendations
141
+
142
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
143
+
144
+ Here are a couple of useful links to learn more about Intel's AI software:
145
+
146
+ - Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
147
+
148
+ ## Disclaimer
149
+
150
+ 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.
151
+
152
+ ## Cite
153
+
154
+ @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} }
155
+
156
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)