Instructions to use thinkingmachines/Inkling-2-Mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use thinkingmachines/Inkling-2-Mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="thinkingmachines/Inkling-2-Mini") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("thinkingmachines/Inkling-2-Mini") model = AutoModelForMultimodalLM.from_pretrained("thinkingmachines/Inkling-2-Mini", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use thinkingmachines/Inkling-2-Mini with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "thinkingmachines/Inkling-2-Mini" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "thinkingmachines/Inkling-2-Mini", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/thinkingmachines/Inkling-2-Mini
- SGLang
How to use thinkingmachines/Inkling-2-Mini 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 "thinkingmachines/Inkling-2-Mini" \ --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": "thinkingmachines/Inkling-2-Mini", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "thinkingmachines/Inkling-2-Mini" \ --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": "thinkingmachines/Inkling-2-Mini", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use thinkingmachines/Inkling-2-Mini with Docker Model Runner:
docker model run hf.co/thinkingmachines/Inkling-2-Mini
How to run Inkling 2 Mini on a Mac: up to 128.8 tok/s on an M5 Max with MTPLX 2.13 (24 GB Macs and up)
I work with Youssof Al Toukhi, who writes MTPLX. He released 2.13 this morning and I'm posting the numbers here for him.
MTPLX 2.13 runs Inkling 2 Mini on Apple Silicon with the model's own draft head as a speculative decoder (rejection sampling with residual correction, so the output keeps the model's distribution at temperature 1.0) and Metal kernels written for it.
Measured on one MacBook Pro M5 Max with 128 GB, at the model's own sampler:
| Pack | Size | Peak decode | First token, new 4,142-token prompt |
|---|---|---|---|
| Bare Speed (4-bit) | 16.0 GB | 128.8 tok/s | 1.69 s |
| Optimized Speed (4-bit experts, 8-bit attention and head) | 17.2 GB | 123.8 tok/s | 1.73 s |
| Optimized Quality (these official weights, unchanged) | 20.2 GB | 103.8 tok/s | 1.84 s |
On the same Mac, prompt and sampler, decode is 1.6x oMLX 0.8.0 with its draft head and 2.8x plain mlx-lm. These are peak figures on a cool machine, and M1 to M4 Macs run a slower path. The conditions for each number are in the release notes: https://github.com/youssofal/MTPLX/releases/tag/v2.13.0
Every pack keeps the whole vision tower. Bare Speed fits a 24 GB Mac, all three fit from 32 GB, and there are FP16 builds for M1 and M2.
brew install youssofal/mtplx/mtplx
mtplx start
The app and mtplx start read your chip and memory and offer only the packs that fit. There is also a Mac app: https://mtplx.com/download
Open source, Apache 2.0: https://github.com/youssofal/MTPLX
Every number above is from one M5 Max. If you have an M5 Ultra, he would like to see yours.
Update: MTPLX 2.13.1 is out. 2.13.0 failed to load Inkling 2 Mini on an M1 Max with "Thread group size (800) is greater than the maximum allowed threads per threadgroup (704)", and a tester saw the same crash on an M2 Max. 2.13.1 fixes it. The packs did not change, so nothing needs downloading again. Update with brew update && brew upgrade mtplx or pip install -U mtplx. Release notes: https://github.com/youssofal/MTPLX/releases/tag/v2.13.1