Text Generation
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion
feature-extraction
nvidia
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Labs-Diffusion-8B", 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-8B", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-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-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-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-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-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-8B", "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-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-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Nemotron-Labs-Diffusion-8B with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B
Patch modeling_ministral.py: handle both `input_embeds` and `inputs_embeds` kwargs
Browse files- modeling_ministral.py +9 -1
modeling_ministral.py
CHANGED
|
@@ -420,13 +420,21 @@ class Ministral3Model(Ministral3PreTrainedModel):
|
|
| 420 |
|
| 421 |
if kwargs.get("use_causal_mask", False):
|
| 422 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 423 |
causal_mask = mask_function(
|
| 424 |
config=self.config,
|
| 425 |
-
input_embeds=inputs_embeds,
|
| 426 |
attention_mask=attention_mask,
|
| 427 |
cache_position=cache_position,
|
| 428 |
past_key_values=past_key_values,
|
| 429 |
position_ids=position_ids,
|
|
|
|
| 430 |
)
|
| 431 |
|
| 432 |
else:
|
|
|
|
| 420 |
|
| 421 |
if kwargs.get("use_causal_mask", False):
|
| 422 |
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 423 |
+
# `create_causal_mask` renamed the embeds kwarg from `input_embeds` (transformers <= 4.x)
|
| 424 |
+
# to `inputs_embeds` (transformers >= 5.0). Detect which the installed version uses.
|
| 425 |
+
import inspect
|
| 426 |
+
mask_input_kw = (
|
| 427 |
+
"inputs_embeds"
|
| 428 |
+
if "inputs_embeds" in inspect.signature(mask_function).parameters
|
| 429 |
+
else "input_embeds"
|
| 430 |
+
)
|
| 431 |
causal_mask = mask_function(
|
| 432 |
config=self.config,
|
|
|
|
| 433 |
attention_mask=attention_mask,
|
| 434 |
cache_position=cache_position,
|
| 435 |
past_key_values=past_key_values,
|
| 436 |
position_ids=position_ids,
|
| 437 |
+
**{mask_input_kw: inputs_embeds},
|
| 438 |
)
|
| 439 |
|
| 440 |
else:
|