cicdatopea
commited on
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,119 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
---
|
4 |
+
## Model Details
|
5 |
+
|
6 |
+
This model is an int4 model(The vision module has also been quantized) with group_size 128 and symmetric quantization of [Xkev/Llama-3.2V-11B-cot](https://huggingface.co/Xkev/Llama-3.2V-11B-cot) generated by [intel/auto-round](https://github.com/intel/auto-round).
|
7 |
+
|
8 |
+
## How To Use
|
9 |
+
|
10 |
+
### Requirements
|
11 |
+
Please use Transformers version 4.45.0 or later
|
12 |
+
AutoRound version >= 0.4.1
|
13 |
+
|
14 |
+
### INT4 Inference
|
15 |
+
```python
|
16 |
+
from auto_round import AutoRoundConfig ## must import for auto-round format
|
17 |
+
import requests
|
18 |
+
import torch
|
19 |
+
from PIL import Image
|
20 |
+
from transformers import MllamaForConditionalGeneration, AutoProcessor
|
21 |
+
|
22 |
+
quantized_model_path="OPEA/Llama-3.2V-11B-cot-int4-sym-inc"
|
23 |
+
|
24 |
+
model = MllamaForConditionalGeneration.from_pretrained(
|
25 |
+
quantized_model_path,
|
26 |
+
torch_dtype="auto",
|
27 |
+
device_map="auto"
|
28 |
+
)
|
29 |
+
processor = AutoProcessor.from_pretrained(quantized_model_path)
|
30 |
+
image_url = "https://huggingface.co/datasets/huggingface/documentation-images/resolve/0052a70beed5bf71b92610a43a52df6d286cd5f3/diffusers/rabbit.jpg"
|
31 |
+
content = "Please write a haiku for this one, it would be: "
|
32 |
+
|
33 |
+
messages = [
|
34 |
+
{"role": "user", "content": [
|
35 |
+
{"type": "image"},
|
36 |
+
{"type": "text", "text": content}
|
37 |
+
]}
|
38 |
+
]
|
39 |
+
# Preparation for inference
|
40 |
+
image = Image.open(requests.get(image_url, stream=True).raw)
|
41 |
+
input_text = processor.apply_chat_template(messages, add_generation_prompt=True)
|
42 |
+
inputs = processor(
|
43 |
+
image,
|
44 |
+
input_text,
|
45 |
+
add_special_tokens=False,
|
46 |
+
return_tensors="pt"
|
47 |
+
).to(model.device)
|
48 |
+
|
49 |
+
output = model.generate(**inputs, max_new_tokens=2048)
|
50 |
+
output = processor.decode(output[0])
|
51 |
+
pattern = re.compile('<CONCLUSION>(.*)</CONCLUSION>')
|
52 |
+
print(pattern.search(output).group(1))
|
53 |
+
##INT4:
|
54 |
+
## Blue coat brown vest
|
55 |
+
## Stone cottage green hills
|
56 |
+
## Peaceful rural scene
|
57 |
+
|
58 |
+
##BF16:
|
59 |
+
## Rabbit in blue coat
|
60 |
+
## Brown vest and stone cottage
|
61 |
+
## Peaceful countryside
|
62 |
+
|
63 |
+
image_url = "http://images.cocodataset.org/train2017/000000411975.jpg"
|
64 |
+
content = "How many people are on the baseball field in the picture?"
|
65 |
+
##INT4:
|
66 |
+
## There are four people on the baseball field in the picture.
|
67 |
+
|
68 |
+
##BF16:
|
69 |
+
## There are four people on the baseball field in the picture.
|
70 |
+
|
71 |
+
image_url = "https://intelcorp.scene7.com/is/image/intelcorp/processor-overview-framed-badge:1920-1080?wid=480&hei=270"
|
72 |
+
content = "Which company does this picture represent?"
|
73 |
+
##INT4:
|
74 |
+
## This picture represents Intel.
|
75 |
+
|
76 |
+
##BF16:
|
77 |
+
## Intel
|
78 |
+
```
|
79 |
+
|
80 |
+
### Generate the model
|
81 |
+
Here is the sample command to reproduce the model.
|
82 |
+
```bash
|
83 |
+
pip install auto-round
|
84 |
+
auto-round-mllm \
|
85 |
+
--model Xkev/Llama-3.2V-11B-cot \
|
86 |
+
--device 0 \
|
87 |
+
--group_size 128 \
|
88 |
+
--bits 4 \
|
89 |
+
--iters 200 \
|
90 |
+
--nsample 128 \
|
91 |
+
--seqlen 512 \
|
92 |
+
--quant_nontext_module \
|
93 |
+
--format 'auto_round' \
|
94 |
+
--output_dir "./tmp_autoround"
|
95 |
+
```
|
96 |
+
|
97 |
+
## Ethical Considerations and Limitations
|
98 |
+
|
99 |
+
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.
|
100 |
+
|
101 |
+
Therefore, before deploying any applications of the model, developers should perform safety testing.
|
102 |
+
|
103 |
+
## Caveats and Recommendations
|
104 |
+
|
105 |
+
Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model.
|
106 |
+
|
107 |
+
Here are a couple of useful links to learn more about Intel's AI software:
|
108 |
+
|
109 |
+
- Intel Neural Compressor [link](https://github.com/intel/neural-compressor)
|
110 |
+
|
111 |
+
## Disclaimer
|
112 |
+
|
113 |
+
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.
|
114 |
+
|
115 |
+
## Cite
|
116 |
+
|
117 |
+
@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} }
|
118 |
+
|
119 |
+
[arxiv](https://arxiv.org/abs/2309.05516) [github](https://github.com/intel/auto-round)
|