Instructions to use moonshotai/Kimi-VL-A3B-Thinking with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-VL-A3B-Thinking with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="moonshotai/Kimi-VL-A3B-Thinking", 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-VL-A3B-Thinking", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moonshotai/Kimi-VL-A3B-Thinking with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "moonshotai/Kimi-VL-A3B-Thinking" # 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-VL-A3B-Thinking", "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-VL-A3B-Thinking
- SGLang
How to use moonshotai/Kimi-VL-A3B-Thinking 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-VL-A3B-Thinking" \ --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-VL-A3B-Thinking", "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-VL-A3B-Thinking" \ --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-VL-A3B-Thinking", "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-VL-A3B-Thinking with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-VL-A3B-Thinking
fix GenerationMixin ImportError in transformers main branch (#6)
Browse files- fix GenerationMixin ImportError in transformers main branch (496bcc3aef55fd057ec943a122be78e0f6c423f3)
- config.json +2 -1
- modeling_kimi_vl.py +2 -4
config.json
CHANGED
|
@@ -19,7 +19,8 @@
|
|
| 19 |
"merge_kernel_size": [
|
| 20 |
2,
|
| 21 |
2
|
| 22 |
-
]
|
|
|
|
| 23 |
},
|
| 24 |
"text_config": {
|
| 25 |
"vocab_size": 163840,
|
|
|
|
| 19 |
"merge_kernel_size": [
|
| 20 |
2,
|
| 21 |
2
|
| 22 |
+
],
|
| 23 |
+
"torch_dtype": "bfloat16"
|
| 24 |
},
|
| 25 |
"text_config": {
|
| 26 |
"vocab_size": 163840,
|
modeling_kimi_vl.py
CHANGED
|
@@ -55,10 +55,8 @@ import torch.distributed as dist
|
|
| 55 |
from torch.nn import CrossEntropyLoss
|
| 56 |
from transformers.activations import GELUActivation, ACT2FN, PytorchGELUTanh
|
| 57 |
from transformers.cache_utils import Cache, DynamicCache
|
| 58 |
-
from transformers.modeling_utils import
|
| 59 |
-
|
| 60 |
-
GenerationMixin,
|
| 61 |
-
)
|
| 62 |
from transformers.models.llava.modeling_llava import LlavaCausalLMOutputWithPast
|
| 63 |
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
|
| 64 |
from transformers.modeling_outputs import (
|
|
|
|
| 55 |
from torch.nn import CrossEntropyLoss
|
| 56 |
from transformers.activations import GELUActivation, ACT2FN, PytorchGELUTanh
|
| 57 |
from transformers.cache_utils import Cache, DynamicCache
|
| 58 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 59 |
+
from transformers.generation.utils import GenerationMixin
|
|
|
|
|
|
|
| 60 |
from transformers.models.llava.modeling_llava import LlavaCausalLMOutputWithPast
|
| 61 |
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask
|
| 62 |
from transformers.modeling_outputs import (
|