Image-Text-to-Text
Transformers
Safetensors
kimi_vl
feature-extraction
agent
video
screenspot
long-context
conversational
custom_code
Instructions to use moonshotai/Kimi-VL-A3B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use moonshotai/Kimi-VL-A3B-Instruct 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-Instruct", 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?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("moonshotai/Kimi-VL-A3B-Instruct", trust_remote_code=True, dtype="auto", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use moonshotai/Kimi-VL-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-VL-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-VL-A3B-Instruct", "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-Instruct
- SGLang
How to use moonshotai/Kimi-VL-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-VL-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-VL-A3B-Instruct", "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-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-VL-A3B-Instruct", "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-Instruct with Docker Model Runner:
docker model run hf.co/moonshotai/Kimi-VL-A3B-Instruct
Fix the AttributeError: 'KimiVLForConditionalGeneration' object has no attribute '_supports_sdpa' issue after bumping to transformers==4.54.0
#29
by hebiao064 - opened
- modeling_kimi_vl.py +1 -8
modeling_kimi_vl.py
CHANGED
|
@@ -2406,6 +2406,7 @@ class KimiVLPreTrainedModel(PreTrainedModel, GenerationMixin):
|
|
| 2406 |
_no_split_modules = ["MoonVitEncoderLayer", "DeepseekV3DecoderLayer"]
|
| 2407 |
_skip_keys_device_placement = "past_key_values"
|
| 2408 |
_supports_flash_attn_2 = True
|
|
|
|
| 2409 |
|
| 2410 |
def _init_weights(self, module):
|
| 2411 |
# important: this ported version of Llava isn't meant for training from scratch - only
|
|
@@ -2429,14 +2430,6 @@ class KimiVLPreTrainedModel(PreTrainedModel, GenerationMixin):
|
|
| 2429 |
if module.padding_idx is not None:
|
| 2430 |
module.weight.data[module.padding_idx].zero_()
|
| 2431 |
|
| 2432 |
-
@property
|
| 2433 |
-
def _supports_sdpa(self):
|
| 2434 |
-
"""
|
| 2435 |
-
Retrieve language_model's attribute to check whether the model supports
|
| 2436 |
-
SDPA or not.
|
| 2437 |
-
"""
|
| 2438 |
-
return self.language_model._supports_sdpa
|
| 2439 |
-
|
| 2440 |
|
| 2441 |
class KimiVLForConditionalGeneration(KimiVLPreTrainedModel, GenerationMixin):
|
| 2442 |
|
|
|
|
| 2406 |
_no_split_modules = ["MoonVitEncoderLayer", "DeepseekV3DecoderLayer"]
|
| 2407 |
_skip_keys_device_placement = "past_key_values"
|
| 2408 |
_supports_flash_attn_2 = True
|
| 2409 |
+
_supports_sdpa = False
|
| 2410 |
|
| 2411 |
def _init_weights(self, module):
|
| 2412 |
# important: this ported version of Llava isn't meant for training from scratch - only
|
|
|
|
| 2430 |
if module.padding_idx is not None:
|
| 2431 |
module.weight.data[module.padding_idx].zero_()
|
| 2432 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2433 |
|
| 2434 |
class KimiVLForConditionalGeneration(KimiVLPreTrainedModel, GenerationMixin):
|
| 2435 |
|