Instructions to use ai21labs/AI21-Jamba-Reasoning-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ai21labs/AI21-Jamba-Reasoning-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ai21labs/AI21-Jamba-Reasoning-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ai21labs/AI21-Jamba-Reasoning-3B") model = AutoModelForCausalLM.from_pretrained("ai21labs/AI21-Jamba-Reasoning-3B", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ai21labs/AI21-Jamba-Reasoning-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ai21labs/AI21-Jamba-Reasoning-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ai21labs/AI21-Jamba-Reasoning-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ai21labs/AI21-Jamba-Reasoning-3B
- SGLang
How to use ai21labs/AI21-Jamba-Reasoning-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 "ai21labs/AI21-Jamba-Reasoning-3B" \ --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": "ai21labs/AI21-Jamba-Reasoning-3B", "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 "ai21labs/AI21-Jamba-Reasoning-3B" \ --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": "ai21labs/AI21-Jamba-Reasoning-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ai21labs/AI21-Jamba-Reasoning-3B with Docker Model Runner:
docker model run hf.co/ai21labs/AI21-Jamba-Reasoning-3B
MLX optimization
Hey thanks a lot for this dev effort - awesome to see models with new architectures performing this well!
I saw that you used a Mac in the benchmarks. Are you by chance interested in optimizing the model for MLX?
There is https://huggingface.co/mlx-community but jamba architecture is not yet supported. Would you be interested in contributing to https://github.com/ml-explore/mlx-lm?
I guess there could be significant speed-ups.
Personally I am currently processing large text dumps for a research prioject and looking for a model that is:
- small & fast
- with high quality outputs
- supporting long-contexts
- high batch throughput
- optimized for MLX
So far you model ticks most bullets for me me. If you optimized it for MLX, I could use batch generation easily (https://github.com/ml-explore/mlx-lm/blob/main/mlx_lm/examples/batch_generate_response.py).
Best
Dominik
Update: opened this issue in mlx-lm https://github.com/ml-explore/mlx-lm/issues/551
Awesome, thanks a lot!
the PR has been merged, the next MLX-LM release will support Jamba.