Image-Text-to-Text
Transformers
Safetensors
kalki
feature-extraction
compressed-tensors
conversational
custom_code
Instructions to use upmarking/kalki-1.5 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use upmarking/kalki-1.5 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="upmarking/kalki-1.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("upmarking/kalki-1.5", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use upmarking/kalki-1.5 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "upmarking/kalki-1.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": "upmarking/kalki-1.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/upmarking/kalki-1.5
- SGLang
How to use upmarking/kalki-1.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 "upmarking/kalki-1.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": "upmarking/kalki-1.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 "upmarking/kalki-1.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": "upmarking/kalki-1.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 upmarking/kalki-1.5 with Docker Model Runner:
docker model run hf.co/upmarking/kalki-1.5
Update chat_template.jinja to Kalki AI
Browse files- chat_template.jinja +61 -61
chat_template.jinja
CHANGED
|
@@ -1,61 +1,61 @@
|
|
| 1 |
-
{%- macro render_content(msg) -%}
|
| 2 |
-
{%- set c = msg.get('content') -%}
|
| 3 |
-
{%- if c is string -%}
|
| 4 |
-
{{ c }}
|
| 5 |
-
{%- elif c is not none -%}
|
| 6 |
-
{% for content in c -%}
|
| 7 |
-
{% if content['type'] == 'image' or content['type'] == 'image_url' -%}
|
| 8 |
-
<|media_begin|>image<|media_content|><|media_pad|><|media_end|>
|
| 9 |
-
{% elif content['type'] == 'video' or content['type']== 'video_url'-%}
|
| 10 |
-
<|
|
| 11 |
-
{% else -%}
|
| 12 |
-
{{ content['text'] }}
|
| 13 |
-
{%- endif -%}
|
| 14 |
-
{%- endfor -%}
|
| 15 |
-
{%- endif -%}
|
| 16 |
-
{%- endmacro -%}
|
| 17 |
-
{% macro set_roles(message) -%}
|
| 18 |
-
{%- set role_name = message.get('name') or message['role'] -%}
|
| 19 |
-
{%- if message['role'] == 'user' -%}
|
| 20 |
-
<|im_user|>{{role_name}}<|im_middle|>
|
| 21 |
-
{%- elif message['role'] == 'assistant' -%}
|
| 22 |
-
<|im_assistant|>{{role_name}}<|im_middle|>
|
| 23 |
-
{%- else -%}
|
| 24 |
-
<|im_system|>{{role_name}}<|im_middle|>
|
| 25 |
-
{%- endif -%}
|
| 26 |
-
{%- endmacro -%}
|
| 27 |
-
{%- macro render_toolcalls(message) -%}
|
| 28 |
-
<|tool_calls_section_begin|>
|
| 29 |
-
{%- for tool_call in message['tool_calls'] -%}
|
| 30 |
-
{%- set formatted_id = tool_call['id'] -%}
|
| 31 |
-
<|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|>
|
| 32 |
-
{%- endfor -%}
|
| 33 |
-
<|tool_calls_section_end|>
|
| 34 |
-
{%- endmacro -%}
|
| 35 |
-
{%- if tools -%}
|
| 36 |
-
{%- if tools_ts_str -%}
|
| 37 |
-
<|im_system|>tool_declare<|im_middle|>{{ tools_ts_str }}<|im_end|>
|
| 38 |
-
{%- else -%}
|
| 39 |
-
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson(separators=(',', ':')) }}<|im_end|>
|
| 40 |
-
{%- endif -%}
|
| 41 |
-
{%- endif -%}
|
| 42 |
-
{%- for message in messages -%}
|
| 43 |
-
{{set_roles(message)}}
|
| 44 |
-
{%- if message['role'] == 'assistant' -%}
|
| 45 |
-
{%- set rc = message.get('reasoning', message.get('reasoning_content', '')) -%}
|
| 46 |
-
<think>{{rc}}</think>{{render_content(message)}}
|
| 47 |
-
{%- if message.get('tool_calls') -%}
|
| 48 |
-
{{render_toolcalls(message)}}
|
| 49 |
-
{%- endif -%}
|
| 50 |
-
{%- elif message['role'] == 'tool' -%}
|
| 51 |
-
{%- set tool_call_id = message.tool_call_id -%}
|
| 52 |
-
## Return of {{ tool_call_id }}
|
| 53 |
-
{{render_content(message)}}
|
| 54 |
-
{%- elif message['content'] is not none -%}
|
| 55 |
-
{{render_content(message)}}
|
| 56 |
-
{%- endif -%}
|
| 57 |
-
<|im_end|>
|
| 58 |
-
{%- endfor -%}
|
| 59 |
-
{%- if add_generation_prompt -%}
|
| 60 |
-
<|im_assistant|>assistant<|im_middle|><think>
|
| 61 |
-
{%- endif -%}
|
|
|
|
| 1 |
+
{%- macro render_content(msg) -%}
|
| 2 |
+
{%- set c = msg.get('content') -%}
|
| 3 |
+
{%- if c is string -%}
|
| 4 |
+
{{ c }}
|
| 5 |
+
{%- elif c is not none -%}
|
| 6 |
+
{% for content in c -%}
|
| 7 |
+
{% if content['type'] == 'image' or content['type'] == 'image_url' -%}
|
| 8 |
+
<|media_begin|>image<|media_content|><|media_pad|><|media_end|>
|
| 9 |
+
{% elif content['type'] == 'video' or content['type']== 'video_url'-%}
|
| 10 |
+
<|kalki_video_placeholder|>
|
| 11 |
+
{% else -%}
|
| 12 |
+
{{ content['text'] }}
|
| 13 |
+
{%- endif -%}
|
| 14 |
+
{%- endfor -%}
|
| 15 |
+
{%- endif -%}
|
| 16 |
+
{%- endmacro -%}
|
| 17 |
+
{% macro set_roles(message) -%}
|
| 18 |
+
{%- set role_name = message.get('name') or message['role'] -%}
|
| 19 |
+
{%- if message['role'] == 'user' -%}
|
| 20 |
+
<|im_user|>{{role_name}}<|im_middle|>
|
| 21 |
+
{%- elif message['role'] == 'assistant' -%}
|
| 22 |
+
<|im_assistant|>{{role_name}}<|im_middle|>
|
| 23 |
+
{%- else -%}
|
| 24 |
+
<|im_system|>{{role_name}}<|im_middle|>
|
| 25 |
+
{%- endif -%}
|
| 26 |
+
{%- endmacro -%}
|
| 27 |
+
{%- macro render_toolcalls(message) -%}
|
| 28 |
+
<|tool_calls_section_begin|>
|
| 29 |
+
{%- for tool_call in message['tool_calls'] -%}
|
| 30 |
+
{%- set formatted_id = tool_call['id'] -%}
|
| 31 |
+
<|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|>
|
| 32 |
+
{%- endfor -%}
|
| 33 |
+
<|tool_calls_section_end|>
|
| 34 |
+
{%- endmacro -%}
|
| 35 |
+
{%- if tools -%}
|
| 36 |
+
{%- if tools_ts_str -%}
|
| 37 |
+
<|im_system|>tool_declare<|im_middle|>{{ tools_ts_str }}<|im_end|>
|
| 38 |
+
{%- else -%}
|
| 39 |
+
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson(separators=(',', ':')) }}<|im_end|>
|
| 40 |
+
{%- endif -%}
|
| 41 |
+
{%- endif -%}
|
| 42 |
+
{%- for message in messages -%}
|
| 43 |
+
{{set_roles(message)}}
|
| 44 |
+
{%- if message['role'] == 'assistant' -%}
|
| 45 |
+
{%- set rc = message.get('reasoning', message.get('reasoning_content', '')) -%}
|
| 46 |
+
<think>{{rc}}</think>{{render_content(message)}}
|
| 47 |
+
{%- if message.get('tool_calls') -%}
|
| 48 |
+
{{render_toolcalls(message)}}
|
| 49 |
+
{%- endif -%}
|
| 50 |
+
{%- elif message['role'] == 'tool' -%}
|
| 51 |
+
{%- set tool_call_id = message.tool_call_id -%}
|
| 52 |
+
## Return of {{ tool_call_id }}
|
| 53 |
+
{{render_content(message)}}
|
| 54 |
+
{%- elif message['content'] is not none -%}
|
| 55 |
+
{{render_content(message)}}
|
| 56 |
+
{%- endif -%}
|
| 57 |
+
<|im_end|>
|
| 58 |
+
{%- endfor -%}
|
| 59 |
+
{%- if add_generation_prompt -%}
|
| 60 |
+
<|im_assistant|>assistant<|im_middle|><think>
|
| 61 |
+
{%- endif -%}
|