Model Details
This model is an int4 model(The vision module has also been quantized) with group_size 128 and symmetric quantization of deepseek-ai/deepseek-vl2 generated by intel/auto-round. Load the model with revision 2e595e8
to use AutoGPTQ format.
How to Use
INT4 Inference
from auto_round import AutoRoundConfig ##must import for auto-round format
import requests
import torch
from PIL import Image
from transformers import AutoModelForCausalLM
from deepseek_vl2.models import DeepseekVLV2Processor, DeepseekVLV2ForCausalLM
# specify the path to the model
model_path = "OPEA/deepseek-vl2-int4-sym-inc"
vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)
tokenizer = vl_chat_processor.tokenizer
vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(
model_path,
trust_remote_code=True,
device_map="auto",
torch_dtype="auto",
## revision="2e595e8" ##AutoGPTQ format
)
vl_gpt = vl_gpt.eval()
image_url = "https://qianwen-res.oss-cn-beijing.aliyuncs.com/Qwen-VL/assets/demo.jpeg"
content = "Describe this image."
## single image conversation example
conversation = [
{
"role": "<|User|>",
"content": content,
},
{"role": "<|Assistant|>", "content": ""},
]
# load images and prepare for inputs
pil_images = Image.open(requests.get(image_url, stream=True).raw)
prepare_inputs = vl_chat_processor(
conversations=conversation,
images=[pil_images],
force_batchify=True,
system_prompt=""
)
prepare_inputs = prepare_inputs.to(vl_gpt.device)
# run image encoder to get the image embeddings
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
# run the model to get the response
outputs = vl_gpt.language.generate(
input_ids = prepare_inputs["input_ids"],
inputs_embeds=inputs_embeds,
attention_mask=prepare_inputs.attention_mask,
pad_token_id=tokenizer.eos_token_id,
bos_token_id=tokenizer.bos_token_id,
eos_token_id=tokenizer.eos_token_id,
max_new_tokens=512,
do_sample=False,
use_cache=True
)
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
print(f"{prepare_inputs['sft_format'][0]}", answer)
#INT4:
## This image shows a person standing in front of a large, colorful mural. The mural depicts a vibrant cityscape with tall buildings, bright lights, and a bustling street scene. The person is dressed in casual clothing and is smiling at the camera. The overall atmosphere of the image is lively and energetic.
#BF16:
## This image shows a person standing in front of a large, colorful mural. The mural depicts a vibrant cityscape with tall buildings, bright lights, and a bustling street scene. The person in the image is wearing a casual outfit and appears to be taking a photo of the mural with their phone. The overall atmosphere of the image is lively and energetic, with a sense of excitement and creativity.
image_url = "http://images.cocodataset.org/train2017/000000411975.jpg"
content = "How many people are there on the baseball field in the image?"
#INT4:
#There are no people on the baseball field in the image.
#BF16:
# There are no people visible on the baseball field in the image.
image_url = "https://intelcorp.scene7.com/is/image/intelcorp/processor-overview-framed-badge:1920-1080?wid=480&hei=270"
content = "This image represents which company?"
#INT4:
# I'm sorry, but I cannot identify or recognize companies based on images. However, I can help you with information about companies or provide general knowledge on various topics. If you have any questions or need assistance, feel free to ask!
#BF16:
# I'm sorry, but I cannot provide information about the company represented in the image as I do not have the ability to view or interpret images. However, if you provide me with a description of the image, I may be able to help you identify the company.
Generate the model
Here is the sample command to reproduce the model.
pip install auto-round
auto-round-mllm \
--model deepseek-ai/deepseek-vl2 \
--device 0 \
--group_size 128 \
--bits 4 \
--iters 1000 \
--nsample 512 \
--seqlen 2048 \
--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
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} }
- Downloads last month
- 37
Model tree for OPEA/deepseek-vl2-int4-sym-inc
Base model
deepseek-ai/deepseek-vl2