doubility123 commited on
Commit
386a472
1 Parent(s): f7b6d8b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +132 -5
README.md CHANGED
@@ -1,5 +1,132 @@
1
- ---
2
- license: other
3
- license_name: deepseek
4
- license_link: https://github.com/deepseek-ai/DeepSeek-LLM/blob/HEAD/LICENSE-MODEL
5
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: deepseek
4
+ license_link: https://github.com/deepseek-ai/DeepSeek-LLM/blob/HEAD/LICENSE-MODEL
5
+ ---
6
+
7
+ ## 1. Introduction
8
+
9
+ Introducing DeepSeek-VL2, an advanced series of large Mixture-of-Experts (MoE) Vision-Language Models that significantly improves upon its predecessor, DeepSeek-VL. DeepSeek-VL2 demonstrates superior capabilities across various tasks, including but not limited to visual question answering, optical character recognition, document/table/chart understanding, and visual grounding. Our model series is composed of three variants: DeepSeek-VL2-Tiny, DeepSeek-VL2-Small and DeepSeek-VL2, with 1.0B, 2.8B and 4.5B activated parameters respectively.
10
+ DeepSeek-VL2 achieves competitive or state-of-the-art performance with similar or fewer activated parameters compared to existing open-source dense and MoE-based models.
11
+
12
+
13
+ [DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding]()
14
+
15
+ [**Github Repository**](https://github.com/deepseek-ai/DeepSeek-VL2)
16
+
17
+
18
+ Zhiyu Wu*, Xiaokang Chen*, Zizheng Pan*, Xingchao Liu*, Wen Liu**, Damai Dai, Huazuo Gao, Yiyang Ma, Chengyue Wu, Bingxuan Wang, Zhenda Xie, Yu Wu, Kai Hu, Jiawei Wang, Yaofeng Sun, Yukun Li, Yishi Piao, Kang Guan, Aixin Liu, Xin Xie, Yuxiang You, Kai Dong, Xingkai Yu, Haowei Zhang, Liang Zhao, Yisong Wang, Chong Ruan*** (* Equal Contribution, ** Project Lead, *** Corresponding author)
19
+
20
+ ![](https://github.com/deepseek-ai/DeepSeek-VL2/tree/main/images/vl2_teaser.jpeg)
21
+
22
+
23
+ ### 2. Model Summary
24
+
25
+ DeepSeek-VL2 is built on DeepSeekMoE-27B.
26
+
27
+
28
+ ## 3. Quick Start
29
+
30
+ ### Installation
31
+
32
+ On the basis of `Python >= 3.8` environment, install the necessary dependencies by running the following command:
33
+
34
+ ```shell
35
+ pip install -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 DeepseekVLV2Processor, DeepseekVLV2ForCausalLM
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-vl2-small"
50
+ vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)
51
+ tokenizer = vl_chat_processor.tokenizer
52
+
53
+ vl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
54
+ vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()
55
+
56
+ ## single image conversation example
57
+ conversation = [
58
+ {
59
+ "role": "<|User|>",
60
+ "content": "<image>\n<|ref|>The giraffe at the back.<|/ref|>.",
61
+ "images": ["./images/visual_grounding.jpeg"],
62
+ },
63
+ {"role": "<|Assistant|>", "content": ""},
64
+ ]
65
+
66
+ ## multiple images (or in-context learning) conversation example
67
+ # conversation = [
68
+ # {
69
+ # "role": "User",
70
+ # "content": "<image_placeholder>A dog wearing nothing in the foreground, "
71
+ # "<image_placeholder>a dog wearing a santa hat, "
72
+ # "<image_placeholder>a dog wearing a wizard outfit, and "
73
+ # "<image_placeholder>what's the dog wearing?",
74
+ # "images": [
75
+ # "images/dog_a.png",
76
+ # "images/dog_b.png",
77
+ # "images/dog_c.png",
78
+ # "images/dog_d.png",
79
+ # ],
80
+ # },
81
+ # {"role": "Assistant", "content": ""}
82
+ # ]
83
+
84
+ # load images and prepare for inputs
85
+ pil_images = load_pil_images(conversation)
86
+ prepare_inputs = vl_chat_processor(
87
+ conversations=conversation,
88
+ images=pil_images,
89
+ force_batchify=True,
90
+ system_prompt=""
91
+ ).to(vl_gpt.device)
92
+
93
+ # run image encoder to get the image embeddings
94
+ inputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)
95
+
96
+ # run the model to get the response
97
+ outputs = vl_gpt.language_model.generate(
98
+ inputs_embeds=inputs_embeds,
99
+ attention_mask=prepare_inputs.attention_mask,
100
+ pad_token_id=tokenizer.eos_token_id,
101
+ bos_token_id=tokenizer.bos_token_id,
102
+ eos_token_id=tokenizer.eos_token_id,
103
+ max_new_tokens=512,
104
+ do_sample=False,
105
+ use_cache=True
106
+ )
107
+
108
+ answer = tokenizer.decode(outputs[0].cpu().tolist(), skip_special_tokens=True)
109
+ print(f"{prepare_inputs['sft_format'][0]}", answer)
110
+ ```
111
+
112
+ ### Gradio Demo (TODO)
113
+
114
+
115
+ ## 4. License
116
+
117
+ This code repository is licensed under [MIT License](./LICENSE-CODE). The use of DeepSeek-VL2 models is subject to [DeepSeek Model License](./LICENSE-MODEL). DeepSeek-VL2 series supports commercial use.
118
+
119
+ ## 5. Citation
120
+
121
+ ```
122
+
123
+ @misc{wu2024deepseekvl2,
124
+ title={DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding},
125
+ author={Zhiyu Wu, Xiaokang Chen, Zizheng Pan, Xingchao Liu, Wen Liu, Damai Dai, Huazuo Gao, Yiyang Ma, Chengyue Wu, Bingxuan Wang, Zhenda Xie, Yu Wu, Kai Hu, Jiawei Wang, Yaofeng Sun, Yukun Li, Yishi Piao, Kang Guan, Aixin Liu, Xin Xie, Yuxiang You, Kai Dong, Xingkai Yu, Haowei Zhang, Liang Zhao, Yisong Wang, Chong Ruan},
126
+ year={2024}
127
+ }
128
+ ```
129
+
130
+ ## 6. Contact
131
+
132
+ If you have any questions, please raise an issue or contact us at [service@deepseek.com](mailto:service@deepseek.com).