Instructions to use unsloth/Kimi-K2-Thinking-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Kimi-K2-Thinking-GGUF with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("unsloth/Kimi-K2-Thinking-GGUF", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use unsloth/Kimi-K2-Thinking-GGUF with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama cli -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./llama-cli -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Use Docker
docker model run hf.co/unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
- LM Studio
- Jan
- Ollama
How to use unsloth/Kimi-K2-Thinking-GGUF with Ollama:
ollama run hf.co/unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
- Unsloth Desktop
- Pi
How to use unsloth/Kimi-K2-Thinking-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Configure the model in Pi
# Install Pi: npm install -g @earendil-works/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Docker Model Runner
How to use unsloth/Kimi-K2-Thinking-GGUF with Docker Model Runner:
docker model run hf.co/unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
- Lemonade
How to use unsloth/Kimi-K2-Thinking-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Run and chat with the model
lemonade run user.Kimi-K2-Thinking-GGUF-UD-Q4_K_XL
List all available models
lemonade list
- Hermes Agent
How to use unsloth/Kimi-K2-Thinking-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Run Hermes
hermes
- Atomic Chat
- OpenClaw
How to use unsloth/Kimi-K2-Thinking-GGUF with OpenClaw:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama serve -hf unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL
Configure OpenClaw
# Install OpenClaw: npm install -g openclaw@latest # Register the local server and set it as the default model: openclaw onboard --non-interactive --mode local \ --auth-choice custom-api-key \ --custom-base-url http://127.0.0.1:8080/v1 \ --custom-model-id "unsloth/Kimi-K2-Thinking-GGUF:UD-Q4_K_XL" \ --custom-provider-id llama-cpp \ --custom-compatibility openai \ --custom-text-input \ --accept-risk \ --skip-health
Run OpenClaw
openclaw agent --local --agent main --message "Hello from Hugging Face"
Chat template fixes + FAQ
Hey everyone! We worked with the Kimi K2 team to fix the default system prompt of You are Kimi, an AI assistant created by Moonshot AI. not appearing in the first turn! See https://huggingface.co/moonshotai/Kimi-K2-Thinking/discussions/12 for more details.
All GGUFs, imatrix calibrated GGUFs and uploads are all updated with these fixes.
You may notice that there are no thinking tags when you run the model. This is normal and intended behavior. To enable it you will need to add --special.
Don't forget to read our guide for more details: https://docs.unsloth.ai/models/kimi-k2-thinking-how-to-run-locally
Would you know why i get this "< | im_end | >" at the end of the message? Apart from that everything works perfectly.
Today at 5:05 PM
Thought for 14 seconds
Hi! How can I help you today?<|im_end|>
Have you been able to evaluate drop off in accuracy for the Q2 UD ? Or whichever?
Would you know why i get this "< | im_end | >" at the end of the message? Apart from that everything works perfectly.
Today at 5:05 PM
Thought for 14 seconds
Hi! How can I help you today?<|im_end|>
Hello we wrote more info in our guide: https://docs.unsloth.ai/models/kimi-k2-thinking-how-to-run-locally#no-thinking-tags
Would you know why i get this "< | im_end | >" at the end of the message? Apart from that everything works perfectly.
Today at 5:05 PM
Thought for 14 seconds
Hi! How can I help you today?<|im_end|>Hello we wrote more info in our guide: https://docs.unsloth.ai/models/kimi-k2-thinking-how-to-run-locally#no-thinking-tags
You could create a page for some basic knowledge about LLM in general, like how tokenizer and chat template works.
You can remove the artifacts using the chat template.
i was able to fix this, here is the complete command for anyone else looking for the solution:
CUDA_DEVICE_ORDER=PCI_BUS_ID CUDA_VISIBLE_DEVICES="0,1" ./build/bin/llama-server \
--model /media/data/models/unsloth/Kimi-K2-Thinking-GGUF/UD-Q2_K_XL/Kimi-K2-Thinking-UD-Q2_K_XL-00001-of-00008.gguf \
--alias unsloth/Kimi-K2-Thinking \
--ctx-size 262144 \
-fa on \
-b 4096 -ub 4096 \
-ngl 99 \
-ot exps=CPU \
--special \
--no-warmup \
--parallel 1 \
--temp 1.0 \
--min-p 0.01 \
--jinja \
--threads 56 \
--threads-batch 56 \
--host 0.0.0.0 \
--port 10002 \
--reverse-prompt "<|im_end|>"