Image-Text-to-Text
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion_vlm
feature-extraction
nvidia
multimodal
vlm
diffusion-language-model
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-VLM-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-VLM-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="nvidia/Nemotron-Labs-Diffusion-VLM-8B", trust_remote_code=True) 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("nvidia/Nemotron-Labs-Diffusion-VLM-8B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-VLM-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Nemotron-Labs-Diffusion-VLM-8B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "nvidia/Nemotron-Labs-Diffusion-VLM-8B", "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/nvidia/Nemotron-Labs-Diffusion-VLM-8B
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-VLM-8B 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 "nvidia/Nemotron-Labs-Diffusion-VLM-8B" \ --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": "nvidia/Nemotron-Labs-Diffusion-VLM-8B", "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 "nvidia/Nemotron-Labs-Diffusion-VLM-8B" \ --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": "nvidia/Nemotron-Labs-Diffusion-VLM-8B", "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 nvidia/Nemotron-Labs-Diffusion-VLM-8B with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-VLM-8B
Update chat_template.jinja
Browse files- chat_template.jinja +20 -1
chat_template.jinja
CHANGED
|
@@ -132,7 +132,7 @@
|
|
| 132 |
{%- endif -%}
|
| 133 |
{%- endif %}
|
| 134 |
{{- '<|im_start|>assistant\n' }}
|
| 135 |
-
{%-
|
| 136 |
{%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
|
| 137 |
{# Assistant message has tool calls. #}
|
| 138 |
{%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
|
@@ -188,6 +188,25 @@
|
|
| 188 |
{%- endif %}
|
| 189 |
{%- endif %}
|
| 190 |
{%- endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 191 |
{%- endgeneration %}
|
| 192 |
{{- '\n' }}
|
| 193 |
{%- elif message.role == "user" or message.role == "system" %}
|
|
|
|
| 132 |
{%- endif -%}
|
| 133 |
{%- endif %}
|
| 134 |
{{- '<|im_start|>assistant\n' }}
|
| 135 |
+
{%- set turn %}
|
| 136 |
{%- if message.tool_calls is defined and message.tool_calls is iterable and message.tool_calls | length > 0 %}
|
| 137 |
{# Assistant message has tool calls. #}
|
| 138 |
{%- set include_content = not (truncate_history_thinking and loop.index0 < ns.last_user_idx) %}
|
|
|
|
| 188 |
{%- endif %}
|
| 189 |
{%- endif %}
|
| 190 |
{%- endif %}
|
| 191 |
+
{%- endset %}
|
| 192 |
+
{#- What the generation prompt pre-fills stays out of the generation block: the model never generates it #}
|
| 193 |
+
{%- set prefill = '<think>\n' if enable_thinking else '<think></think>' %}
|
| 194 |
+
{%- if turn.startswith(prefill) %}
|
| 195 |
+
{%- set lead = prefill %}
|
| 196 |
+
{%- elif not turn.startswith('<think>') %}
|
| 197 |
+
{%- set lead = '' %}
|
| 198 |
+
{%- elif enable_thinking or '</think>' not in turn %}
|
| 199 |
+
{%- set lead = '<think>' %}
|
| 200 |
+
{%- else %}
|
| 201 |
+
{#- Reasoning with thinking off: the prompt pre-fills an empty block, so the whole block stays out #}
|
| 202 |
+
{%- set lead = turn.split('</think>')[0] ~ '</think>' %}
|
| 203 |
+
{%- if turn[lead | length:].startswith('\n') %}
|
| 204 |
+
{%- set lead = lead ~ '\n' %}
|
| 205 |
+
{%- endif %}
|
| 206 |
+
{%- endif %}
|
| 207 |
+
{{- lead }}
|
| 208 |
+
{%- generation %}
|
| 209 |
+
{{- turn[lead | length:] }}
|
| 210 |
{%- endgeneration %}
|
| 211 |
{{- '\n' }}
|
| 212 |
{%- elif message.role == "user" or message.role == "system" %}
|