weiweiz1 commited on
Commit
e6f3e64
1 Parent(s): a429eb9

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +153 -3
README.md CHANGED
@@ -1,3 +1,153 @@
1
- ---
2
- license: llama3.1
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ datasets:
4
+ - NeelNanda/pile-10k
5
+
6
+ ---
7
+
8
+ ## Model Card Details
9
+
10
+ This model is an int4 model with group_size 128 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), auto-round is needed to run this model
11
+
12
+
13
+
14
+
15
+ ## Reproduce the model
16
+
17
+ Here is the sample command to reproduce the model.
18
+
19
+ ```bash
20
+ git clone https://github.com/intel/auto-round
21
+ cd auto-round/examples/language-modeling
22
+ pip install -r requirements.txt
23
+ python3 main.py \
24
+ --model_name meta-llama/Meta-Llama-3.1-70B-Instruct \
25
+ --device 0 \
26
+ --group_size 128 \
27
+ --nsamples 512 \
28
+ --bits 4 \
29
+ --iter 1000 \
30
+ --disable_eval \
31
+ --low_gpu_mem_usage \
32
+ --deployment_device 'auto_round' \
33
+ --output_dir "./tmp_autoround"
34
+ ```
35
+
36
+
37
+ ## Inference on CPU/HPU//CUDA
38
+
39
+
40
+ 1 git clone https://github.com/intel/auto-round && cd auto-round && pip install -vvv --no-build-isolation -e .
41
+
42
+ 2 CPU only machine: pip install intel-extension-for-transformers
43
+
44
+ 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).
45
+
46
+ CUDA: no extra operations
47
+
48
+
49
+ ```python
50
+ ##git clone https://github.com/intel/auto-round.git
51
+ ##cd auto-round && pip install -vvv --no-build-isolation -e .
52
+ from auto_round import AutoHfQuantizer ##must import
53
+ import torch
54
+ from transformers import AutoModelForCausalLM,AutoTokenizer
55
+ quantized_model_dir = "Intel/Meta-Llama-3.1-70B-Instruct-int4-inc"
56
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
57
+
58
+ model = AutoModelForCausalLM.from_pretrained(
59
+ quantized_model_dir,
60
+ torch_dtype='auto',
61
+ device_map="auto",
62
+ )
63
+ prompt = "There is a girl who likes adventure,"
64
+ messages = [
65
+ {"role": "system", "content": "You are a helpful assistant."},
66
+ {"role": "user", "content": prompt}
67
+ ]
68
+
69
+ tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
70
+ text = tokenizer.apply_chat_template(
71
+ messages,
72
+ tokenize=False,
73
+ add_generation_prompt=True
74
+ )
75
+ model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
76
+
77
+ generated_ids = model.generate(
78
+ model_inputs.input_ids,
79
+ max_new_tokens=50, ##change this to align with the official usage
80
+ do_sample=False ##change this to align with the official usage
81
+ )
82
+ generated_ids = [
83
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
84
+ ]
85
+
86
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
87
+ print(response)
88
+
89
+ ##prompt = "请介绍一下阿里巴巴公司"
90
+ ##阿里巴巴集团是中国最大的电子商务公司之一,由马云等18人于1999年在杭州创立。阿里巴巴集团旗下拥有多个知名的电子商务平台,包括�
91
+
92
+ ##prompt = "9.8大还是9.11大"
93
+ ##9.11大
94
+
95
+ ##prompt = "Once upon a time,"
96
+ ##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?
97
+
98
+ ##prompt = "There is a girl who likes adventure,"
99
+ ##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?
100
+ ```
101
+
102
+
103
+
104
+ ### Evaluate the model
105
+
106
+ pip3 install lm-eval==0.4.2
107
+
108
+ ```bash
109
+ git clone https://github.com/intel/auto-round
110
+ cd auto-round/examples/language-modeling
111
+ python3 eval_042/evluation.py --model_name "Intel/Meta-Llama-3.1-70B-Instruct-int4-inc" --eval_bs 16 --tasks lambada_openai,hellaswag,piqa,winogrande,truthfulqa_mc1,openbookqa,boolq,arc_easy,arc_challenge,mmlu,gsm8k,cmmlu,ceval-valid --trust_remote_code
112
+ ```
113
+
114
+ | Metric | BF16 | INT4-AutoRound |
115
+ |----------------|--------|----------------|
116
+ | avg | 0.7182 | 0.7165 |
117
+ | avg w/o gsm8k | 0.7000 | 0.6987 |
118
+ | mmlu | 0.8221 | 0.8145 |
119
+ | lambada_openai | 0.7566 | 0.7565 |
120
+ | hellaswag | 0.6522 | 0.6492 |
121
+ | winogrande | 0.7901 | 0.8090 |
122
+ | piqa | 0.8308 | 0.8270 |
123
+ | truthfulqa_mc1 | 0.4064 | 0.4051 |
124
+ | openbookqa | 0.3720 | 0.3760 |
125
+ | boolq | 0.8777 | 0.8768 |
126
+ | arc_easy | 0.8674 | 0.8565 |
127
+ | arc_challenge | 0.6246 | 0.6160 |
128
+ | gsm8k(5shot) strict match | 0.8999 | 0.8954 |
129
+
130
+ ## Ethical Considerations and Limitations
131
+
132
+ 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.
133
+
134
+ Therefore, before deploying any applications of the model, developers should perform safety testing.
135
+
136
+ ## Caveats and Recommendations
137
+
138
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
139
+
140
+ Here are a couple of useful links to learn more about Intel's AI software:
141
+
142
+ * Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
143
+ * Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
144
+
145
+ ## Disclaimer
146
+
147
+ 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.
148
+
149
+ ## Cite
150
+
151
+ @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} }
152
+
153
+ [arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)