update readme
Browse filesSigned-off-by: wenhuach <[email protected]>
README.md
CHANGED
@@ -1,3 +1,109 @@
|
|
1 |
-
|
2 |
-
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
## Model Card Details
|
2 |
+
|
3 |
+
This is an recipe of int4 model with group_size 128 for meta-llama/Meta-Llama-3.1-8B-Instruct](https://huggingface.co/meta-llama/Meta-Llama-3.1-8B-Instruct) generated by [intel/auto-round](https://github.com/intel/auto-round).
|
4 |
+
|
5 |
+
### Reproduce the model
|
6 |
+
|
7 |
+
Here is the sample command to reproduce the model
|
8 |
+
|
9 |
+
```bash
|
10 |
+
git clone https://github.com/intel/auto-round
|
11 |
+
cd auto-round/examples/language-modeling
|
12 |
+
pip install -r requirements.txt
|
13 |
+
python3 main.py \
|
14 |
+
--model_name meta-llama/Meta-Llama-3.1-8B-Instruct \
|
15 |
+
--device 0 \
|
16 |
+
--group_size 128 \
|
17 |
+
--bits 4 \
|
18 |
+
--iters 1000 \
|
19 |
+
--model_dtype "fp16"
|
20 |
+
--deployment_device 'auto_round' \
|
21 |
+
--eval_bs 16 \
|
22 |
+
--output_dir "./tmp_autoround" \
|
23 |
+
|
24 |
+
```
|
25 |
+
|
26 |
+
|
27 |
+
|
28 |
+
### Inference on CPU/HPU//CUDA
|
29 |
+
|
30 |
+
1 git clone https://github.com/intel/auto-round
|
31 |
+
|
32 |
+
cd auto-round && pip install -vvv --no-build-isolation -e .
|
33 |
+
|
34 |
+
2 cpu only machine: pip install intel-extension-for-transformers
|
35 |
+
|
36 |
+
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).
|
37 |
+
|
38 |
+
CUDA: no extra operations
|
39 |
+
|
40 |
+
```python
|
41 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
42 |
+
from auto_round.auto_quantizer import AutoHfQuantizer
|
43 |
+
|
44 |
+
quantized_model_dir = "Intel/Meta-Llama-3.1-8B-Instruct-AutoRound"
|
45 |
+
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
|
46 |
+
model = AutoModelForCausalLM.from_pretrained(quantized_model_dir,
|
47 |
+
device_map="auto"
|
48 |
+
)
|
49 |
+
##model = model.to(torch.bfloat16).to("hpu") ## uncommnet it for HPU
|
50 |
+
tokenizer = AutoTokenizer.from_pretrained(quantized_model_dir)
|
51 |
+
text = "There is a girl who likes adventure,"
|
52 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
53 |
+
print(tokenizer.decode(model.generate(**inputs, max_new_tokens=50)[0]))
|
54 |
+
|
55 |
+
text = "There is a girl who likes adventure,"
|
56 |
+
##There is a girl who likes adventure, and she is always ready to go on a journey. She is a traveler, a wanderer, and a seeker of new experiences. She is always looking for something new and exciting, and she is not afraid to take risks. She is a free
|
57 |
+
|
58 |
+
text = "Once upon a time, "
|
59 |
+
##Once upon a time, in the land of the free and the home of the brave, there was a young girl named Lily. She was a bright and curious child, with a heart full of wonder and a mind full of questions. She lived in a small town surrounded by
|
60 |
+
|
61 |
+
text = "Which one is bigger, 9.11 or 9.8 "
|
62 |
+
##Which one is bigger, 9.11 or 9.8 9.11 is bigger. 9.11 is bigger than 9.8. 9.11 is bigger than 9.8. 9.11 is bigger than 9.8. 9.11 is bigger than
|
63 |
+
|
64 |
+
text = "Tell me something about Intel. "
|
65 |
+
##Tell me something about Intel. I've heard they're a big company, but I don't know much about them. What do they do?" \n
|
66 |
+
##Intel is a multinational technology company that designs and manufactures semiconductor chips, primarily for the computing and communications industries. They are one of
|
67 |
+
|
68 |
+
```
|
69 |
+
|
70 |
+
|
71 |
+
|
72 |
+
### Evaluate the model
|
73 |
+
|
74 |
+
lm-eval 0.4.2 eval_bs 16
|
75 |
+
|
76 |
+
| Metric | BF16 | INT4 | INT4 lmhead |
|
77 |
+
| ------------------------- | ------ | ------ | ----------- |
|
78 |
+
| Avg. | 0.6539 | 0.6483 | 0.6454 |
|
79 |
+
| Avg w/o gsm8k | 0.6425 | 0.6394 | 0.6357 |
|
80 |
+
| mmlu | 0.6778 | 0.6676 | 0.6602 |
|
81 |
+
| lambada_openai | 0.7306 | 0.7262 | 0.7180 |
|
82 |
+
| hellaswag | 0.5911 | 0.5848 | 0.5840 |
|
83 |
+
| winogrande | 0.7388 | 0.7261 | 0.7198 |
|
84 |
+
| piqa | 0.7998 | 0.7976 | 0.7992 |
|
85 |
+
| truthfulqa_mc1 | 0.3709 | 0.3635 | 0.3709 |
|
86 |
+
| openbookqa | 0.3380 | 0.3440 | 0.3380 |
|
87 |
+
| boolq | 0.8410 | 0.8361 | 0.8339 |
|
88 |
+
| arc_easy | 0.8203 | 0.8220 | 0.8182 |
|
89 |
+
| arc_challenge | 0.5162 | 0.5256 | 0.5145 |
|
90 |
+
| gsm8k(5shot) strict match | 0.7688 | 0.7377 | 0.7422 |
|
91 |
+
|
92 |
+
## Ethical Considerations and Limitations
|
93 |
+
|
94 |
+
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.
|
95 |
+
|
96 |
+
Therefore, before deploying any applications of the model, developers should perform safety testing.
|
97 |
+
|
98 |
+
## Caveats and Recommendations
|
99 |
+
|
100 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
101 |
+
|
102 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
103 |
+
|
104 |
+
* Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
105 |
+
* Intel Extension for Transformers [link](https://github.com/intel/intel-extension-for-transformers)
|
106 |
+
|
107 |
+
## Disclaimer
|
108 |
+
|
109 |
+
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.
|