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
Increasing num_experts_per_tok at inference time, is this supported?
Hi,
I'm interested in experimenting with the MoE routing configuration of Inkling 2 Mini.
The current configuration uses:
n_routed_experts = 128
num_experts_per_tok = 8
route_scale = 8.0
I'd like to investigate whether increasing the number of routed experts per token from 8 to 9 or even 10 could improve coding, reasoning and agentic task performance without modifying the original expert weights or performing additional training.
A few questions:
Is num_experts_per_tok intended to be configurable at inference time, or is the value of 8 fundamentally tied to the training process?
Would changing it to 9 or 10 in the model configuration be sufficient, or would modifications to the router or expert dispatch implementation be required?
How should route_scale and expert weight normalization be adjusted when increasing top-k?
Does the routing mechanism support this change across all three loop passes?
Have you experimented with higher top-k values internally? Are there any known quality or performance results?
My goal is to explore whether additional expert computation can improve model quality while keeping the original checkpoint weights unchanged.
Thanks for any technical insights!
Yes — in the transformers implementation this is a config change, not a code change, and the normalization takes care of itself.
The router (Inkling2LoopTopKRouter in modeling_inkling2_loop.py) reads the value once when the model is built: self.top_k = config.num_experts_per_tok, then selects with torch.topk over the router scores plus the correction bias. The same router class serves every layer, so setting num_experts_per_tok to 9 or 10 in the text_config of config.json before loading changes all of them together, loop passes included. One catch from the same code: since the value is read in the router's init, editing the config after the model has loaded won't take effect — it has to be set before construction.
On route_scale and normalization, nothing needs adjusting by hand. The selected experts' scores are renormalized over just the selected set (divided by their sum), then multiplied by route_scale (8.0 here). So at k=9 or 10 the mixture's total scale stays exactly where it was at k=8; each expert's individual share simply gets smaller. Raising route_scale to compensate would change the output magnitude instead — the shipped normalization is already the conservative choice.
What the code can't tell you is whether it helps. The router and its correction bias were trained at k=8, so the 9th- and 10th-ranked experts get admitted in combinations training never used, and expert compute per token rises by roughly a ninth per added expert. A clean first check: fix a small prompt set, run k=8, 9, and 10 with identical seeds and sampling settings, and compare the outputs side by side before trusting any benchmark delta.
The config values above are from this repo's config.json as served today (128 routed experts, k=8, route_scale 8.0). Hope it saves you some spelunking — curious what you find at 9 and 10.