Instructions to use Q-bert/Mamba-370M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Q-bert/Mamba-370M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Q-bert/Mamba-370M", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Q-bert/Mamba-370M", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("Q-bert/Mamba-370M", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Q-bert/Mamba-370M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Q-bert/Mamba-370M" # 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/Mamba-370M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Q-bert/Mamba-370M
- SGLang
How to use Q-bert/Mamba-370M 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/Mamba-370M" \ --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/Mamba-370M", "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/Mamba-370M" \ --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/Mamba-370M", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Q-bert/Mamba-370M with Docker Model Runner:
docker model run hf.co/Q-bert/Mamba-370M
| import math | |
| from typing import Optional , Union | |
| from transformers import PretrainedConfig | |
| class MambaConfig(PretrainedConfig): | |
| model_type = "mamba" | |
| def __init__( | |
| self, | |
| vocab_size=50277, | |
| d_state=16, | |
| d_model=2560, | |
| d_conv=4, | |
| expand=2, | |
| conv_bias=True, | |
| bias=False, | |
| n_layer=64, | |
| dt_rank: Union[int, str] = "auto", | |
| pad_vocab_size_multiple=8, | |
| initializer_range=0.02, | |
| **kwargs, | |
| ): | |
| self.vocab_size = vocab_size | |
| self.n_layer= n_layer | |
| self.conv_bias = conv_bias | |
| self.expand = expand | |
| self.pad_vocab_size_multiple = pad_vocab_size_multiple | |
| self.d_conv = d_conv | |
| self.d_model = d_model | |
| self.d_state = d_state | |
| self.d_inner = int(self.expand * self.d_model) | |
| self.dt_rank = dt_rank | |
| self.initializer_range = initializer_range | |
| self.bias = bias | |
| if self.dt_rank == 'auto': | |
| self.dt_rank = math.ceil(self.d_model / 16) | |
| if self.vocab_size % self.pad_vocab_size_multiple != 0: | |
| self.vocab_size += (self.pad_vocab_size_multiple | |
| - self.vocab_size % self.pad_vocab_size_multiple) | |
| super().__init__( | |
| **kwargs, | |
| ) |