Image-Text-to-Text
Transformers
Safetensors
kimi_k25
feature-extraction
compressed-tensors
conversational
custom_code
Eval Results
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, device_map="auto") 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
Fix grammar and punctuation errors in README.md (#12)
Browse files- Fix grammar and punctuation errors in README.md (58556c39bc3ac04f8b8a9f2b50099e6bc5a99a10)
Co-authored-by: Suqin Zhang <TomGrc@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -529,7 +529,7 @@ Kimi-K2.5 adopts the same native int4 quantization method as [Kimi-K2-Thinking](
|
|
| 529 |
|
| 530 |
## 5. Deployment
|
| 531 |
> [!Note]
|
| 532 |
-
> You can access Kimi-K2.5's API on https://platform.moonshot.ai
|
| 533 |
Currently, Kimi-K2.5 is recommended to run on the following inference engines:
|
| 534 |
* vLLM
|
| 535 |
* SGLang
|
|
@@ -545,13 +545,13 @@ Deployment examples can be found in the [Model Deployment Guide](docs/deploy_gui
|
|
| 545 |
|
| 546 |
The usage demos below demonstrate how to call our official API.
|
| 547 |
|
| 548 |
-
For third-party
|
| 549 |
> [!Note]
|
| 550 |
-
> - Chat with video content is an experimental feature and is only supported in our official API for now
|
| 551 |
>
|
| 552 |
> - The recommended `temperature` will be `1.0` for Thinking mode and `0.6` for Instant mode.
|
| 553 |
>
|
| 554 |
-
> - The recommended `top_p` is `0.95`
|
| 555 |
>
|
| 556 |
> - To use instant mode, you need to pass `{'chat_template_kwargs': {"thinking": False}}` in `extra_body`.
|
| 557 |
|
|
@@ -576,9 +576,9 @@ def simple_chat(client: openai.OpenAI, model_name: str):
|
|
| 576 |
response = client.chat.completions.create(
|
| 577 |
model=model_name, messages=messages, stream=False, max_tokens=4096
|
| 578 |
)
|
| 579 |
-
print('===== Below is reasoning_content in Thinking Mode ======')
|
| 580 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 581 |
-
print('===== Below is response in Thinking Mode ======')
|
| 582 |
print(f'response: {response.choices[0].message.content}')
|
| 583 |
|
| 584 |
# To use instant mode, pass {"thinking" = {"type":"disabled"}}
|
|
@@ -590,7 +590,7 @@ def simple_chat(client: openai.OpenAI, model_name: str):
|
|
| 590 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 591 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 592 |
)
|
| 593 |
-
print('===== Below is response in Instant Mode ======')
|
| 594 |
print(f'response: {response.choices[0].message.content}')
|
| 595 |
```
|
| 596 |
|
|
@@ -625,12 +625,12 @@ def chat_with_image(client: openai.OpenAI, model_name: str):
|
|
| 625 |
response = client.chat.completions.create(
|
| 626 |
model=model_name, messages=messages, stream=False, max_tokens=8192
|
| 627 |
)
|
| 628 |
-
print('===== Below is reasoning_content in Thinking Mode ======')
|
| 629 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 630 |
-
print('===== Below is response in Thinking Mode ======')
|
| 631 |
print(f'response: {response.choices[0].message.content}')
|
| 632 |
|
| 633 |
-
# Also support instant mode if pass {"thinking" = {"type":"disabled"}}
|
| 634 |
response = client.chat.completions.create(
|
| 635 |
model=model_name,
|
| 636 |
messages=messages,
|
|
@@ -639,7 +639,7 @@ def chat_with_image(client: openai.OpenAI, model_name: str):
|
|
| 639 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 640 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 641 |
)
|
| 642 |
-
print('===== Below is response in Instant Mode ======')
|
| 643 |
print(f'response: {response.choices[0].message.content}')
|
| 644 |
|
| 645 |
return response.choices[0].message.content
|
|
@@ -669,9 +669,9 @@ def chat_with_video(client: openai.OpenAI, model_name:str):
|
|
| 669 |
]
|
| 670 |
|
| 671 |
response = client.chat.completions.create(model=model_name, messages=messages)
|
| 672 |
-
print('===== Below is reasoning_content in Thinking Mode ======')
|
| 673 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 674 |
-
print('===== Below is response in Thinking Mode ======')
|
| 675 |
print(f'response: {response.choices[0].message.content}')
|
| 676 |
|
| 677 |
# Also support instant mode if pass {"thinking" = {"type":"disabled"}}
|
|
@@ -683,7 +683,7 @@ def chat_with_video(client: openai.OpenAI, model_name:str):
|
|
| 683 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 684 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 685 |
)
|
| 686 |
-
print('===== Below is response in Instant Mode ======')
|
| 687 |
print(f'response: {response.choices[0].message.content}')
|
| 688 |
return response.choices[0].message.content
|
| 689 |
```
|
|
|
|
| 529 |
|
| 530 |
## 5. Deployment
|
| 531 |
> [!Note]
|
| 532 |
+
> You can access Kimi-K2.5's API on https://platform.moonshot.ai and we provide OpenAI/Anthropic-compatible API for you. To verify the deployment is correct, we also provide the [Kimi Vendor Verifier](https://kimi.com/blog/kimi-vendor-verifier.html).
|
| 533 |
Currently, Kimi-K2.5 is recommended to run on the following inference engines:
|
| 534 |
* vLLM
|
| 535 |
* SGLang
|
|
|
|
| 545 |
|
| 546 |
The usage demos below demonstrate how to call our official API.
|
| 547 |
|
| 548 |
+
For third-party APIs deployed with vLLM or SGLang, please note that:
|
| 549 |
> [!Note]
|
| 550 |
+
> - Chat with video content is an experimental feature and is only supported in our official API for now.
|
| 551 |
>
|
| 552 |
> - The recommended `temperature` will be `1.0` for Thinking mode and `0.6` for Instant mode.
|
| 553 |
>
|
| 554 |
+
> - The recommended `top_p` is `0.95`.
|
| 555 |
>
|
| 556 |
> - To use instant mode, you need to pass `{'chat_template_kwargs': {"thinking": False}}` in `extra_body`.
|
| 557 |
|
|
|
|
| 576 |
response = client.chat.completions.create(
|
| 577 |
model=model_name, messages=messages, stream=False, max_tokens=4096
|
| 578 |
)
|
| 579 |
+
print('====== Below is reasoning_content in Thinking Mode ======')
|
| 580 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 581 |
+
print('====== Below is response in Thinking Mode ======')
|
| 582 |
print(f'response: {response.choices[0].message.content}')
|
| 583 |
|
| 584 |
# To use instant mode, pass {"thinking" = {"type":"disabled"}}
|
|
|
|
| 590 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 591 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 592 |
)
|
| 593 |
+
print('====== Below is response in Instant Mode ======')
|
| 594 |
print(f'response: {response.choices[0].message.content}')
|
| 595 |
```
|
| 596 |
|
|
|
|
| 625 |
response = client.chat.completions.create(
|
| 626 |
model=model_name, messages=messages, stream=False, max_tokens=8192
|
| 627 |
)
|
| 628 |
+
print('====== Below is reasoning_content in Thinking Mode ======')
|
| 629 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 630 |
+
print('====== Below is response in Thinking Mode ======')
|
| 631 |
print(f'response: {response.choices[0].message.content}')
|
| 632 |
|
| 633 |
+
# Also support instant mode if you pass {"thinking" = {"type":"disabled"}}
|
| 634 |
response = client.chat.completions.create(
|
| 635 |
model=model_name,
|
| 636 |
messages=messages,
|
|
|
|
| 639 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 640 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 641 |
)
|
| 642 |
+
print('====== Below is response in Instant Mode ======')
|
| 643 |
print(f'response: {response.choices[0].message.content}')
|
| 644 |
|
| 645 |
return response.choices[0].message.content
|
|
|
|
| 669 |
]
|
| 670 |
|
| 671 |
response = client.chat.completions.create(model=model_name, messages=messages)
|
| 672 |
+
print('====== Below is reasoning_content in Thinking Mode ======')
|
| 673 |
print(f'reasoning content: {response.choices[0].message.reasoning_content}')
|
| 674 |
+
print('====== Below is response in Thinking Mode ======')
|
| 675 |
print(f'response: {response.choices[0].message.content}')
|
| 676 |
|
| 677 |
# Also support instant mode if pass {"thinking" = {"type":"disabled"}}
|
|
|
|
| 683 |
extra_body={'thinking': {'type': 'disabled'}}, # this is for official API
|
| 684 |
# extra_body= {'chat_template_kwargs': {"thinking": False}} # this is for vLLM/SGLang
|
| 685 |
)
|
| 686 |
+
print('====== Below is response in Instant Mode ======')
|
| 687 |
print(f'response: {response.choices[0].message.content}')
|
| 688 |
return response.choices[0].message.content
|
| 689 |
```
|