Instructions to use unsloth/DeepSeek-V4-Flash-Vision-Exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/DeepSeek-V4-Flash-Vision-Exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="unsloth/DeepSeek-V4-Flash-Vision-Exp") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("unsloth/DeepSeek-V4-Flash-Vision-Exp") model = AutoModelForCausalLM.from_pretrained("unsloth/DeepSeek-V4-Flash-Vision-Exp", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use unsloth/DeepSeek-V4-Flash-Vision-Exp with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "unsloth/DeepSeek-V4-Flash-Vision-Exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "unsloth/DeepSeek-V4-Flash-Vision-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/unsloth/DeepSeek-V4-Flash-Vision-Exp
- SGLang
How to use unsloth/DeepSeek-V4-Flash-Vision-Exp 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 "unsloth/DeepSeek-V4-Flash-Vision-Exp" \ --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": "unsloth/DeepSeek-V4-Flash-Vision-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "unsloth/DeepSeek-V4-Flash-Vision-Exp" \ --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": "unsloth/DeepSeek-V4-Flash-Vision-Exp", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use unsloth/DeepSeek-V4-Flash-Vision-Exp with Docker Model Runner:
docker model run hf.co/unsloth/DeepSeek-V4-Flash-Vision-Exp
Minimal inference
This directory contains a readable reference implementation rather than a
production serving engine. The model code includes Vision + Aligner, DFlash,
MoE, Hyper-Connections, and Transformer.forward_spec() for the DSpark forward
path. The generation loop remains straightforward autoregressive sampling.
Install
python -m pip install -r requirements.txt
Convert Hugging Face weights
The reference runtime uses one converted checkpoint file per tensor-parallel rank. From this directory:
export HF_CKPT_PATH=/path/to/DeepSeek-V4-Flash-Vision-Exp-HF
export SAVE_PATH=/path/to/DeepSeek-V4-Flash-Vision-Exp-TP4
export MP=4
python convert.py \
--hf-ckpt-path "${HF_CKPT_PATH}" \
--save-path "${SAVE_PATH}" \
--n-experts 256 \
--model-parallel "${MP}" \
--expert-dtype fp4
convert.py also copies tokenizer.json and tokenizer_config.json into the
converted checkpoint directory. --tokenizer-path can be used when tokenizer
files live outside the weight directory.
Run the equivalent TXT and JSON examples
export CKPT_PATH=/path/to/DeepSeek-V4-Flash-Vision-Exp-TP4
export MP=4
INPUT_FILE=examples/example_vl.txt ./run.sh
INPUT_FILE=examples/example_vl_harmony.json ./run.sh
The two files express the same interleaved two-image prompt and therefore produce identical encoded prompts and input token IDs.
For interactive chat:
torchrun --nproc-per-node "${MP}" generate.py \
--ckpt-path "${CKPT_PATH}" \
--config config.json \
--interactive \
--temperature 1.0
For multi-node execution, pass the usual torchrun --nnodes, --node-rank,
--master-addr, and --master-port arguments before generate.py.
Preprocessing tests
From the repository root:
python -m pytest -q \
encoding/test_encoding_dsv4.py \
inference/test_image_processor.py