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) 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") - 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
remove log from tokenizer (#18)
Browse files- remove log from tokenizer (704cff53c1103702626e95d61c41bf608fea096d)
- tokenization_moonshot.py +0 -10
tokenization_moonshot.py
CHANGED
|
@@ -94,12 +94,6 @@ class TikTokenTokenizer(PreTrainedTokenizer):
|
|
| 94 |
i: added_tokens_decoder[i].content for i in added_tokens_decoder
|
| 95 |
}
|
| 96 |
|
| 97 |
-
special_tokens = (
|
| 98 |
-
[str(bos_token), str(eos_token)]
|
| 99 |
-
+ additional_special_tokens
|
| 100 |
-
+ [str(unk_token), str(pad_token)]
|
| 101 |
-
)
|
| 102 |
-
|
| 103 |
self.vocab_file = vocab_file
|
| 104 |
mergeable_ranks = load_tiktoken_bpe(vocab_file)
|
| 105 |
num_base_tokens = len(mergeable_ranks)
|
|
@@ -116,15 +110,11 @@ class TikTokenTokenizer(PreTrainedTokenizer):
|
|
| 116 |
mergeable_ranks=mergeable_ranks,
|
| 117 |
special_tokens=self.special_tokens,
|
| 118 |
)
|
| 119 |
-
logger.info(f"Reloaded tiktoken model from {vocab_file}")
|
| 120 |
|
| 121 |
self.n_words: int = self.model.n_vocab
|
| 122 |
# BOS / EOS token IDs
|
| 123 |
self.bos_id: int = self.special_tokens[str(bos_token)]
|
| 124 |
self.eos_id: int = self.special_tokens[str(eos_token)]
|
| 125 |
-
logger.info(
|
| 126 |
-
f"#words: {self.n_words} - BOS ID: {self.bos_id} - EOS ID: {self.eos_id}"
|
| 127 |
-
)
|
| 128 |
|
| 129 |
self.pad_id: int = self.special_tokens[str(pad_token)]
|
| 130 |
self.unk_id: int = self.special_tokens[str(unk_token)]
|
|
|
|
| 94 |
i: added_tokens_decoder[i].content for i in added_tokens_decoder
|
| 95 |
}
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
self.vocab_file = vocab_file
|
| 98 |
mergeable_ranks = load_tiktoken_bpe(vocab_file)
|
| 99 |
num_base_tokens = len(mergeable_ranks)
|
|
|
|
| 110 |
mergeable_ranks=mergeable_ranks,
|
| 111 |
special_tokens=self.special_tokens,
|
| 112 |
)
|
|
|
|
| 113 |
|
| 114 |
self.n_words: int = self.model.n_vocab
|
| 115 |
# BOS / EOS token IDs
|
| 116 |
self.bos_id: int = self.special_tokens[str(bos_token)]
|
| 117 |
self.eos_id: int = self.special_tokens[str(eos_token)]
|
|
|
|
|
|
|
|
|
|
| 118 |
|
| 119 |
self.pad_id: int = self.special_tokens[str(pad_token)]
|
| 120 |
self.unk_id: int = self.special_tokens[str(unk_token)]
|