Image-Text-to-Text
Transformers
Safetensors
deepseek_v4
text-generation
Eval Results
8-bit precision
fp8
Instructions to use deepseek-ai/DeepSeek-V4-Flash-Vision-Exp with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-V4-Flash-Vision-Exp with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="deepseek-ai/DeepSeek-V4-Flash-Vision-Exp")# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-V4-Flash-Vision-Exp") model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-V4-Flash-Vision-Exp", device_map="auto") - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/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 "deepseek-ai/DeepSeek-V4-Flash-Vision-Exp" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4-Flash-Vision-Exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp
- SGLang
How to use deepseek-ai/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 "deepseek-ai/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/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4-Flash-Vision-Exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "deepseek-ai/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/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4-Flash-Vision-Exp", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use deepseek-ai/DeepSeek-V4-Flash-Vision-Exp with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-V4-Flash-Vision-Exp
Commit ·
86f746b
1
Parent(s): 0cd0d27
Add thinking-mode encoding example and change default interactive temperature to 1.0
Browse files- encoding/README.md +15 -0
- inference/README.md +1 -1
- inference/generate.py +2 -2
encoding/README.md
CHANGED
|
@@ -21,11 +21,26 @@ messages = [{
|
|
| 21 |
],
|
| 22 |
}]
|
| 23 |
|
|
|
|
| 24 |
prompt, media = encode_messages(
|
| 25 |
messages,
|
| 26 |
thinking_mode="chat",
|
| 27 |
return_multi_modal_data=True,
|
| 28 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
```
|
| 30 |
|
| 31 |
Images are represented in the prompt by `<|deepseek_image|>`. `media["images"]`
|
|
|
|
| 21 |
],
|
| 22 |
}]
|
| 23 |
|
| 24 |
+
# non-thinking
|
| 25 |
prompt, media = encode_messages(
|
| 26 |
messages,
|
| 27 |
thinking_mode="chat",
|
| 28 |
return_multi_modal_data=True,
|
| 29 |
)
|
| 30 |
+
# prompt:
|
| 31 |
+
# '<|begin▁of▁sentence|><|User|>第一张图\n\n<|deepseek_image|>\n\n有什么内容?<|Assistant|></think>'
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
# # thinking with `max` reasoning_effort
|
| 35 |
+
# prompt, media = encode_messages(
|
| 36 |
+
# messages,
|
| 37 |
+
# thinking_mode="thinking",
|
| 38 |
+
# reasoning_effort="max",
|
| 39 |
+
# return_multi_modal_data=True,
|
| 40 |
+
# )
|
| 41 |
+
# prompt:
|
| 42 |
+
# <|begin▁of▁sentence|>Reasoning Effort: Beyond maximum — exhaustive, relentless, and uncompromising.\nYou MUST reason with the utmost depth and rigor, leaving absolutely nothing to chance: exhaustively decompose the problem into its most fundamental components, trace every causal chain to its root, and resolve the underlying cause rather than any surface symptom.\nDo not stop reasoning until you have independently verified the solution from multiple angles and are certain that no assumption remains unchecked and no error remains undiscovered.\n\n<|User|>第一张图\n\n<|deepseek_image|>\n\n有什么内容?<|Assistant|><think>
|
| 43 |
+
|
| 44 |
```
|
| 45 |
|
| 46 |
Images are represented in the prompt by `<|deepseek_image|>`. `media["images"]`
|
inference/README.md
CHANGED
|
@@ -53,7 +53,7 @@ torchrun --nproc-per-node "${MP}" generate.py \
|
|
| 53 |
--ckpt-path "${CKPT_PATH}" \
|
| 54 |
--config config.json \
|
| 55 |
--interactive \
|
| 56 |
-
--temperature
|
| 57 |
```
|
| 58 |
|
| 59 |
For multi-node execution, pass the usual `torchrun --nnodes`, `--node-rank`,
|
|
|
|
| 53 |
--ckpt-path "${CKPT_PATH}" \
|
| 54 |
--config config.json \
|
| 55 |
--interactive \
|
| 56 |
+
--temperature 1.0
|
| 57 |
```
|
| 58 |
|
| 59 |
For multi-node execution, pass the usual `torchrun --nnodes`, `--node-rank`,
|
inference/generate.py
CHANGED
|
@@ -198,12 +198,12 @@ if __name__ == "__main__":
|
|
| 198 |
parser.add_argument("--interactive", action="store_true")
|
| 199 |
parser.add_argument("--thinking-mode", type=str, default="chat", choices=["chat", "thinking"])
|
| 200 |
parser.add_argument("--max-new-tokens", type=int, default=None, help="default: 16384 for .json input, 200 otherwise")
|
| 201 |
-
parser.add_argument("--temperature", type=float, default=None, help="default: 0.99 for .json input,
|
| 202 |
args = parser.parse_args()
|
| 203 |
assert args.input_file or args.interactive, "Either input-file or interactive mode must be specified"
|
| 204 |
json_input = args.input_file.endswith(".json")
|
| 205 |
if args.max_new_tokens is None:
|
| 206 |
args.max_new_tokens = 16384 if json_input else 200
|
| 207 |
if args.temperature is None:
|
| 208 |
-
args.temperature = 0.99 if json_input else
|
| 209 |
main(args.ckpt_path, args.config, args.input_file, args.interactive, args.max_new_tokens, args.temperature, args.thinking_mode)
|
|
|
|
| 198 |
parser.add_argument("--interactive", action="store_true")
|
| 199 |
parser.add_argument("--thinking-mode", type=str, default="chat", choices=["chat", "thinking"])
|
| 200 |
parser.add_argument("--max-new-tokens", type=int, default=None, help="default: 16384 for .json input, 200 otherwise")
|
| 201 |
+
parser.add_argument("--temperature", type=float, default=None, help="default: 0.99 for .json input, 1.0 otherwise")
|
| 202 |
args = parser.parse_args()
|
| 203 |
assert args.input_file or args.interactive, "Either input-file or interactive mode must be specified"
|
| 204 |
json_input = args.input_file.endswith(".json")
|
| 205 |
if args.max_new_tokens is None:
|
| 206 |
args.max_new_tokens = 16384 if json_input else 200
|
| 207 |
if args.temperature is None:
|
| 208 |
+
args.temperature = 0.99 if json_input else 1.0
|
| 209 |
main(args.ckpt_path, args.config, args.input_file, args.interactive, args.max_new_tokens, args.temperature, args.thinking_mode)
|