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