Text Generation
Transformers
Safetensors
deepseek_v3
conversational
custom_code
text-generation-inference
Instructions to use yujiepan/kimi-k2-tiny-random with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yujiepan/kimi-k2-tiny-random with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yujiepan/kimi-k2-tiny-random", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("yujiepan/kimi-k2-tiny-random", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("yujiepan/kimi-k2-tiny-random", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yujiepan/kimi-k2-tiny-random with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yujiepan/kimi-k2-tiny-random" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yujiepan/kimi-k2-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yujiepan/kimi-k2-tiny-random
- SGLang
How to use yujiepan/kimi-k2-tiny-random 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 "yujiepan/kimi-k2-tiny-random" \ --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": "yujiepan/kimi-k2-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "yujiepan/kimi-k2-tiny-random" \ --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": "yujiepan/kimi-k2-tiny-random", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yujiepan/kimi-k2-tiny-random with Docker Model Runner:
docker model run hf.co/yujiepan/kimi-k2-tiny-random
Upload folder using huggingface_hub
Browse files- config.json +1 -1
- generation_config.json +1 -1
- tokenizer_config.json +1 -1
config.json
CHANGED
|
@@ -55,7 +55,7 @@
|
|
| 55 |
"topk_group": 1,
|
| 56 |
"topk_method": "noaux_tc",
|
| 57 |
"torch_dtype": "bfloat16",
|
| 58 |
-
"transformers_version": "4.
|
| 59 |
"use_cache": true,
|
| 60 |
"v_head_dim": 64,
|
| 61 |
"vocab_size": 163840
|
|
|
|
| 55 |
"topk_group": 1,
|
| 56 |
"topk_method": "noaux_tc",
|
| 57 |
"torch_dtype": "bfloat16",
|
| 58 |
+
"transformers_version": "4.54.0.dev0",
|
| 59 |
"use_cache": true,
|
| 60 |
"v_head_dim": 64,
|
| 61 |
"vocab_size": 163840
|
generation_config.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
{
|
| 2 |
"eos_token_id": 163586,
|
| 3 |
"max_length": 131072,
|
| 4 |
-
"transformers_version": "4.
|
| 5 |
"trust_remote_code": true
|
| 6 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"eos_token_id": 163586,
|
| 3 |
"max_length": 131072,
|
| 4 |
+
"transformers_version": "4.54.0.dev0",
|
| 5 |
"trust_remote_code": true
|
| 6 |
}
|
tokenizer_config.json
CHANGED
|
@@ -151,7 +151,7 @@
|
|
| 151 |
"clean_up_tokenization_spaces": false,
|
| 152 |
"eos_token": "[EOS]",
|
| 153 |
"extra_special_tokens": {},
|
| 154 |
-
"chat_template": "{% if tools -%}\n
|
| 155 |
"model_max_length": 1000000000000000019884624838656,
|
| 156 |
"pad_token": "[PAD]",
|
| 157 |
"tokenizer_class": "TikTokenTokenizer",
|
|
|
|
| 151 |
"clean_up_tokenization_spaces": false,
|
| 152 |
"eos_token": "[EOS]",
|
| 153 |
"extra_special_tokens": {},
|
| 154 |
+
"chat_template": "{%- if tools -%}\n <|im_system|>tool_declare<|im_middle|>{{ tools | tojson }}<|im_end|>\n{%- endif -%}\n{%- for message in messages -%}\n {%- if loop.first and messages[0]['role'] != 'system' -%}\n <|im_system|>system<|im_middle|>You are Kimi, an AI assistant created by Moonshot AI.<|im_end|>\n {%- endif -%}\n {%- if message['role'] == 'system' -%}\n <|im_system|>system<|im_middle|>\n {%- elif message['role'] == 'user' -%}\n <|im_user|>user<|im_middle|>\n {%- elif message['role'] == 'assistant' -%}\n <|im_assistant|>assistant<|im_middle|>\n {%- elif message['role'] == 'tool' -%}\n <|im_system|>tool<|im_middle|>\n {%- endif -%}\n {%- if message['role'] == 'assistant' and message.get('tool_calls') -%}\n {%- if message['content'] -%}{{ message['content'] }}{%- endif -%}\n <|tool_calls_section_begin|>\n {%- for tool_call in message['tool_calls'] -%}\n {%- set formatted_id = tool_call['id'] -%}\n <|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>\n {%- endfor -%}\n <|tool_calls_section_end|>\n {%- elif message['role'] == 'tool' -%}\n ## Return of {{ message.tool_call_id }}\n {{ message['content'] }}\n {%- elif message['content'] is string -%}\n {{ message['content'] }}\n {%- elif message['content'] is not none -%}\n {% for content in message['content'] -%}\n {% if content['type'] == 'image' or 'image' in content or 'image_url' in content -%}\n <|media_start|>image<|media_content|><|media_pad|><|media_end|>\n {% else -%}\n {{ content['text'] }}\n {%- endif -%}\n {%- endfor -%}\n {%- endif -%}\n <|im_end|>\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n <|im_assistant|>assistant<|im_middle|>\n{%- endif -%}",
|
| 155 |
"model_max_length": 1000000000000000019884624838656,
|
| 156 |
"pad_token": "[PAD]",
|
| 157 |
"tokenizer_class": "TikTokenTokenizer",
|