Views
No views yet
| Quantization | Blackwell | Hopper |
|---|---|---|
| BF16 (16-bit) | 4 x B200 | 8 x H100 |
| FP8 (8-bit) | 2 x B200 | 4 x H100 |
| W4A4 (4-bit) | 1 x B200 | 2 x H100 |
1# pip install transformers
2from transformers import AutoTokenizer, AutoModelForImageTextToText
3
4model_id = "CohereLabs/command-a-plus-05-2026-bf16"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForImageTextToText.from_pretrained(model_id)
7
8# Format message with the command-a-plus-05-2026-bf16 chat template
9messages = [{"role": "user", "content": "What has keys but can't open locks?"}]
10input_ids = tokenizer.apply_chat_template(
11 messages,
12 tokenize=True,
13 add_generation_prompt=True,
14 return_tensors="pt",
15)
16
17gen_tokens = model.generate(
18 input_ids,
19 max_new_tokens=4096,
20 do_sample=True,
21 temperature=0.6,
22 top_p=0.95
23)
24
25gen_text = tokenizer.decode(gen_tokens[0])
26print(gen_text)<START_THINKING> and <END_THINKING>:<|START_THINKING|>The user asks a riddle: "What has keys but can't open locks?" The answer is a piano (or keyboard). So respond with answer.<|END_THINKING|>1from transformers import pipeline
2import torch
3
4model_id = "CohereLabs/command-a-plus-05-2026-bf16"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6
7pipe = pipeline(
8 "text-generation",
9 model=model_id,
10 dtype="auto",
11 device_map="auto",
12)
13
14messages = [
15 {"role": "user", "content": "Explain the Transformer architecture"},
16]
17
18text = tokenizer.apply_chat_template(
19 messages,
20 tokenize=False,
21 add_generation_prompt=True,
22)
23
24outputs = pipe(
25 messages,
26 max_new_tokens=300,
27)
28print(outputs[0]["generated_text"][-1])
29
30vllm>=0.21.0 is required for Command A+ and accurate response parsing also requires installing Cohere’s melody library.uv pip install vllm>=0.21.0
uv pip install transformers uv pip install cohere_melody>=0.9.0# This is for B200, adjust tp for your device vllm serve CohereLabs/command-a-plus-05-2026-bf16 -tp 4 --tool-call-parser cohere_command4 --reasoning-parser cohere_command4 --enable-auto-tool-choice1from transformers import AutoTokenizer
2
3model_id = "CohereLabs/command-a-plus-05-2026-bf16"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5
6# Define tools
7tools = [{
8 "type": "function",
9 "function": {
10 "name": "query_daily_sales_report",
11 "description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
12 "parameters": {
13 "type": "object",
14 "properties": {
15 "day": {
16 "description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
17 "type": "string",
18 }
19 },
20 "required": ["day"],
21 },
22 },
23}]
24
25# Define conversation input
26conversation = [
27 {"role": "user", "content": "Can you provide a sales summary for 29th September 2023?"}
28]
29
30# Tokenize the Tool Use prompt directly
31input_ids = tokenizer.apply_chat_template(
32 conversation=conversation,
33 tools=tools,
34 tokenize=True,
35 add_generation_prompt=True,
36 return_tensors="pt",
37)1tool_call = {"name": "query_daily_sales_report", "arguments": {"day": "2023-09-29"}}
2thinking = "I will use the query_daily_sales_report tool to find the sales summary for 29th September 2023."
3conversation.append({"role": "assistant", "tool_calls": [{"id": "0", "type": "function", "function": tool_call}], "thinking": thinking})1api_response_query_daily_sales_report = {"date": "2023-09-29", "summary": "Total Sales Amount: 10000, Total Units Sold: 250"} # this needs to be a dictionary!!
2
3# Append tool results
4conversation.append({"role": "tool", "tool_call_id": "0", "content": api_response_query_daily_sales_report})enable_citations=True in tokenizer.apply_chat_template(*). The generation would look like this:On 29th September 2023, the total sales amount was <co>10000</co: 0:[0]> and the total units sold were <co>250.</co: 0:[0]><co> and </co> to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. For example, <co>span</co: 0:[1,2],1:[0]> means that "span" is supported by result 1 and 2 from tool_call_id=0 as well as result 0 from tool_call_id=1. Sources from the same tool call are grouped together and listed as {tool_call_id}:[{list of result indices}], before they are joined together by ",".