Text Generation
Transformers
Safetensors
English
klm
custom_code
small-language-model
chat
conversational
reasoning
tool-use
hybrid
gated-deltanet
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
Download tokenizer_config.json from MinimaLabs/KLM-1.6-Chat: direct link, hf CLI and curl.
- Browser
- Download file 2.16 kB
-
https://huggingface.co/MinimaLabs/KLM-1.6-Chat/resolve/main/tokenizer_config.json
- Command line
-
hf download hf://MinimaLabs/KLM-1.6-Chat/tokenizer_config.json
-
curl -L -o tokenizer_config.json https://huggingface.co/MinimaLabs/KLM-1.6-Chat/resolve/main/tokenizer_config.json
2.16 kB
| { | |
| "tokenizer_class": "PreTrainedTokenizerFast", | |
| "model_max_length": 32768, | |
| "pad_token": "<pad>", | |
| "bos_token": "<bos>", | |
| "eos_token": "<eos>", | |
| "additional_special_tokens": [ | |
| "<|im_start|>", | |
| "<|im_end|>", | |
| "<think>", | |
| "</think>" | |
| ], | |
| "add_bos_token": false, | |
| "add_eos_token": false, | |
| "clean_up_tokenization_spaces": false, | |
| "model_input_names": [ | |
| "input_ids", | |
| "attention_mask" | |
| ], | |
| "chat_template": "{%- set think = enable_thinking if enable_thinking is defined else true -%}\n{%- set ns = namespace(system='', last_user=-1) -%}\n{%- if messages and messages[0]['role'] == 'system' -%}\n {%- set ns.system = messages[0]['content'] -%}\n {%- set rest = messages[1:] -%}\n{%- else -%}\n {%- set rest = messages -%}\n{%- endif -%}\n{%- if tools -%}\n {%- set lines = namespace(text='You can use these tools:') -%}\n {%- for tool in tools -%}\n {%- set lines.text = lines.text + '\\n' + ((tool['function'] if tool['function'] is defined else tool) | tojson) -%}\n {%- endfor -%}\n {%- set lines.text = lines.text + '\\n\\nTo use one, write <tool_call>{\"name\": \"<tool name>\", \"arguments\": {...}}</tool_call> and stop. The result comes back in a tool message.' -%}\n {%- set ns.system = (ns.system + '\\n\\n' + lines.text) if ns.system else lines.text -%}\n{%- endif -%}\n{%- set flag = '/think' if think else '/no_think' -%}\n{%- set ns.system = (ns.system.rstrip() + '\\n\\n' + flag) if ns.system else flag -%}\n{{- '<|im_start|>system\\n' + ns.system + '<|im_end|>\\n' -}}\n{%- for m in rest -%}\n {%- if m['role'] == 'user' -%}{%- set ns.last_user = loop.index0 -%}{%- endif -%}\n{%- endfor -%}\n{%- for m in rest -%}\n {%- set content = m['content'] -%}\n {%- if m['role'] == 'assistant' and loop.index0 < ns.last_user and content.startswith('<think>') and '</think>' in content -%}\n {%- set content = content.split('</think>', 1)[1] | trim -%}\n {%- endif -%}\n {{- '<|im_start|>' + m['role'] + '\\n' + content + '<|im_end|>\\n' -}}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{- '<|im_start|>assistant\\n' + ('<think>\\n' if think else '<think>\\n\\n</think>\\n\\n') -}}\n{%- endif -%}" | |
| } | |