Text Generation
Transformers
Safetensors
PyTorch
English
nemotron-nas
nvidia
llama-3
conversational
custom_code
Instructions to use nvidia/Llama-3_1-Nemotron-51B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Llama-3_1-Nemotron-51B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Llama-3_1-Nemotron-51B-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("nvidia/Llama-3_1-Nemotron-51B-Instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/Llama-3_1-Nemotron-51B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Llama-3_1-Nemotron-51B-Instruct" # 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/Llama-3_1-Nemotron-51B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Llama-3_1-Nemotron-51B-Instruct
- SGLang
How to use nvidia/Llama-3_1-Nemotron-51B-Instruct 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/Llama-3_1-Nemotron-51B-Instruct" \ --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/Llama-3_1-Nemotron-51B-Instruct", "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/Llama-3_1-Nemotron-51B-Instruct" \ --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/Llama-3_1-Nemotron-51B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Llama-3_1-Nemotron-51B-Instruct with Docker Model Runner:
docker model run hf.co/nvidia/Llama-3_1-Nemotron-51B-Instruct
_prepare_generation_config bugfix (failed due to version update in transformers) (#25)
Browse files- _prepare_generation_config bugfix (failed due to version update in transformers) (aabac526c6963d3107659c16ef56c50408e96b65)
Co-authored-by: Ido Shahaf <ishahaf@users.noreply.huggingface.co>
- modeling_decilm.py +5 -2
modeling_decilm.py
CHANGED
|
@@ -833,10 +833,13 @@ class DeciLMPreTrainedModel(PreTrainedModel):
|
|
| 833 |
module.weight.data[module.padding_idx].zero_()
|
| 834 |
|
| 835 |
def _prepare_generation_config(
|
| 836 |
-
self,
|
|
|
|
|
|
|
|
|
|
| 837 |
) -> tuple[GenerationConfig, dict]:
|
| 838 |
# DeciLM-specific code
|
| 839 |
-
generation_config, model_kwargs = super()._prepare_generation_config(generation_config, **kwargs)
|
| 840 |
generation_config.cache_implementation = "variable"
|
| 841 |
NEED_SETUP_CACHE_CLASSES_MAPPING["variable"] = VariableCache
|
| 842 |
return generation_config, model_kwargs
|
|
|
|
| 833 |
module.weight.data[module.padding_idx].zero_()
|
| 834 |
|
| 835 |
def _prepare_generation_config(
|
| 836 |
+
self,
|
| 837 |
+
generation_config: Optional[GenerationConfig],
|
| 838 |
+
*args,
|
| 839 |
+
**kwargs,
|
| 840 |
) -> tuple[GenerationConfig, dict]:
|
| 841 |
# DeciLM-specific code
|
| 842 |
+
generation_config, model_kwargs = super()._prepare_generation_config(generation_config, *args, **kwargs)
|
| 843 |
generation_config.cache_implementation = "variable"
|
| 844 |
NEED_SETUP_CACHE_CLASSES_MAPPING["variable"] = VariableCache
|
| 845 |
return generation_config, model_kwargs
|