Instructions to use nvidia/Hymba-1.5B-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use nvidia/Hymba-1.5B-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="nvidia/Hymba-1.5B-Base", 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-Base", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use nvidia/Hymba-1.5B-Base 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-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/Hymba-1.5B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/nvidia/Hymba-1.5B-Base
- SGLang
How to use nvidia/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-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/Hymba-1.5B-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use nvidia/Hymba-1.5B-Base with Docker Model Runner:
docker model run hf.co/nvidia/Hymba-1.5B-Base
fix int/str for conv_dim indexing
#5
by winglian - opened
No description provided.
When loading the model in transformers with
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("nvidia/Hymba-1.5B-Base", trust_remote_code=True)
attempting to debug or print model.config results in the error:
>>> model.config
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/root/miniconda3/envs/py3.11/lib/python3.11/site-packages/transformers/configuration_utils.py", line 778, in __repr__
return f"{self.__class__.__name__} {self.to_json_string()}"
^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/py3.11/lib/python3.11/site-packages/transformers/configuration_utils.py", line 899, in to_json_string
return json.dumps(config_dict, indent=2, sort_keys=True) + "\n"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/py3.11/lib/python3.11/json/__init__.py", line 238, in dumps
**kw).encode(obj)
^^^^^^^^^^^
File "/root/miniconda3/envs/py3.11/lib/python3.11/json/encoder.py", line 202, in encode
chunks = list(chunks)
^^^^^^^^^^^^
File "/root/miniconda3/envs/py3.11/lib/python3.11/json/encoder.py", line 432, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "/root/miniconda3/envs/py3.11/lib/python3.11/json/encoder.py", line 406, in _iterencode_dict
yield from chunks
File "/root/miniconda3/envs/py3.11/lib/python3.11/json/encoder.py", line 354, in _iterencode_dict
items = sorted(dct.items())
^^^^^^^^^^^^^^^^^^^
TypeError: '<' not supported between instances of 'int' and 'str'
the issue is more apparent when using model.config.to_dict() and inspecting the conv_dim key:
'conv_dim': {'0': 3200, '1': 3200, '2': 3200, '3': 3200, '4': 3200, '5': 3200, '6': 3200, '7': 3200, '8': 3200, '9': 3200, '10': 3200, '11': 3200, '12': 3200, '13': 3200, '14': 3200, '15': 3200, '16': 3200, '17': 3200, '18': 3200, '19': 3200, '20': 3200, '21': 3200, '22': 3200, '23': 3200, '24': 3200, '25': 3200, '26': 3200, '27': 3200, '28': 3200, '29': 3200, '30': 3200, '31': 3200, 0: 3200, 1: 3200, 2: 3200, 3: 3200, 4: 3200, 5: 3200, 6: 3200, 7: 3200, 8: 3200, 9: 3200, 10: 3200, 11: 3200, 12: 3200, 13: 3200, 14: 3200, 15: 3200, 16: 3200, 17: 3200, 18: 3200, 19: 3200, 20: 3200, 21: 3200, 22: 3200, 23: 3200, 24: 3200, 25: 3200, 26: 3200, 27: 3200, 28: 3200, 29: 3200, 30: 3200, 31: 3200}
here you can see the layer indexes end up as both int and strings leading to the error above.
SimonX changed pull request status to merged
Thanks for pointing it out and fixing it.