doubility123
commited on
Commit
•
9710d9e
1
Parent(s):
a0b9d53
Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,124 @@
|
|
1 |
---
|
2 |
-
license:
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: other
|
3 |
+
license_name: deepseek
|
4 |
+
license_link: LICENSE
|
5 |
---
|
6 |
+
|
7 |
+
## 1. Introduction
|
8 |
+
|
9 |
+
Introducing DeepSeek VL, an open-source Vision-Language (VL) Model designed for real-world vision and language understanding applications. DeepSeek-VL possesses general multimodal understanding capabilities, capable of processing logical diagrams, web pages, formula recognition, scientific literature, natural images, and embodied intelligence in complex scenarios.
|
10 |
+
|
11 |
+
[DeepSeek-VL: Towards Real-World Vision-Language Understanding](https://arxiv.org/abs/2403.05525)
|
12 |
+
|
13 |
+
Haoyu Lu*, Wen Liu*, Bo Zhang**, Bingxuan Wang, Kai Dong, Bo Liu, Jingxiang Sun, Tongzheng Ren, Zhuoshu Li, Yaofeng Sun, Chengqi Deng, Hanwei Xu, Zhenda Xie, Chong Ruan (*Equal Contribution, **Project Leader)
|
14 |
+
|
15 |
+
![](https://github.com/deepseek-ai/DeepSeek-VL/blob/main/images/sample.jpg)
|
16 |
+
|
17 |
+
|
18 |
+
### 2. Model Summary
|
19 |
+
|
20 |
+
DeepSeek-VL-1.3b-chat is a tiny vision-language model. It uses the [SigLIP-L](https://huggingface.co/timm/ViT-L-16-SigLIP-384) as the vision encoder supporting 384 x 384 image input
|
21 |
+
and is constructed based on the DeepSeek-LLM-1.3b-base which is trained on an approximate corpus of 500B text tokens. The whole DeepSeek-1.3b-base model is finally trained around 400B vision-language tokens.
|
22 |
+
The DeepSeek-VL-1.3b-chat is an instructed version based on [DeepSeek-VL-1.3b-base](https://huggingface.co/deepseek-ai/deepseek-vl-1.3b-base).
|
23 |
+
|
24 |
+
## 3. Quick Start
|
25 |
+
|
26 |
+
### Installation
|
27 |
+
|
28 |
+
On the basis of `Python >= 3.8` environment, install the necessary dependencies by running the following command:
|
29 |
+
|
30 |
+
|
31 |
+
```shell
|
32 |
+
git clone https://github.com/deepseek-ai/DeepSeek-VL
|
33 |
+
cd DeepSeek-VL
|
34 |
+
|
35 |
+
pip install -r requirements.txt -e .
|
36 |
+
```
|
37 |
+
|
38 |
+
### Simple Inference Example
|
39 |
+
|
40 |
+
```python
|
41 |
+
import torch
|
42 |
+
from transformers import AutoModelForCausalLM
|
43 |
+
|
44 |
+
from deepseek_vl.models import VLChatProcessor, MultiModalityCausalLM
|
45 |
+
from deepseek_vl.utils.io import load_pil_images
|
46 |
+
|
47 |
+
|
48 |
+
# specify the path to the model
|
49 |
+
model_path = "deepseek-ai/deepseek-vl-7b-chat"
|
50 |
+
vl_chat_processor: VLChatProcessor = VLChatProcessor.from_pretrained(model_path)
|
51 |
+
tokenizer = vl_chat_processor.tokenizer
|
52 |
+
|
53 |
+
vl_gpt: MultiModalityCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
|
54 |
+
vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
|
55 |
+
|
56 |
+
conversation = [
|
57 |
+
{
|
58 |
+
"role": "User",
|
59 |
+
"content": "<image_placeholder>Describe each stage of this image.",
|
60 |
+
"images": ["./images/training_pipelines.png"]
|
61 |
+
},
|
62 |
+
{
|
63 |
+
"role": "Assistant",
|
64 |
+
"content": ""
|
65 |
+
}
|
66 |
+
]
|
67 |
+
|
68 |
+
# load images and prepare for inputs
|
69 |
+
pil_images = load_pil_images(conversation)
|
70 |
+
prepare_inputs = vl_chat_processor(
|
71 |
+
conversations=conversation,
|
72 |
+
images=pil_images,
|
73 |
+
force_batchify=True
|
74 |
+
).to(vl_gpt.device)
|
75 |
+
|
76 |
+
# run image encoder to get the image embeddings
|
77 |
+
inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
|
78 |
+
|
79 |
+
# run the model to get the response
|
80 |
+
outputs = vl_gpt.language_model.generate(
|
81 |
+
inputs_embeds=inputs_embeds,
|
82 |
+
attention_mask=prepare_inputs.attention_mask,
|
83 |
+
pad_token_id=tokenizer.eos_token_id,
|
84 |
+
bos_token_id=tokenizer.bos_token_id,
|
85 |
+
eos_token_id=tokenizer.eos_token_id,
|
86 |
+
max_new_tokens=512,
|
87 |
+
do_sample=False,
|
88 |
+
use_cache=True
|
89 |
+
)
|
90 |
+
|
91 |
+
answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
|
92 |
+
print(f"{prepare_inputs['sft_format'][0]}", answer)
|
93 |
+
```
|
94 |
+
|
95 |
+
### CLI Chat
|
96 |
+
```bash
|
97 |
+
|
98 |
+
python cli_chat.py --model_path "deepseek-ai/deepseek-vl-7b-chat"
|
99 |
+
|
100 |
+
# or local path
|
101 |
+
python cli_chat.py --model_path "local model path"
|
102 |
+
|
103 |
+
```
|
104 |
+
|
105 |
+
## 4. License
|
106 |
+
|
107 |
+
This code repository is licensed under [the MIT License](https://github.com/deepseek-ai/DeepSeek-LLM/blob/HEAD/LICENSE-CODE). The use of DeepSeek LLM Base/Chat models is subject to [the Model License](https://github.com/deepseek-ai/DeepSeek-LLM/blob/HEAD/LICENSE-MODEL). DeepSeek LLM series (including Base and Chat) supports commercial use.
|
108 |
+
|
109 |
+
## 5. Citation
|
110 |
+
|
111 |
+
```
|
112 |
+
@misc{lu2024deepseekvl,
|
113 |
+
title={DeepSeek-VL: Towards Real-World Vision-Language Understanding},
|
114 |
+
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 Yaofeng Sun and Chengqi Deng and Hanwei Xu and Zhenda Xie and Chong Ruan},
|
115 |
+
year={2024},
|
116 |
+
eprint={2403.05525},
|
117 |
+
archivePrefix={arXiv},
|
118 |
+
primaryClass={cs.AI}
|
119 |
+
}
|
120 |
+
```
|
121 |
+
|
122 |
+
## 6. Contact
|
123 |
+
|
124 |
+
If you have any questions, please raise an issue or contact us at [service@deepseek.com](mailto:service@deepseek.com).
|