Instructions to use deepseek-ai/DeepSeek-V4.1-Flash with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use deepseek-ai/DeepSeek-V4.1-Flash 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.1-Flash") 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 AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-V4.1-Flash", device_map="auto") - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use deepseek-ai/DeepSeek-V4.1-Flash 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.1-Flash" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "deepseek-ai/DeepSeek-V4.1-Flash", "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/deepseek-ai/DeepSeek-V4.1-Flash
- SGLang
How to use deepseek-ai/DeepSeek-V4.1-Flash 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.1-Flash" \ --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": "deepseek-ai/DeepSeek-V4.1-Flash", "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 "deepseek-ai/DeepSeek-V4.1-Flash" \ --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": "deepseek-ai/DeepSeek-V4.1-Flash", "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 deepseek-ai/DeepSeek-V4.1-Flash with Docker Model Runner:
docker model run hf.co/deepseek-ai/DeepSeek-V4.1-Flash
Native Transformers text-backbone support proposal (#48721)
Hello DeepSeek team and community,
I have an open community proposal for native Transformers support for the DeepSeek-V4.1-Flash text backbone:
- Pull request: https://github.com/huggingface/transformers/pull/48721
- Tracking issue: https://github.com/huggingface/transformers/issues/48755
Would someone from DeepSeek be willing to review the architecture and checkpoint-loading semantics? This is an unmerged proposal, not support already shipped in a Transformers release, and not an officially endorsed integration.
Scope
The implementation covers the composite/text configuration, published checkpoint-name conversion, FP8/packed-FP4 weight loading, Engram row lookup, single-pass mHC, CSA2 Full/Reindex/Reuse source sharing, hierarchical indexing, and cached text generation. It follows the existing Transformers model, quantizer and expert-parallel conventions.
Not included: the vision tower/processor/multimodal wrapper, DSpark/MTP speculative decoding, a tool-calling server, or bounded NVMe expert/Engram streaming. The release's Python/Rust prompt encoders are still needed; loading the model does not supply a missing Jinja chat template.
Evidence and limits
The PR links released-checkpoint loading/generation runs, 8×H200 expert-parallel measurements (about 327 ms/token in the measured batch-1 greedy setup), and passcode retrieval at approximately 262k, 524k and 1,048k prompt tokens. These are specific measurements, not a comprehensive quality benchmark or proof of every backend/batch mode.
The numerical architecture comparison is a reduced five-layer, random-weight FP32 CPU run with local kernel adaptations, not full-checkpoint numerical parity. At prefill 200 + 24 teacher-forced decode steps it measured maximum absolute logit differences of 5.461e-4 with activation fake quantization and 8.404e-5 with it disabled, with 100% sampled argmax agreement. Engram is tested separately rather than enabled in that full-model comparison.
We also reproduced the reference index-key ownership issue already addressed by @ZenAlexa 's PR #12. Thank you for the official-kernel H100 checks there. Our complementary CPU reference-model self-consistency reproduction and scripts are in discussion #41; we have supported the existing PR instead of opening a duplicate.
Could you review Full/Reindex/Reuse ownership, hierarchical visibility, QAT placement, and the Engram/checkpoint mapping against the intended implementation? A canonical layer trace or additional reference test cases would be especially helpful.
I made some updates to the repo, work is still in progress.
Few more things fixed in Transformers commit 62d7ebd: padding-aware compressed attention, preservation of composite quantization metadata in bare text loads, and atomic refusal of unsupported CSA
Vision follow-up opened as #48768: https://github.com/huggingface/transformers/pull/48768
It is a draft dependent on #48721, with a vision-only diff so reviewers can isolate the addition. The author has reviewed all code; AI-assisted provenance is disclosed. The existing text PR remains separate.
The vision implementation has 296 passing model/processor tests and reduced-model reference checks.
Holy AI agent
We can see you're using HF CLI with a coding agent (and you speak like one)
Holy AI agent
We can see you're using HF CLI with a coding agent (and you speak like one)
And I need your clothes, your boots and your motorcycle...
Yes, there is a bit of that, but I still come behind and review as a mere human.