Instructions to use AirlockRIck/Jamba-v0.1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AirlockRIck/Jamba-v0.1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AirlockRIck/Jamba-v0.1", trust_remote_code=True)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("AirlockRIck/Jamba-v0.1", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("AirlockRIck/Jamba-v0.1", trust_remote_code=True) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use AirlockRIck/Jamba-v0.1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AirlockRIck/Jamba-v0.1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AirlockRIck/Jamba-v0.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/AirlockRIck/Jamba-v0.1
- SGLang
How to use AirlockRIck/Jamba-v0.1 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 "AirlockRIck/Jamba-v0.1" \ --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": "AirlockRIck/Jamba-v0.1", "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 "AirlockRIck/Jamba-v0.1" \ --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": "AirlockRIck/Jamba-v0.1", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use AirlockRIck/Jamba-v0.1 with Docker Model Runner:
docker model run hf.co/AirlockRIck/Jamba-v0.1
File size: 3,901 Bytes
49fe93b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | """HF Inference Endpoint custom handler for ai21labs/Jamba-v0.1.
Deploys hybrid SSM-Transformer MoE base model via the HF Endpoints custom-handler
interface. Jamba requires trust_remote_code=True and the mamba-ssm + causal-conv1d
dependencies. 52B total / 12B active parameters; needs A100 80GB minimum.
Input schema (Bench 1.6-A concatenated completion format):
{
"inputs": "<flat text prompt with system + user turns concatenated>",
"parameters": {
"max_new_tokens": 512,
"temperature": 0.7,
"top_p": 0.95,
"do_sample": true,
}
}
Output schema:
{
"generated_text": "<model completion>",
"input_tokens": <int>,
"output_tokens": <int>,
"model": "ai21labs/Jamba-v0.1"
}
Preregistered per docs/BENCH-1.6A-PREREG.md §5.5 (base-model asymmetry):
Base Jamba receives completion-format prompts, NOT chat-template formatted
messages. The caller (scripts/nsi_bench_hf.py) is responsible for
concatenating the Bench 1 [system, user_1, assistant_1, user_2, ...]
structure into the flat text the base model expects.
"""
from __future__ import annotations
from typing import Any
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL_ID = "ai21labs/Jamba-v0.1"
class EndpointHandler:
"""HF Endpoints custom handler entry point.
HF Endpoints constructs this class once at boot and calls __call__ per
request. The class name MUST be EndpointHandler.
"""
def __init__(self, path: str = "") -> None:
self.model_id = MODEL_ID
self.device = "cuda" if torch.cuda.is_available() else "cpu"
self.tokenizer = AutoTokenizer.from_pretrained(
self.model_id,
trust_remote_code=True,
)
# BF16 with device_map=auto for A100 80GB. Per ai21labs model card,
# this fits the model in a single 80GB GPU at BF16.
self.model = AutoModelForCausalLM.from_pretrained(
self.model_id,
trust_remote_code=True,
torch_dtype=torch.bfloat16,
device_map="auto",
)
self.model.eval()
def __call__(self, data: dict[str, Any]) -> dict[str, Any]:
prompt: str = data.get("inputs", "")
params: dict[str, Any] = data.get("parameters", {}) or {}
max_new_tokens: int = int(params.get("max_new_tokens", 512))
temperature: float = float(params.get("temperature", 0.7))
top_p: float = float(params.get("top_p", 0.95))
do_sample: bool = bool(params.get("do_sample", True))
if not prompt:
return {
"generated_text": "",
"input_tokens": 0,
"output_tokens": 0,
"model": self.model_id,
"error": "empty_input",
}
inputs = self.tokenizer(prompt, return_tensors="pt").to(self.model.device)
input_tokens = int(inputs["input_ids"].shape[-1])
with torch.no_grad():
outputs = self.model.generate(
**inputs,
max_new_tokens=max_new_tokens,
temperature=temperature if do_sample else 1.0,
top_p=top_p,
do_sample=do_sample,
pad_token_id=self.tokenizer.eos_token_id
if self.tokenizer.pad_token_id is None
else self.tokenizer.pad_token_id,
)
full_text = self.tokenizer.decode(
outputs[0],
skip_special_tokens=True,
)
generated_only = full_text[len(prompt):] if full_text.startswith(prompt) else full_text
output_tokens = int(outputs.shape[-1]) - input_tokens
return {
"generated_text": generated_only,
"input_tokens": input_tokens,
"output_tokens": output_tokens,
"model": self.model_id,
}
|