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
- HuggingChat
- 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
Inkling 2 Mini on a 16 GB MacBook with Memory-Sparse MoE (MS-MoE): about 2x more memory-efficient
Hi Thinking Machines team, and thank you for releasing Inkling 2 Mini.
While running it, I noticed that all the experts have to be in memory, even though only a small subset is used at any time. So I tried Memory-Sparse MoE (MS-MoE): a small prediction model picks the experts a question needs, and only those are loaded.
It's about 2x more memory-efficient (17.3 GB → 9 GB), which made it possible to run the model on my 16 GB MacBook at about 10 tokens per second.
The model does need a little fine-tuning to reach similar performance this way, but not much: a few hours for the router and a small attention LoRA, with the expert weights unchanged.
| Test | Full model | MS-MoE (ours) | REAP pruning |
|---|---|---|---|
| MBPP | 91.4% | 89.1% | 35.0% |
| GSM8K | 95.4% | 94.8% | 89.0% |
| MMLU | 78.0% | 76.0% | 53.9% |
- Files and code: https://huggingface.co/Sadanie/Inkling-2-Mini-Half
- Write-up: https://medium.com/@rotteveeladan/mixture-of-experts-models-are-built-wrong-for-laptops-and-local-hardware-9a45165d65d6
I was wondering if you think it would make sense to train models like this from the start? I'd love to hear what you think, and thanks again for making the model open.
There are solutions that can stream experts from an SSD drive, predicting which experts would be needed ahead of time. E.g. see the openbmb/MiniCPM-V-4.7-35B-A3B model or the https://github.com/ggml-org/llama.cpp/discussions/27149 discussion.
Thanks for the pointers! The main difference: those approaches keep the model's normal routing and fetch whatever the router picks from the SSD during generation. MS-MoE fine-tunes the model to work with a fixed subset of experts, chosen once per query, so nothing is read from disk while it answers. On a 16 GB M1 that runs at about 10 tokens per second, while the streaming prototype in that llama.cpp thread reports 2 to 4.5 tokens per second on the same machine. The two can be combined, using streaming only for the rare expert outside the subset.