Run this model with HF Jobs
Run FriendliAI/deepseek-vl2-tiny on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/FriendliAI/deepseek-vl2-tiny. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/FriendliAI/deepseek-vl2-tiny on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/FriendliAI/deepseek-vl2-tiny. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/FriendliAI/deepseek-vl2-tiny. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use FriendliAI/deepseek-vl2-tiny with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FriendliAI/deepseek-vl2-tiny with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="FriendliAI/deepseek-vl2-tiny") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("FriendliAI/deepseek-vl2-tiny", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FriendliAI/deepseek-vl2-tiny with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FriendliAI/deepseek-vl2-tiny" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FriendliAI/deepseek-vl2-tiny", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/FriendliAI/deepseek-vl2-tiny
- SGLang
How to use FriendliAI/deepseek-vl2-tiny with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FriendliAI/deepseek-vl2-tiny" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FriendliAI/deepseek-vl2-tiny", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FriendliAI/deepseek-vl2-tiny" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FriendliAI/deepseek-vl2-tiny", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use FriendliAI/deepseek-vl2-tiny with Docker Model Runner:
docker model run hf.co/FriendliAI/deepseek-vl2-tiny
diff for compatibility
Browse filesFiles changed (2)
- README.md+12-127
- tokenizer_config.json+2-1
5 unmodified lines67891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411425 unmodified lineslibrary_name: transformers---## 1. IntroductionIntroducing 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.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.[DeepSeek-VL2: Mixture-of-Experts Vision-Language Models for Advanced Multimodal Understanding](https://arxiv.org/abs/2412.10302)[**Github Repository**](https://github.com/deepseek-ai/DeepSeek-VL2)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)### 2. Model SummaryDeepSeek-VL2-tiny is built on DeepSeekMoE-3B (total activated parameters are 1.0B).## 3. Quick Start### InstallationOn the basis of `Python >= 3.8` environment, install the necessary dependencies by running the following command:```shellpip install -e .```### Notifications1. We suggest to use a temperature T <= 0.7 when sampling. We observe a larger temperature decreases the generation quality.2. To keep the number of tokens managable in the context window, we apply dynamic tiling strategy to <=2 images. When there are >=3 images, we directly pad the images to 384*384 as inputs without tiling.3. The main difference between DeepSeek-VL2-Tiny, DeepSeek-VL2-Small and DeepSeek-VL2 is the base LLM.### Simple Inference Example```pythonimport torchfrom transformers import AutoModelForCausalLMfrom deepseek_vl.models import DeepseekVLV2Processor, DeepseekVLV2ForCausalLMfrom deepseek_vl.utils.io import load_pil_images# specify the path to the modelmodel_path = "deepseek-ai/deepseek-vl2-small"vl_chat_processor: DeepseekVLV2Processor = DeepseekVLV2Processor.from_pretrained(model_path)tokenizer = vl_chat_processor.tokenizervl_gpt: DeepseekVLV2ForCausalLM = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)vl_gpt = vl_gpt.to(torch.bfloat16).cuda().eval()## single image conversation exampleconversation = [{"role": "<|User|>","content": "<image>\n<|ref|>The giraffe at the back.<|/ref|>.","images": ["./images/visual_grounding.jpeg"],},{"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 inputspil_images = load_pil_images(conversation)prepare_inputs = vl_chat_processor(conversations=conversation,images=pil_images,force_batchify=True,system_prompt="").to(vl_gpt.device)# run image encoder to get the image embeddingsinputs_embeds = vl_gpt.prepare_inputs_embeds(**prepare_inputs)# run the model to get the responseoutputs = 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)```### Gradio Demo (TODO)## 4. LicenseThis 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.## 5. Citation```@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},}```## 6. ContactIf you have any questions, please raise an issue or contact us at [service@deepseek.com](mailto:service@deepseek.com).5 unmodified lines67891011121314151617181920212223242526275 unmodified lineslibrary_name: transformers---<!-- header start --><p align="center"><img src="https://huggingface.co/datasets/FriendliAI/documentation-images/resolve/main/model-card-assets/friendliai.png" width="100%" alt="FriendliAI Logo"></p><!-- header end --># deepseek-ai/deepseek-vl2-tiny* Model creator: [deepseek-ai](https://huggingface.co/deepseek-ai)* Original model: [deepseek-vl2-tiny](https://huggingface.co/deepseek-ai/deepseek-vl2-tiny)## Differences* Added missing chat template to tokenizer_config.json## LicenseRefer to the license of the original model card.
6615 unmodified lines6616661766186619662066212 unmodified lines66246625662666276615 unmodified lines"<|Assistant|>"],"bos_token": "<|begin▁of▁sentence|>","clean_up_tokenization_spaces": false,"eos_token": "<|end▁of▁sentence|>","model_max_length": 1000000000000000019884624838656,2 unmodified lines"tokenizer_class": "LlamaTokenizer","unk_token": null,"use_default_system_prompt": false}6615 unmodified lines66166617661866196620662166222 unmodified lines66256626662766286615 unmodified lines"<|Assistant|>"],"bos_token": "<|begin▁of▁sentence|>","chat_template": "{{ '<|User|>: <image>\n'}}{% for message in messages[-1:] %}{% for content in message['content'] | selectattr('type', 'equalto', 'text') %}{{ content['text'] }}{% endfor %}{% endfor %}{{ '\n\n<|Assistant|>:' }}","clean_up_tokenization_spaces": false,"eos_token": "<|end▁of▁sentence|>","model_max_length": 1000000000000000019884624838656,2 unmodified lines"tokenizer_class": "LlamaTokenizer","unk_token": null,"use_default_system_prompt": false}
README.md+12-127
tokenizer_config.json+2-1