Instructions to use Q-bert/MambaHermes-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Q-bert/MambaHermes-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Q-bert/MambaHermes-3B", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Q-bert/MambaHermes-3B", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Q-bert/MambaHermes-3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Q-bert/MambaHermes-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Q-bert/MambaHermes-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Q-bert/MambaHermes-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Q-bert/MambaHermes-3B
- SGLang
How to use Q-bert/MambaHermes-3B 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 "Q-bert/MambaHermes-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Q-bert/MambaHermes-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'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 "Q-bert/MambaHermes-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Q-bert/MambaHermes-3B", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Q-bert/MambaHermes-3B with Docker Model Runner:
docker model run hf.co/Q-bert/MambaHermes-3B
Create configuration_mamba.py
Browse files- configuration_mamba.py +43 -0
configuration_mamba.py
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import math
|
| 2 |
+
from typing import Optional , Union
|
| 3 |
+
|
| 4 |
+
from transformers import PretrainedConfig
|
| 5 |
+
class MambaConfig(PretrainedConfig):
|
| 6 |
+
model_type = "mamba"
|
| 7 |
+
def __init__(
|
| 8 |
+
self,
|
| 9 |
+
vocab_size=50277,
|
| 10 |
+
d_state=16,
|
| 11 |
+
d_model=2560,
|
| 12 |
+
d_conv=4,
|
| 13 |
+
expand=2,
|
| 14 |
+
conv_bias=True,
|
| 15 |
+
bias=False,
|
| 16 |
+
n_layer=64,
|
| 17 |
+
dt_rank: Union[int, str] = "auto",
|
| 18 |
+
pad_vocab_size_multiple=8,
|
| 19 |
+
initializer_range=0.02,
|
| 20 |
+
**kwargs,
|
| 21 |
+
):
|
| 22 |
+
self.vocab_size = vocab_size
|
| 23 |
+
self.n_layer= n_layer
|
| 24 |
+
self.conv_bias = conv_bias
|
| 25 |
+
self.expand = expand
|
| 26 |
+
self.pad_vocab_size_multiple = pad_vocab_size_multiple
|
| 27 |
+
self.d_conv = d_conv
|
| 28 |
+
self.d_model = d_model
|
| 29 |
+
self.d_state = d_state
|
| 30 |
+
self.d_inner = int(self.expand * self.d_model)
|
| 31 |
+
self.dt_rank = dt_rank
|
| 32 |
+
self.initializer_range = initializer_range
|
| 33 |
+
self.bias = bias
|
| 34 |
+
|
| 35 |
+
if self.dt_rank == 'auto':
|
| 36 |
+
self.dt_rank = math.ceil(self.d_model / 16)
|
| 37 |
+
|
| 38 |
+
if self.vocab_size % self.pad_vocab_size_multiple != 0:
|
| 39 |
+
self.vocab_size += (self.pad_vocab_size_multiple
|
| 40 |
+
- self.vocab_size % self.pad_vocab_size_multiple)
|
| 41 |
+
super().__init__(
|
| 42 |
+
**kwargs,
|
| 43 |
+
)
|