Image-Text-to-Text
Transformers
Safetensors
kimi_k25
image-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 AutoModel model = AutoModel.from_pretrained("moonshotai/Kimi-K2.5", trust_remote_code=True, dtype="auto") - 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
wangzhengtao commited on
Commit ·
da977e1
1
Parent(s): 54383e8
support transformers inference
Browse files- config.json +4 -2
- modeling_kimi_k25.py +4 -4
config.json
CHANGED
|
@@ -116,10 +116,12 @@
|
|
| 116 |
},
|
| 117 |
"format": "pack-quantized",
|
| 118 |
"ignore": [
|
| 119 |
-
"lm_head",
|
| 120 |
"re:.*self_attn.*",
|
| 121 |
"re:.*shared_experts.*",
|
| 122 |
-
"re:.*mlp\\.(gate|up|gate_up|down)_proj.*"
|
|
|
|
|
|
|
|
|
|
| 123 |
],
|
| 124 |
"kv_cache_scheme": null,
|
| 125 |
"quant_method": "compressed-tensors",
|
|
|
|
| 116 |
},
|
| 117 |
"format": "pack-quantized",
|
| 118 |
"ignore": [
|
|
|
|
| 119 |
"re:.*self_attn.*",
|
| 120 |
"re:.*shared_experts.*",
|
| 121 |
+
"re:.*mlp\\.(gate|up|gate_up|down)_proj.*",
|
| 122 |
+
"re:.*lm_head.*",
|
| 123 |
+
"re:vision_tower.*",
|
| 124 |
+
"re:mm_projector.*"
|
| 125 |
],
|
| 126 |
"kv_cache_scheme": null,
|
| 127 |
"quant_method": "compressed-tensors",
|
modeling_kimi_k25.py
CHANGED
|
@@ -562,7 +562,8 @@ class MoonViT3dEncoder(nn.Module):
|
|
| 562 |
hidden_dim: int,
|
| 563 |
num_layers: int,
|
| 564 |
block_cfg: dict,
|
| 565 |
-
video_attn_type: str = 'spatial_temporal'
|
|
|
|
| 566 |
super().__init__()
|
| 567 |
|
| 568 |
assert video_attn_type == 'spatial_temporal', f'video_attn_type must be "spatial_temporal", got {video_attn_type}'
|
|
@@ -570,9 +571,8 @@ class MoonViT3dEncoder(nn.Module):
|
|
| 570 |
self.rope_2d = Rope2DPosEmbRepeated(
|
| 571 |
block_cfg['hidden_dim'] // block_cfg['num_heads'], 512, 512)
|
| 572 |
self.blocks = nn.ModuleList([
|
| 573 |
-
MoonViTEncoderLayer(
|
| 574 |
-
|
| 575 |
-
use_deterministic_attn=self.use_deterministic_attn)
|
| 576 |
for _ in range(num_layers)
|
| 577 |
])
|
| 578 |
self.final_layernorm = nn.LayerNorm(hidden_dim)
|
|
|
|
| 562 |
hidden_dim: int,
|
| 563 |
num_layers: int,
|
| 564 |
block_cfg: dict,
|
| 565 |
+
video_attn_type: str = 'spatial_temporal',
|
| 566 |
+
use_deterministic_attn: bool = False) -> None:
|
| 567 |
super().__init__()
|
| 568 |
|
| 569 |
assert video_attn_type == 'spatial_temporal', f'video_attn_type must be "spatial_temporal", got {video_attn_type}'
|
|
|
|
| 571 |
self.rope_2d = Rope2DPosEmbRepeated(
|
| 572 |
block_cfg['hidden_dim'] // block_cfg['num_heads'], 512, 512)
|
| 573 |
self.blocks = nn.ModuleList([
|
| 574 |
+
MoonViTEncoderLayer(**block_cfg,
|
| 575 |
+
use_deterministic_attn=use_deterministic_attn)
|
|
|
|
| 576 |
for _ in range(num_layers)
|
| 577 |
])
|
| 578 |
self.final_layernorm = nn.LayerNorm(hidden_dim)
|