DeepSeek-VL2
收藏DeepSeek-VL2 数据集概述
1. 简介
DeepSeek-VL2 是一个先进的混合专家(Mixture-of-Experts, MoE)视觉-语言模型系列,显著优于其前身 DeepSeek-VL。DeepSeek-VL2 在多种任务中表现出色,包括视觉问答、光学字符识别、文档/表格/图表理解以及视觉定位。该模型系列包含三个变体:DeepSeek-VL2-Tiny、DeepSeek-VL2-Small 和 DeepSeek-VL2,分别激活了 1.0B、2.8B 和 4.5B 参数。DeepSeek-VL2 在参数相似或更少的情况下,与现有的开源密集和 MoE 模型相比,实现了具有竞争力的或最先进的性能。
2. 发布
- 2024-12-13:发布 DeepSeek-VL2 系列,包括
DeepSeek-VL2-tiny、DeepSeek-VL2-small和DeepSeek-VL2。
3. 模型下载
DeepSeek-VL2 系列包括 DeepSeek-VL2-tiny、DeepSeek-VL2-small 和 DeepSeek-VL2,支持学术和商业社区的广泛研究。使用该模型需遵守 License 部分 中规定的条款。
Huggingface
| 模型 | 序列长度 | 下载链接 |
|---|---|---|
| DeepSeek-VL2-tiny | 4096 | 🤗 Hugging Face |
| DeepSeek-VL2-small | 4096 | 🤗 Hugging Face |
| DeepSeek-VL2 | 4096 | 🤗 Hugging Face |
4. 快速开始
安装
在 Python >= 3.8 环境下,通过运行以下命令安装必要的依赖项:
shell pip install -e .
简单推理示例
python import torch from transformers import AutoModelForCausalLM
from deepseek_vl.models import DeepseekVLV2Processor, DeepseekVLV2ForCausalLM from deepseek_vl.utils.io import load_pil_images
指定模型路径
model_path = "deepseek-ai/deepseek-vl2-small" 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) vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
单张图片对话示例
conversation = [ { "role": "<|User|>", "content": "<image> <|ref|>The giraffe at the back.<|/ref|>.", "images": ["./images/visual_grounding.jpeg"], }, {"role": "<|Assistant|>", "content": ""}, ]
加载图片并准备输入
pil_images = load_pil_images(conversation) prepare_inputs = vl_chat_processor( conversations=conversation, images=pil_images, force_batchify=True, system_prompt="" ).to(vl_gpt.device)
运行图像编码器以获取图像嵌入
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
运行模型以获取响应
outputs = vl_gpt.language.generate( 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)
5. 许可证
代码仓库的许可证为 MIT License。DeepSeek-VL2 模型的使用受 DeepSeek Model License 约束。DeepSeek-VL2 系列支持商业使用。
6. 引用
@misc{wu2024deepseekvl2mixtureofexpertsvisionlanguagemodels, title={DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding}, author={Zhiyu Wu and Xiaokang Chen and Zizheng Pan and Xingchao Liu and Wen Liu and Damai Dai and Huazuo Gao and Yiyang Ma and Chengyue Wu and Bingxuan Wang and Zhenda Xie and Yu Wu and Kai Hu and Jiawei Wang and Yaofeng Sun and Yukun Li and Yishi Piao and Kang Guan and Aixin Liu and Xin Xie and Yuxiang You and Kai Dong and Xingkai Yu and Haowei Zhang and Liang Zhao and Yisong Wang and Chong Ruan}, year={2024}, eprint={2412.10302}, archivePrefix={arXiv}, primaryClass={cs.CV}, url={https://arxiv.org/abs/2412.10302}, }
7. 联系
如有任何问题,请提交 issue 或联系我们:service@deepseek.com。




