Instructions to use unsloth/Kimi-K2-Instruct-GGUF with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use unsloth/Kimi-K2-Instruct-GGUF with Transformers:
# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("unsloth/Kimi-K2-Instruct-GGUF", dtype="auto") - llama-cpp-python
How to use unsloth/Kimi-K2-Instruct-GGUF with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="unsloth/Kimi-K2-Instruct-GGUF", filename="BF16/Kimi-K2-Instruct-BF16-00001-of-00045.gguf", )
llm.create_chat_completion( messages = "No input example has been defined for this model task." )
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use unsloth/Kimi-K2-Instruct-GGUF with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: llama-cli -hf unsloth/Kimi-K2-Instruct-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-Instruct-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./llama-cli -hf unsloth/Kimi-K2-Instruct-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-Instruct-GGUF:UD-Q4_K_XL # Run inference directly in the terminal: ./build/bin/llama-cli -hf unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
Use Docker
docker model run hf.co/unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
- LM Studio
- Jan
- Ollama
How to use unsloth/Kimi-K2-Instruct-GGUF with Ollama:
ollama run hf.co/unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
- Unsloth Studio
How to use unsloth/Kimi-K2-Instruct-GGUF with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Kimi-K2-Instruct-GGUF to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for unsloth/Kimi-K2-Instruct-GGUF to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for unsloth/Kimi-K2-Instruct-GGUF to start chatting
- Pi
How to use unsloth/Kimi-K2-Instruct-GGUF with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/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-Instruct-GGUF:UD-Q4_K_XL" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use unsloth/Kimi-K2-Instruct-GGUF with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf unsloth/Kimi-K2-Instruct-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-Instruct-GGUF:UD-Q4_K_XL
Run Hermes
hermes
- Docker Model Runner
How to use unsloth/Kimi-K2-Instruct-GGUF with Docker Model Runner:
docker model run hf.co/unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
- Lemonade
How to use unsloth/Kimi-K2-Instruct-GGUF with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull unsloth/Kimi-K2-Instruct-GGUF:UD-Q4_K_XL
Run and chat with the model
lemonade run user.Kimi-K2-Instruct-GGUF-UD-Q4_K_XL
List all available models
lemonade list
Trouble running Q5_K_M With Llama.cpp
I pulled the latest llama.cpp repo and built it as I normally do with no problems. I downloaded Q5_K_M presumably with no errors but when I load llama-server I get an abort, without much helpful information. I tested my build with a different model and it loads fine. So then I assumed it was a failed model download so I redownloaded from scratch with huggingface-cli download and again that seemed to complete with no errors. Yet I get the same error with llama-server.
Can anyone confirm that llama.cpp can load this model?
@simusid oh so the latest llama.cpp doesn't yet have support for it - you'll have to use the limit or use https://github.com/unslothai/llama.cpp
I wrote details on how to do it in https://docs.unsloth.ai/basics/kimi-k2-how-to-run-locally
@danielhanchen . Thanks for that! I see your work on here and your comments on reddit and I want you to know it's appreciated.
Thank you @simusid :)
Hey all!
I'm also running into an issue running with llama.cpp. I downloaded the unslothai version of llama.cpp (and followed the tutorial steps):
git clone https://github.com/unslothai/llama.cpp
cmake llama.cpp -B llama.cpp/build
-DBUILD_SHARED_LIBS=OFF -DGGML_CUDA=OFF -DLLAMA_CURL=ON
cmake --build llama.cpp/build --config Release -j --clean-first --target llama-quantize llama-cli llama-gguf-split llama-mtmd-cli
cp llama.cpp/build/bin/llama-* llama.cpp
The only change I made was that I switched the CUDA to "OFF" as it gave an error (I am on a Mac, so perhaps not surprising).
When I try this command to launch Kimi-K2 (already locally available):
unslothai/llama.cpp/build/bin/llama-cli
--model unsloth/Kimi-K2-Instruct-GGUF/Kimi-K2-Instruct-UD-Q2_K_XL-00001-of-00008.gguf
--n-gpu-layers 16
--temp 0.6
--min_p 0.01
--ctx-size 16384
--cache-type-k q8_0
--seed 3407
-ot ".ffn_.*_exps.=CPU"
I get these errors:
gguf_init_from_file: failed to open GGUF file 'unsloth/Kimi-K2-Instruct-GGUF/Kimi-K2-Instruct-UD-Q2_K_XL-00001-of-00008.gguf'
llama_model_load: error loading model: llama_model_loader: failed to load model from unsloth/Kimi-K2-Instruct-GGUF/Kimi-K2-Instruct-UD-Q2_K_XL-00001-of-00008.gguf
llama_model_load_from_file_impl: failed to load model
common_init_from_params: failed to load model 'unsloth/Kimi-K2-Instruct-GGUF/Kimi-K2-Instruct-UD-Q2_K_XL-00001-of-00008.gguf'
main: error: unable to load model
It does not really try to load the model at all. Any thoughts or ideas? Thanks!
Edit
Nevermind - this was due to a simple pathing error to my external SSD directory. My apologies. I can CONFIRM that the unslothai llama.cpp fork as described above does attempt to load the model. I'm still waiting for it to load, but wanted to update my post.
Edit #2
I can confirm the model loads successfully following the unsloth guide above with command llama-cli.
I do wish I could start a server via llama-server, but I am guessing that is not supported just yet!
Thanks again for all you do, unsloth!!
I'm unable to help @x-polyglot-x but I can say that with the link from @danielhanchen I was completely successful and I'm running the giant Q5 model with no issues :O
Yes, my apologies. I also followed the link from @danielhanchen and got it working! My issue was a pathing issue to the model itself (DOH!).
That said, I will likely wait to adopt or use this model seriously for llama-server support. I want to ask it longer prompts and upload files (etc) and doing that via a chat in the terminal is a bit too cumbersome for me. But, all in all, I'm glad I can run it and have it now!!