DeepSeek-VL:面向真实世界的视觉语言理解模型,支持多场景多模态处理

DeepSeek-VL: Towards Real-World Vision-Language Understanding

分支1Tags0
文件最后提交记录最后更新时间
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
2 年前
DeepSeek LLM

📥 模型下载 | ⚡ 快速开始 | 📜 许可协议 | 📖 引用方式
📄 论文链接 | 🤗 Huggingface 论文链接 | 👁️ 演示Demo

1. 引言

本文介绍DeepSeek-VL,这是一款开源的视觉-语言(VL)模型,专为现实世界的视觉与语言理解应用而设计。DeepSeek-VL具备通用的多模态理解能力,能够处理复杂场景下的逻辑图表、网页、公式识别、科技文献、自然图像以及具身智能等任务。

DeepSeek-VL: Towards Real-World Vision-Language Understanding

Haoyu Lu*, Wen Liu*, Bo Zhang**, Bingxuan Wang, Kai Dong, Bo Liu, Jingxiang Sun, Tongzheng Ren, Zhuoshu Li, Hao Yang, Yaofeng Sun, Chengqi Deng, Hanwei Xu, Zhenda Xie, Chong Ruan (*Equal Contribution, **Project Lead)

2. 版本发布

✅ 2024-03-14:DeepSeek-VL-7B演示版已在Hugging Face上线。
请访问https://huggingface.co/spaces/deepseek-ai/DeepSeek-VL-7B体验DeepSeek-VL-7B的Gradio演示,亲自感受其强大功能!
✅ 2024-03-13:支持DeepSeek-VL的Gradio演示。
✅ 2024-03-11:DeepSeek-VL系列模型正式发布,包括DeepSeek-VL-7B-baseDeepSeek-VL-7B-chatDeepSeek-VL-1.3B-baseDeepSeek-VL-1.3B-chat
此次发布的DeepSeek-VL系列包含多种模型,可满足不同应用需求。模型提供70亿参数和13亿参数两种规格,每种规格均包含基础版(base)和对话版(chat),以适应不同的使用场景和集成需求。

3. 模型下载

我们向公众发布DeepSeek-VL系列模型,包括1.3B-base、1.3B-chat、7b-base和7b-chat。 旨在支持学术界和商业界更广泛、更多样化的研究工作。 请注意,本模型的使用需遵守许可证部分中规定的条款。商业用途在这些条款下是允许的。

Huggingface

模型 序列长度 下载
DeepSeek-VL-1.3B-base 4096 🤗 Hugging Face
DeepSeek-VL-1.3B-chat 4096 🤗 Hugging Face
DeepSeek-VL-7B-base 4096 🤗 Hugging Face
DeepSeek-VL-7B-chat 4096 🤗 Hugging Face

4. 快速开始

安装

Python >= 3.8 环境基础上,通过运行以下命令安装必要的依赖项:

pip install -e .

简单推理示例

import torch
from transformers import AutoModelForCausalLM

from deepseek_vl.models import VLChatProcessor, MultiModalityCausalLM
from deepseek_vl.utils.io import load_pil_images


# specify the path to the model
model_path = "deepseek-ai/deepseek-vl-7b-chat"
vl_chat_processor: VLChatProcessor = VLChatProcessor.from_pretrained(model_path)
tokenizer = vl_chat_processor.tokenizer

vl_gpt: MultiModalityCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()

## single image conversation example
conversation = [
    {
        "role": "User",
        "content": "<image_placeholder>Describe each stage of this image.",
        "images": ["./images/training_pipelines.jpg"],
    },
    {"role": "Assistant", "content": ""},
]

## multiple images (or in-context learning) conversation example
# conversation = [
#     {
#         "role": "User",
#         "content": "<image_placeholder>A dog wearing nothing in the foreground, "
#                    "<image_placeholder>a dog wearing a santa hat, "
#                    "<image_placeholder>a dog wearing a wizard outfit, and "
#                    "<image_placeholder>what's the dog wearing?",
#         "images": [
#             "images/dog_a.png",
#             "images/dog_b.png",
#             "images/dog_c.png",
#             "images/dog_d.png",
#         ],
#     },
#     {"role": "Assistant", "content": ""}
# ]

# load images and prepare for inputs
pil_images = load_pil_images(conversation)
prepare_inputs = vl_chat_processor(
    conversations=conversation,
    images=pil_images,
    force_batchify=True
).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_model.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)

命令行聊天

python cli_chat.py --model_path "deepseek-ai/deepseek-vl-7b-chat"

# or local path
python cli_chat.py --model_path "local model path"

Gradio 演示

pip install -e .[gradio]

python deepseek_vl/serve/app_deepseek.py

尽情体验!

5. 许可证

本代码仓库基于 MIT 许可证 授权。DeepSeek-VL Base/Chat 模型的使用受 DeepSeek 模型许可证 约束。DeepSeek-VL 系列(包括 Base 和 Chat)支持商业用途。

6. 引用

@misc{lu2024deepseekvl,
      title={DeepSeek-VL: Towards Real-World Vision-Language Understanding},
      author={Haoyu Lu and Wen Liu and Bo Zhang and Bingxuan Wang and Kai Dong and Bo Liu and Jingxiang Sun and Tongzheng Ren and Zhuoshu Li and Hao Yang and Yaofeng Sun and Chengqi Deng and Hanwei Xu and Zhenda Xie and Chong Ruan},
      year={2024},
      eprint={2403.05525},
      archivePrefix={arXiv},
      primaryClass={cs.AI}
}

7. 联系方式

若您有任何疑问,请提交 issue 或通过 service@deepseek.com 与我们联系。

项目介绍

DeepSeek-VL: Towards Real-World Vision-Language Understanding

定制我的领域
361.92 K182访问 GitHub