Text Generation
Transformers
Safetensors
PyTorch
nemotron_labs_diffusion
feature-extraction
nvidia
conversational
custom_code
Instructions to use nvidia/Nemotron-Labs-Diffusion-8B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Nemotron-Labs-Diffusion-8B-Base", 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-Base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base 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-Base" # 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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B-Base
- SGLang
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base 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-Base" \ --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-Base", "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-Base" \ --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-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Nemotron-Labs-Diffusion-8B-Base with Docker Model Runner:
docker model run hf.co/nvidia/Nemotron-Labs-Diffusion-8B-Base
Upload model
Browse files- modeling_ministral.py +13 -9
- modeling_ministral_dlm.py +1 -1
modeling_ministral.py
CHANGED
|
@@ -417,15 +417,19 @@ class Ministral3Model(Ministral3PreTrainedModel):
|
|
| 417 |
if position_ids is None:
|
| 418 |
position_ids = cache_position.unsqueeze(0)
|
| 419 |
|
| 420 |
-
|
| 421 |
-
|
| 422 |
-
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
|
| 426 |
-
|
| 427 |
-
|
| 428 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 429 |
|
| 430 |
hidden_states = inputs_embeds
|
| 431 |
position_embeddings = self.rotary_emb(hidden_states, position_ids=position_ids)
|
|
|
|
| 417 |
if position_ids is None:
|
| 418 |
position_ids = cache_position.unsqueeze(0)
|
| 419 |
|
| 420 |
+
if self.training:
|
| 421 |
+
causal_mask = None
|
| 422 |
+
|
| 423 |
+
else:
|
| 424 |
+
mask_function = create_causal_mask if self.config.sliding_window is None else create_sliding_window_causal_mask
|
| 425 |
+
causal_mask = mask_function(
|
| 426 |
+
config=self.config,
|
| 427 |
+
input_embeds=inputs_embeds,
|
| 428 |
+
attention_mask=attention_mask,
|
| 429 |
+
cache_position=cache_position,
|
| 430 |
+
past_key_values=past_key_values,
|
| 431 |
+
position_ids=position_ids,
|
| 432 |
+
)
|
| 433 |
|
| 434 |
hidden_states = inputs_embeds
|
| 435 |
position_embeddings = self.rotary_emb(hidden_states, position_ids=position_ids)
|
modeling_ministral_dlm.py
CHANGED
|
@@ -518,7 +518,7 @@ class MinistralDiffEncoderModel(Ministral3PreTrainedModel, GenerationMixin):
|
|
| 518 |
|
| 519 |
if labels is not None and self.config.dlm_paradigm != 'autoregressive':
|
| 520 |
if masked_indices is not None:
|
| 521 |
-
|
| 522 |
|
| 523 |
if loss_mask is not None:
|
| 524 |
masked_indices[loss_mask == 0] = 0
|
|
|
|
| 518 |
|
| 519 |
if labels is not None and self.config.dlm_paradigm != 'autoregressive':
|
| 520 |
if masked_indices is not None:
|
| 521 |
+
assert p_mask is not None
|
| 522 |
|
| 523 |
if loss_mask is not None:
|
| 524 |
masked_indices[loss_mask == 0] = 0
|