Instructions to use moonshotai/Kimi-K2.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-K2.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moonshotai/Kimi-K2.5", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("moonshotai/Kimi-K2.5", trust_remote_code=True) model = AutoModel.from_pretrained("moonshotai/Kimi-K2.5", trust_remote_code=True) messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moonshotai/Kimi-K2.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonshotai/Kimi-K2.5" # 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-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/moonshotai/Kimi-K2.5
- SGLang
How to use moonshotai/Kimi-K2.5 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-K2.5" \ --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-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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-K2.5" \ --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-K2.5", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use moonshotai/Kimi-K2.5 with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-K2.5
AttributeError: 'CompressedLinear' object has no attribute 'weight'
When I try to load model with transformers
Traceback (most recent call last):
File "/home/ccc/nas/try_kimi-with-transformers/V2/load.py", line 415, in
main()
File "/home/ccc/nas/try_kimi-with-transformers/V2/load.py", line 403, in main
result = compute_refusal_directions(config)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/ccc/nas/try_kimi-with-transformers/V2/load.py", line 66, in compute_refusal_directions
model = AutoModelForCausalLM.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/models/auto/auto_factory.py", line 365, in from_pretrained
return model_class.from_pretrained(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4110, in from_pretrained
load_info = cls._finalize_load_state_dict(model, load_config, load_info)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4274, in _finalize_load_state_dict
model._initialize_missing_keys(load_config.is_quantized)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 4550, in _initialize_missing_keys
self.initialize_weights()
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 124, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2373, in initialize_weights
self.smart_apply(self._initialize_weights)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2364, in smart_apply
module.smart_apply(module._initialize_weights)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2364, in smart_apply
module.smart_apply(module._initialize_weights)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2366, in smart_apply
module.smart_apply(fn)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2366, in smart_apply
module.smart_apply(fn)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2366, in smart_apply
module.smart_apply(fn)
[Previous line repeated 3 more times]
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2367, in smart_apply
fn(self)
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/transformers/modeling_utils.py", line 2344, in _initialize_weights
self._init_weights(module)
File "/root/.cache/huggingface/modules/transformers_modules/moonshotai/Kimi_hyphen_K2_dot_5/c415995b2384f8927990eaf8454c8a0e0f3f2549/modeling_deepseek.py", line 1248, in init_weights
module.weight.data.normal(mean=0.0, std=std)
^^^^^^^^^^^^^
File "/root/miniconda3/envs/try_kimi/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1965, in getattr
raise AttributeError(
AttributeError: 'CompressedLinear' object has no attribute 'weight'
Same issue