Instructions to use MinimaLabs/KLM-1.6-Chat with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MinimaLabs/KLM-1.6-Chat with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="MinimaLabs/KLM-1.6-Chat", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("MinimaLabs/KLM-1.6-Chat", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use MinimaLabs/KLM-1.6-Chat with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "MinimaLabs/KLM-1.6-Chat" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "MinimaLabs/KLM-1.6-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/MinimaLabs/KLM-1.6-Chat
- SGLang
How to use MinimaLabs/KLM-1.6-Chat 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 "MinimaLabs/KLM-1.6-Chat" \ --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": "MinimaLabs/KLM-1.6-Chat", "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 "MinimaLabs/KLM-1.6-Chat" \ --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": "MinimaLabs/KLM-1.6-Chat", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use MinimaLabs/KLM-1.6-Chat with Docker Model Runner:
docker model run hf.co/MinimaLabs/KLM-1.6-Chat
KLM 1.6-Chat
We are releasing KLM 1.6-Chat, the chat model of the KLM 1.6 series, following the KLM 1.6 base. It is a 99M-parameter hybrid of Gated DeltaNet-2 and attention with tool calling and a 32K context window.
In the same league as models many times its size. Against chat models 2.3 to 17 times larger, it posts the best IFEval and Multi-IF scores in the comparison. You can try it in the browser on its Space.
Benchmarks
All models ran in the same harness, zero-shot and sampled at temperature 0.7 with top-p 0.9, except Qwen3.5-0.8B, whose scores come from its model card.
LFM2.5-230M is the one peer KLM 1.6-Chat doesn't catch on IFBench. On GSM8K and MMLU the bigger models pull away, which is about what you'd expect, since both of those reward stored knowledge and arithmetic more than following directions.
Each panel's axis starts at random-guess accuracy, which is zero for the generative tests and 25% for MMLU.
| Benchmark | KLM 1.6-Chat (99M) | LFM2.5-230M | Granite 4.0-H-350M | Qwen3.5-0.8B | SmolLM2-1.7B |
|---|---|---|---|---|---|
| IFEval (prompt strict) | 66.9 | 66.0 | 55.1 | 52.1 | 48.8 |
| IFBench (prompt loose) | 25.0 | 42.0 | 20.7 | 21.0 | 20.0 |
| Multi-IF (English, 3 turns) | 63.2 | 60.4 | 41.7 | — | 43.3 |
| GSM8K | 26.5 | 33.1 | 32.4 | — | 40.0 |
| MMLU | 27.7 | 38.0 | 27.1 | — | 47.3 |
Architecture
| Field | Value |
|---|---|
| Parameters | 98,975,308, of which 5,411,832 are the n-gram memory |
| Layers | 24, Gated DeltaNet-2 and attention at 3:1 |
| Hidden size | 512 |
| Gated DeltaNet-2 | 4 heads × 128 |
| Attention | 8 query heads, 4 KV heads, head size 64, YaRN RoPE, QK-norm, output gate |
| Residuals | Block Attention Residuals |
| N-gram memory | 125,000 bigrams and 38,000 trigrams, each with its own learned vector |
| Feed-forward | SwiGLU, hidden size 1,408 |
| Context length | 32,768 tokens |
| Vocabulary | 4,100 tokens, tied embeddings |
Post-training
- Long context. KLM 1.6's learning-rate decay was finished on 10B tokens of 32K sequences with YaRN, up from its 2K pretraining length.
- Supervised fine-tuning. About 45B tokens of English chat, instruction-following, tool-use, reasoning and long-conversation data, listed below.
- RL specialists. Six specialists, one per skill, each trained on its own replies with a code checker or a judge model as the reward.
- On-policy distillation. The fine-tuned model learned from all six on its own replies by matching each specialist's next-token distribution, with function calling anchored to the fine-tuned model.
- Identity pass. A short pass teaches the model its name and to keep any persona a system prompt sets.
Training data
The training data came from the following sources.
| Data | Sources |
|---|---|
| Chat | Nemotron IF-Chat v2 and v3, SmolTalk2 Magpie-Ultra, system chats, everyday conversations and multi-turn instruction following, UltraChat 200k, our own chat conversations |
| Instruction following | Nemotron IF-Chat v3, UltraData-SFT, SmolTalk2 Tulu 3 personas, OpenHermes 2.5, rewriting, summarizing, explore-instruct and Table-GPT |
| Tool use and agents | Nemotron Agentic v4, UltraData-SFT-Agent tool use, general, search and code agents, SmolTalk2 xLAM, Hermes function calling and smolagents traces, our own tool-use conversations |
| Maths, code and reasoning | UltraData-SFT maths, code and knowledge, Nemotron Math v4, SmolTalk2 OpenThoughts3, s1K and Mixture-of-Thoughts science |
| Long inputs | Nemotron Long-Context Transduction, Nemotron BBQ, SmolTalk2 LongAlign, LongAlign-10k |
| Pretraining replay | A small share of KLM 1.6's pretraining data |
What RL added
Doom loops
Small models are prone to doom loops, where a reply repeats one passage until it runs out of tokens. After fine-tuning, 13% of KLM 1.6-Chat's replies to loop-prone prompts fell into one.
Our first attempt was Liquid AI's final-token preference optimization, which trains against the exact token where a loop starts. It brought loops down to 0.5%, but it also broke function calling, with BFCL AST falling from 35.9 to 9.8. At 99M parameters the model seemed to learn not to copy from its context at all, so we dropped it.
RL did the job instead. Each specialist scored a looped or unfinished reply as zero, and when the specialists were merged back into one model, any reply that repeated the same span eight times was cut right there, so the correction landed where the loop began.
Long context
KLM 1.6 itself reads 2,048 tokens. Getting a 99M model to make real use of 32K took three steps.
- The long-context stage gave the model 10B tokens of practice at 32K before any chat training.
- Supervised fine-tuning kept every sample whole up to 32K tokens, including long multi-turn conversations.
- The long-context RL specialist trained on tasks we built in code. It answered questions over 4K to 28K tokens of documents with the answer hidden at a random depth, followed chains of keys scattered through the documents, and walked generated graphs. None of it uses RULER data, so RULER stays a clean test.
Examples
These are unedited replies from the released weights, sampled at temperature 0.7 and top-p 0.9.
Tool use (calculator, reasoning on)
User:
What is 48,213 multiplied by 917? Use the calculator.
Assistant:
<think>
The user wants 48,213 × 917. I'll use the calculator to be precise.
</think>
<tool_call>{"name": "calculator", "arguments": {"expression": "48213*917"}}</tool_call>
Tool:
44211321
Assistant:
<think>
The calculator returned 44,211,321. That's 48,213 × 917, so state the multiplication briefly.
</think>
Multiplying 48,213 by 917:
48,213 × 917 = 44,211,321
The answer is 44,211,321.
Math reasoning (reasoning on)
User:
Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?
Assistant:
<think>
We are given: "Natalia sold clips to 48 of her friends in April, and then she sold half as many clips in May. How many clips did Natalia sell altogether in April and May?"
Interpretation: In April, she sold 48 clips. Then she sold half as many clips in May, so half of 48 is 24. So total clips sold: 48 + 24 = 72.
Answer: 72.
Check: 48 in April, half in May = 24, total = 72.
So answer: 72.
</think>
Natalia sold 48 clips in April. She sold half as many in May, which is \( \frac{48}{2} = 24 \) clips.
The total clips sold is \( 48 + 24 = 72 \).
Thus, Natalia sold 72 clips altogether.
Strict instruction following (reasoning on and off)
User (reasoning on):
List exactly three benefits of regular exercise as a numbered list. Each item must be under 10 words.
Assistant:
<think>
Okay, the user wants me to list exactly three benefits of regular exercise as a numbered list, each under 10 words. Let me start by recalling the key benefits of exercise. Common ones include physical health, mental well-being, and better sleep. I need to make sure each point is concise and under the word limit.
First point could be physical health. That's a solid one. Second, mental well-being might be another. Third, sleep quality could be important too. Wait, need exactly three, no more, no less. Let me check the word count to ensure each is under 10. Also, avoid any markdown formatting as specified. Just a straight list. Alright, that should work.
</think>
1. Improves cardiovascular health and strengthens muscles
2. Enhances mental clarity and reduces stress
3. Boosts sleep quality and increases energy levels
User (reasoning off):
Give me a JSON object describing a fictional person with the keys name, age and city. Output only the JSON, nothing else.
Assistant:
{
"name": "Lena Chen",
"age": 28,
"city": "Seoul"
}
Python coding (reasoning off)
User:
Write a Python function that checks whether a string is a palindrome, ignoring case and spaces.
Assistant:
```python
def is_palindrome(s):
"""
Checks if a string is a palindrome ignoring case and spaces.
"""
cleaned = ''.join(c.lower() for c in s if c.isalnum())
return cleaned == cleaned[::-1]
```
Usage
KLM 1.6-Chat is plain PyTorch, so it runs on a CPU or any GPU with only Transformers installed. Reasoning is on by default, and enable_thinking=False in the chat template turns it off for a request.
A few things help in practice.
- Leave tools out for pure reasoning. When tools are declared the model reasons much less, often a line or two, even if the question never needs a tool. Drop the tool definitions for maths, logic and other hard reasoning.
- Keep reasoning on for multi-step tasks. Reasoning off gives tighter replies on simple prompts, but maths with reasoning off sometimes never reaches an answer.
- Name the real tools after a bad call. If the model calls a tool that doesn't exist, return a
toolmessage with an error that lists the available tools, and it will usually recover.
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "MinimaLabs/KLM-1.6-Chat"
device = "cuda" if torch.cuda.is_available() else "cpu"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_id, trust_remote_code=True).to(device)
messages = [{"role": "user", "content": "Explain why the sky looks blue in two sentences."}]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, enable_thinking=True,
return_tensors="pt", return_dict=True).to(device)
outputs = model.generate(**inputs, max_new_tokens=1024)
reply = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
reasoning, _, answer = reply.removesuffix("<|im_end|>").rpartition("</think>")
print(answer.strip())
On an NVIDIA GPU, fast_generate decodes many conversations at once with fused Triton kernels and CUDA graphs. Triton comes with PyTorch's CUDA builds on Linux. Each slot keeps room for a full 32K context, about 200 MB in bf16, so lower slots (16 by default) on a small GPU.
questions = ["Who are you?", "Write a haiku about rain."]
prompts = [tokenizer.apply_chat_template([{"role": "user", "content": q}], add_generation_prompt=True,
return_dict=True)["input_ids"]
for q in questions]
for reply in model.fast_generate(prompts, max_new_tokens=1024):
print(tokenizer.decode(reply, skip_special_tokens=False).removesuffix("<|im_end|>").rpartition("</think>")[2].strip())
For tool use, pass the tools to the chat template with flat string parameters, parse the <tool_call> blocks that come after </think>, and send each result back as a tool message. The model was trained with web_search, read_web_page, current_time and get_weather, and it accepts custom tools written in the same schema.
import json
import re
TOOLS = [
{
"name": "web_search",
"description": "Search the web. Returns up to 5 results, each with a title, a URL and a snippet.",
"parameters": {"query": "what to search for"},
},
{
"name": "read_web_page",
"description": "Read a web page and return its text. Use it on a search result's URL to see the whole page. A long page comes in parts.",
"parameters": {
"url": "the page's full URL, starting with http:// or https://",
"page": "which part of a long page to read: 1 (the default), 2, 3, ...",
},
},
{
"name": "current_time",
"description": "Get the current date and time.",
"parameters": {"timezone": "IANA time zone such as Asia/Kolkata; UTC when omitted"},
},
{
"name": "get_weather",
"description": "Get the current weather and a three-day forecast for a place.",
"parameters": {"location": "a city or place name"},
},
]
TOOL_CALL_RE = re.compile(r"<tool_call>\s*(\{.*?\})\s*</tool_call>", re.S)
def parse_tool_calls(reply):
answer = reply.split("</think>", 1)[1] if "</think>" in reply else reply
calls = []
for raw in TOOL_CALL_RE.findall(answer):
try:
call = json.loads(raw)
except json.JSONDecodeError:
continue
if isinstance(call, dict) and isinstance(call.get("name"), str) and isinstance(call.get("arguments", {}), dict):
calls.append({"name": call["name"], "arguments": call.get("arguments", {})})
return calls
messages = [{"role": "user", "content": "What's the weather in Pune right now?"}]
inputs = tokenizer.apply_chat_template(messages, tools=TOOLS, add_generation_prompt=True,
return_tensors="pt", return_dict=True).to(device)
outputs = model.generate(**inputs, max_new_tokens=1024)
reply = "<think>\n" + tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=False)
reply = reply.removesuffix("<|im_end|>")
print(parse_tool_calls(reply))
# Run each call, then continue the conversation with
# messages += [{"role": "assistant", "content": reply}, {"role": "tool", "content": result}]
Limitations
- At 99M parameters the model knows little about the world, and it often states wrong facts with confidence when answering from memory.
- It only works in English.
- Ambiguous maths problems and reasoning traps can still send it in circles until the token limit, and with reasoning off about one in eight GSM8K answers never reaches a final number.
- Its memory of earlier turns fades in long chats, and tool summaries sometimes misformat numbers, attach the wrong time-zone label or blend figures from different search results.
- Its safety behaviour comes only from general chat data, so add your own filtering before putting it in front of users.
License
KLM 1.6-Chat is released under the Apache-2.0 license, which you can find in LICENSE.
- Downloads last month
- -
Model tree for MinimaLabs/KLM-1.6-Chat
Base model
MinimaLabs/KLM-1.6