Text Generation
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion
feature-extraction
nvidia
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Labs-Diffusion-3B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("nvidia/Nemotron-Labs-Diffusion-3B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-3B 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-3B" # 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-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-3B
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-3B 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-3B" \ --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-3B", "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 "nvidia/Nemotron-Labs-Diffusion-3B" \ --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-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Nemotron-Labs-Diffusion-3B with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-3B
Upload tokenizer
Browse files- chat_template.jinja +0 -7
chat_template.jinja
CHANGED
|
@@ -11,7 +11,6 @@
|
|
| 11 |
{% endmacro %}
|
| 12 |
{%- set enable_thinking = enable_thinking if enable_thinking is defined else False %}
|
| 13 |
{%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else True %}
|
| 14 |
-
|
| 15 |
{%- set ns = namespace(last_user_idx = -1) %}
|
| 16 |
{%- set loop_messages = messages %}
|
| 17 |
{%- for m in loop_messages %}
|
|
@@ -19,7 +18,6 @@
|
|
| 19 |
{%- set ns.last_user_idx = loop.index0 %}
|
| 20 |
{%- endif %}
|
| 21 |
{%- endfor %}
|
| 22 |
-
|
| 23 |
{%- if messages[0]["role"] == "system" %}
|
| 24 |
{%- set system_message = messages[0]["content"] %}
|
| 25 |
{%- set loop_messages = messages[1:] %}
|
|
@@ -88,11 +86,8 @@
|
|
| 88 |
{{- '\n</function>' }}
|
| 89 |
{%- endfor %}
|
| 90 |
{{- "\n</tools>" }}
|
| 91 |
-
|
| 92 |
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 93 |
{%- endif %}
|
| 94 |
-
|
| 95 |
-
|
| 96 |
{%- if system_message is defined %}
|
| 97 |
{{- '<|im_end|>\n' }}
|
| 98 |
{%- else %}
|
|
@@ -100,7 +95,6 @@
|
|
| 100 |
{{- '<|im_end|>\n' }}
|
| 101 |
{%- endif %}
|
| 102 |
{%- endif %}
|
| 103 |
-
|
| 104 |
{%- for message in loop_messages %}
|
| 105 |
{%- if message.role == "assistant" %}
|
| 106 |
{# Add reasoning content in to content field for unified processing below. #}
|
|
@@ -194,7 +188,6 @@
|
|
| 194 |
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
|
| 195 |
{%- endif %}
|
| 196 |
{%- endfor %}
|
| 197 |
-
|
| 198 |
{%- if add_generation_prompt %}
|
| 199 |
{%- if enable_thinking %}
|
| 200 |
{{- '<|im_start|>assistant\n<think>\n' }}
|
|
|
|
| 11 |
{% endmacro %}
|
| 12 |
{%- set enable_thinking = enable_thinking if enable_thinking is defined else False %}
|
| 13 |
{%- set truncate_history_thinking = truncate_history_thinking if truncate_history_thinking is defined else True %}
|
|
|
|
| 14 |
{%- set ns = namespace(last_user_idx = -1) %}
|
| 15 |
{%- set loop_messages = messages %}
|
| 16 |
{%- for m in loop_messages %}
|
|
|
|
| 18 |
{%- set ns.last_user_idx = loop.index0 %}
|
| 19 |
{%- endif %}
|
| 20 |
{%- endfor %}
|
|
|
|
| 21 |
{%- if messages[0]["role"] == "system" %}
|
| 22 |
{%- set system_message = messages[0]["content"] %}
|
| 23 |
{%- set loop_messages = messages[1:] %}
|
|
|
|
| 86 |
{{- '\n</function>' }}
|
| 87 |
{%- endfor %}
|
| 88 |
{{- "\n</tools>" }}
|
|
|
|
| 89 |
{{- '\n\nIf you choose to call a function ONLY reply in the following format with NO suffix:\n\n<tool_call>\n<function=example_function_name>\n<parameter=example_parameter_1>\nvalue_1\n</parameter>\n<parameter=example_parameter_2>\nThis is the value for the second parameter\nthat can span\nmultiple lines\n</parameter>\n</function>\n</tool_call>\n\n<IMPORTANT>\nReminder:\n- Function calls MUST follow the specified format: an inner <function=...></function> block must be nested within <tool_call></tool_call> XML tags\n- Required parameters MUST be specified\n- You may provide optional reasoning for your function call in natural language BEFORE the function call, but NOT after\n- If there is no function call available, answer the question like normal with your current knowledge and do not tell the user about function calls\n</IMPORTANT>' }}
|
| 90 |
{%- endif %}
|
|
|
|
|
|
|
| 91 |
{%- if system_message is defined %}
|
| 92 |
{{- '<|im_end|>\n' }}
|
| 93 |
{%- else %}
|
|
|
|
| 95 |
{{- '<|im_end|>\n' }}
|
| 96 |
{%- endif %}
|
| 97 |
{%- endif %}
|
|
|
|
| 98 |
{%- for message in loop_messages %}
|
| 99 |
{%- if message.role == "assistant" %}
|
| 100 |
{# Add reasoning content in to content field for unified processing below. #}
|
|
|
|
| 188 |
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>\n' }}
|
| 189 |
{%- endif %}
|
| 190 |
{%- endfor %}
|
|
|
|
| 191 |
{%- if add_generation_prompt %}
|
| 192 |
{%- if enable_thinking %}
|
| 193 |
{{- '<|im_start|>assistant\n<think>\n' }}
|