Instructions to use nvidia/Hymba-1.5B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Hymba-1.5B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Hymba-1.5B-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/Hymba-1.5B-Instruct", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use nvidia/Hymba-1.5B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "nvidia/Hymba-1.5B-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/Hymba-1.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Hymba-1.5B-Instruct
- SGLang
How to use nvidia/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Hymba-1.5B-Instruct with Docker Model Runner:
docker model run hf.co/nvidia/Hymba-1.5B-Instruct
| # Prompt user to specify CUDA version | |
| read -p "Enter CUDA version (12.1 or 12.4): " cuda_version | |
| # Verify CUDA version input | |
| if [[ "$cuda_version" != "12.1" && "$cuda_version" != "12.4" ]]; then | |
| echo "Invalid CUDA version specified. Please choose either 12.1 or 12.4." | |
| exit 1 | |
| fi | |
| # Install PyTorch with the specified CUDA version | |
| conda install pytorch==2.5.0 torchvision==0.20.0 torchaudio==2.5.0 pytorch-cuda=$cuda_version -c pytorch -c nvidia | |
| # Install other packages | |
| pip install --upgrade transformers | |
| pip install tiktoken | |
| pip install sentencepiece | |
| pip install protobuf | |
| pip install ninja einops triton packaging | |
| # Clone and install Mamba | |
| git clone https://github.com/state-spaces/mamba.git | |
| cd mamba | |
| pip install -e . | |
| cd .. | |
| # Clone and install causal-conv1d with specified CUDA version | |
| git clone https://github.com/Dao-AILab/causal-conv1d.git | |
| cd causal-conv1d | |
| export CUDA_HOME=/usr/local/cuda-$cuda_version | |
| TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0" python setup.py install | |
| cd .. | |
| # Clone and install attention-gym | |
| git clone https://github.com/pytorch-labs/attention-gym.git | |
| cd attention-gym | |
| pip install . | |
| cd .. | |
| # Install Flash Attention | |
| pip install flash_attn | |
| echo "Installation completed with CUDA $cuda_version." |