Instructions to use CohereLabs/command-a-plus-05-2026-bf16 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use CohereLabs/command-a-plus-05-2026-bf16 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="CohereLabs/command-a-plus-05-2026-bf16") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("CohereLabs/command-a-plus-05-2026-bf16") model = AutoModelForMultimodalLM.from_pretrained("CohereLabs/command-a-plus-05-2026-bf16", 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?"} ] }, ] inputs = processor.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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- HuggingChat
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use CohereLabs/command-a-plus-05-2026-bf16 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "CohereLabs/command-a-plus-05-2026-bf16" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "CohereLabs/command-a-plus-05-2026-bf16", "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/CohereLabs/command-a-plus-05-2026-bf16
- SGLang
How to use CohereLabs/command-a-plus-05-2026-bf16 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 "CohereLabs/command-a-plus-05-2026-bf16" \ --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": "CohereLabs/command-a-plus-05-2026-bf16", "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 "CohereLabs/command-a-plus-05-2026-bf16" \ --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": "CohereLabs/command-a-plus-05-2026-bf16", "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 CohereLabs/command-a-plus-05-2026-bf16 with Docker Model Runner:
docker model run hf.co/CohereLabs/command-a-plus-05-2026-bf16
Chat template: map tool results to tool call positions in one pass
#4
by vMaroon - opened
- chat_template.jinja +43 -6
chat_template.jinja
CHANGED
|
@@ -39,8 +39,10 @@ These instructions serve as your defaults, but they can be overridden in subsequ
|
|
| 39 |
"is_error": null
|
| 40 |
}
|
| 41 |
]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}
|
| 42 |
-
{%- macro tool_call_id_to_int(messages, tool_call_id) %}
|
| 43 |
-
{%- if regen_tool_call_ids -%}
|
|
|
|
|
|
|
| 44 |
{%- set counter = namespace(value=0) %}
|
| 45 |
{%- set tool_call_id_seen = namespace(value=false) %}
|
| 46 |
{%- for msg in messages %}
|
|
@@ -58,9 +60,9 @@ These instructions serve as your defaults, but they can be overridden in subsequ
|
|
| 58 |
{{ tool_call_id }}
|
| 59 |
{%- endif -%}
|
| 60 |
{%- endmacro %}
|
| 61 |
-
{%- macro format_tool_message(messages, tool_msg) -%}
|
| 62 |
{#- format tool message #}{
|
| 63 |
-
"tool_call_id": "{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}",
|
| 64 |
"results": {
|
| 65 |
{%- if tool_msg.content is mapping or tool_msg.content is string %}
|
| 66 |
|
|
@@ -211,8 +213,43 @@ Your output should adhere to the following json schema:
|
|
| 211 |
{%- if render_developer_instruction -%}
|
| 212 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(developer_instruction) }}<|END_OF_TURN_TOKEN|>
|
| 213 |
{%- endif %}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
{%- for message in messages %}
|
| 215 |
{%- set msg_role_downcased = message.role | lower %}
|
|
|
|
|
|
|
| 216 |
{%- if msg_role_downcased == 'system' and (not (loop.first and initial_instruction_message)) -%}
|
| 217 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
|
| 218 |
{%- elif msg_role_downcased == 'user' -%}
|
|
@@ -243,11 +280,11 @@ Your output should adhere to the following json schema:
|
|
| 243 |
{%- endif %}
|
| 244 |
{%- elif msg_role_downcased == 'tool' and message.tool_call_id not in tool_ids_seen.value -%}
|
| 245 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
|
| 246 |
-
{{ format_tool_message(messages, message) }}
|
| 247 |
{%- for msg in messages[loop.index0 + 1:] %}
|
| 248 |
|
| 249 |
{%- if msg.role | lower == 'tool' %},
|
| 250 |
-
{{ format_tool_message(messages, msg) }}
|
| 251 |
{%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}
|
| 252 |
{%- else %}
|
| 253 |
{%- break %}
|
|
|
|
| 39 |
"is_error": null
|
| 40 |
}
|
| 41 |
]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}
|
| 42 |
+
{%- macro tool_call_id_to_int(messages, tool_call_id, hit) %}
|
| 43 |
+
{%- if regen_tool_call_ids and tool_call_id is string -%}
|
| 44 |
+
{{ hit }}
|
| 45 |
+
{%- elif regen_tool_call_ids -%}
|
| 46 |
{%- set counter = namespace(value=0) %}
|
| 47 |
{%- set tool_call_id_seen = namespace(value=false) %}
|
| 48 |
{%- for msg in messages %}
|
|
|
|
| 60 |
{{ tool_call_id }}
|
| 61 |
{%- endif -%}
|
| 62 |
{%- endmacro %}
|
| 63 |
+
{%- macro format_tool_message(messages, tool_msg, hit) -%}
|
| 64 |
{#- format tool message #}{
|
| 65 |
+
"tool_call_id": "{{ tool_call_id_to_int(messages, tool_msg.tool_call_id, hit) }}",
|
| 66 |
"results": {
|
| 67 |
{%- if tool_msg.content is mapping or tool_msg.content is string %}
|
| 68 |
|
|
|
|
| 213 |
{%- if render_developer_instruction -%}
|
| 214 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(developer_instruction) }}<|END_OF_TURN_TOKEN|>
|
| 215 |
{%- endif %}
|
| 216 |
+
{#- tool_call_ints: one entry per tool message, in message order: the position, among all tool calls, of the first
|
| 217 |
+
tool call with the message's tool_call_id, or '' when none has it. Tool calls and tool messages are tagged, sorted
|
| 218 |
+
by id together (stable, so the calls of an id come first and keep their order) and paired in one pass. -#}
|
| 219 |
+
{%- set tl = namespace(items=[], calls=0, n=0) -%}
|
| 220 |
+
{%- for m in messages -%}
|
| 221 |
+
{%- if m.tool_calls -%}
|
| 222 |
+
{%- for tc in m.tool_calls -%}
|
| 223 |
+
{%- if tc.id is string -%}
|
| 224 |
+
{%- set tl.items = tl.items + [{'id': tc.id, 'k': -1, 'n': tl.calls}] -%}
|
| 225 |
+
{%- endif -%}
|
| 226 |
+
{%- set tl.calls = tl.calls + 1 -%}
|
| 227 |
+
{%- endfor -%}
|
| 228 |
+
{%- endif -%}
|
| 229 |
+
{%- endfor -%}
|
| 230 |
+
{%- for m in messages -%}
|
| 231 |
+
{%- if m.role | lower == 'tool' -%}
|
| 232 |
+
{%- set tl.items = tl.items + [{'id': m.tool_call_id if m.tool_call_id is string else '', 'k': tl.n}] -%}
|
| 233 |
+
{%- set tl.n = tl.n + 1 -%}
|
| 234 |
+
{%- endif -%}
|
| 235 |
+
{%- endfor -%}
|
| 236 |
+
{%- set pr = namespace(id=none, n='', hits=[]) -%}
|
| 237 |
+
{%- for it in tl.items | sort(attribute='id', case_sensitive=true) -%}
|
| 238 |
+
{%- if it.k < 0 -%}
|
| 239 |
+
{%- if pr.id is none or pr.id != it.id -%}
|
| 240 |
+
{%- set pr.id = it.id -%}
|
| 241 |
+
{%- set pr.n = it.n -%}
|
| 242 |
+
{%- endif -%}
|
| 243 |
+
{%- else -%}
|
| 244 |
+
{%- set pr.hits = pr.hits + [{'k': it.k, 'n': pr.n if pr.id is not none and pr.id == it.id else ''}] -%}
|
| 245 |
+
{%- endif -%}
|
| 246 |
+
{%- endfor -%}
|
| 247 |
+
{%- set tool_call_ints = pr.hits | sort(attribute='k') -%}
|
| 248 |
+
{%- set tl.n = 0 -%}
|
| 249 |
{%- for message in messages %}
|
| 250 |
{%- set msg_role_downcased = message.role | lower %}
|
| 251 |
+
{%- set tool_ord = tl.n %}
|
| 252 |
+
{%- if msg_role_downcased == 'tool' %}{%- set tl.n = tl.n + 1 %}{%- endif %}
|
| 253 |
{%- if msg_role_downcased == 'system' and (not (loop.first and initial_instruction_message)) -%}
|
| 254 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ print_msg(message) }}<|END_OF_TURN_TOKEN|>
|
| 255 |
{%- elif msg_role_downcased == 'user' -%}
|
|
|
|
| 280 |
{%- endif %}
|
| 281 |
{%- elif msg_role_downcased == 'tool' and message.tool_call_id not in tool_ids_seen.value -%}
|
| 282 |
<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[
|
| 283 |
+
{{ format_tool_message(messages, message, tool_call_ints[tool_ord].n) }}
|
| 284 |
{%- for msg in messages[loop.index0 + 1:] %}
|
| 285 |
|
| 286 |
{%- if msg.role | lower == 'tool' %},
|
| 287 |
+
{{ format_tool_message(messages, msg, tool_call_ints[tool_ord + 1 + loop.index0].n) }}
|
| 288 |
{%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}
|
| 289 |
{%- else %}
|
| 290 |
{%- break %}
|