Instructions to use moonshotai/Kimi-Linear-48B-A3B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-Linear-48B-A3B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="moonshotai/Kimi-Linear-48B-A3B-Instruct", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("moonshotai/Kimi-Linear-48B-A3B-Instruct", trust_remote_code=True, dtype="auto") - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moonshotai/Kimi-Linear-48B-A3B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonshotai/Kimi-Linear-48B-A3B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "moonshotai/Kimi-Linear-48B-A3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/moonshotai/Kimi-Linear-48B-A3B-Instruct
- SGLang
How to use moonshotai/Kimi-Linear-48B-A3B-Instruct 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 "moonshotai/Kimi-Linear-48B-A3B-Instruct" \ --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": "moonshotai/Kimi-Linear-48B-A3B-Instruct", "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 "moonshotai/Kimi-Linear-48B-A3B-Instruct" \ --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": "moonshotai/Kimi-Linear-48B-A3B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use moonshotai/Kimi-Linear-48B-A3B-Instruct with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-Linear-48B-A3B-Instruct
No space to test it, not on open router, are there obstacles ?
Just wondering if the model is possibly having issues or performing horrible ?
I wanted to test it but it's not supported on llama.cpp, is not on openrouter and doesn't have a single space on HF.
- It's a bit too recent, released mere days ago
- More of an architecture demonstrator than a model meant for production use (though it might make a great base for FT)
- Requires VLLM nightly, and the VLLM implementation was broken on release day (and AFAIK still broken to this day)
I think it should be a little better once VLLM releases next (should be any day now!)
There is a related fix PR: https://github.com/vllm-project/vllm/pull/27905
Documentation here: https://docs.vllm.ai/projects/recipes/en/latest/moonshotai/Kimi-Linear.html#4-gpu-tensor-parallel
And I have tested latest commit: https://github.com/vllm-project/vllm/commit/1bf43ae35d7f6a83cc2025b8c0a2332456f4afe9
| Tasks |Version| Filter |n-shot| Metric | |Value | |Stderr|
|-----------------|------:|----------------|-----:|-----------|---|-----:|---|-----:|
|gsm8k_opencompass| 3|flexible-extract| 0|exact_match|↑ |0.9075|± | 0.008|