Instructions to use alejandro-rodriguez/tiny-random-nemotron-h with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use alejandro-rodriguez/tiny-random-nemotron-h with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="alejandro-rodriguez/tiny-random-nemotron-h") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("alejandro-rodriguez/tiny-random-nemotron-h") model = AutoModelForCausalLM.from_pretrained("alejandro-rodriguez/tiny-random-nemotron-h", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use alejandro-rodriguez/tiny-random-nemotron-h with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "alejandro-rodriguez/tiny-random-nemotron-h" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "alejandro-rodriguez/tiny-random-nemotron-h", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/alejandro-rodriguez/tiny-random-nemotron-h
- SGLang
How to use alejandro-rodriguez/tiny-random-nemotron-h 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 "alejandro-rodriguez/tiny-random-nemotron-h" \ --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": "alejandro-rodriguez/tiny-random-nemotron-h", "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 "alejandro-rodriguez/tiny-random-nemotron-h" \ --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": "alejandro-rodriguez/tiny-random-nemotron-h", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use alejandro-rodriguez/tiny-random-nemotron-h with Docker Model Runner:
docker model run hf.co/alejandro-rodriguez/tiny-random-nemotron-h
Tiny random NemotronH model for the OpenVINO tests of optimum-intel. The tokenizer is the one of nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16.
Here is the code to create this tiny model:
"""Create a tiny random NemotronH model with every block type (Mamba2, MoE, attention, MLP).
Built with transformers 5.15.1. The layer types are saved as `hybrid_override_pattern` instead of
`layers_block_type`: transformers 5.13 renamed them ("mamba" -> "linear_attention", "attention" -> "full_attention")
and 5.6 to 5.12 only accept the old names, while every version with NemotronH converts the pattern.
Usage: python create_tiny_random_nemotron_h.py [output_dir]
"""
import json
import sys
from pathlib import Path
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, NemotronHConfig
# Mamba2, MoE, attention, Mamba2, MLP, attention
HYBRID_OVERRIDE_PATTERN = "ME*M-*"
output_dir = Path(sys.argv[1] if len(sys.argv) > 1 else "./tiny-random-nemotron-h")
tokenizer = AutoTokenizer.from_pretrained("nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-BF16")
config = NemotronHConfig(
vocab_size=len(tokenizer),
hidden_size=64,
hybrid_override_pattern=HYBRID_OVERRIDE_PATTERN,
num_attention_heads=4,
num_key_value_heads=2,
# differs from hidden_size // num_attention_heads, as in NVIDIA-Nemotron-3-Nano-4B
head_dim=32,
intermediate_size=128,
mamba_num_heads=8,
mamba_head_dim=8,
n_groups=2,
ssm_state_size=16,
conv_kernel=4,
# several chunks for the reference SSD scan of the prompts used in tests
chunk_size=8,
n_routed_experts=8,
num_experts_per_tok=2,
moe_intermediate_size=32,
moe_shared_expert_intermediate_size=64,
routed_scaling_factor=2.5,
n_group=1,
topk_group=1,
tie_word_embeddings=False,
)
config.dtype = "float32"
torch.manual_seed(42)
model = AutoModelForCausalLM.from_config(config).float().eval()
output_dir.mkdir(parents=True, exist_ok=True)
model.save_pretrained(output_dir)
tokenizer.save_pretrained(output_dir)
config_file = output_dir / "config.json"
saved_config = json.loads(config_file.read_text(encoding="utf-8"))
saved_config.pop("layers_block_type")
saved_config.pop("mtp_layers_block_type", None)
saved_config["hybrid_override_pattern"] = HYBRID_OVERRIDE_PATTERN
config_file.write_text(json.dumps(saved_config, indent=2, sort_keys=True) + "\n", encoding="utf-8")
- Downloads last month
- 90