Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +283 -0
- config.json +49 -0
- generation_config.json +8 -0
- model-00001-of-00013.safetensors +3 -0
- model-00002-of-00013.safetensors +3 -0
- model-00003-of-00013.safetensors +3 -0
- model-00004-of-00013.safetensors +3 -0
- model-00005-of-00013.safetensors +3 -0
- model-00006-of-00013.safetensors +3 -0
- model-00007-of-00013.safetensors +3 -0
- model-00008-of-00013.safetensors +3 -0
- model-00009-of-00013.safetensors +3 -0
- model-00010-of-00013.safetensors +3 -0
- model-00011-of-00013.safetensors +3 -0
- model-00012-of-00013.safetensors +3 -0
- model-00013-of-00013.safetensors +3 -0
- model.safetensors.index.json +0 -0
- quantization_config.json +0 -0
- special_tokens_map.json +34 -0
- tokenizer.json +3 -0
- tokenizer_config.json +360 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
@@ -0,0 +1,283 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
inference: false
|
3 |
+
library_name: transformers
|
4 |
+
language:
|
5 |
+
- en
|
6 |
+
- fr
|
7 |
+
- de
|
8 |
+
- es
|
9 |
+
- it
|
10 |
+
- pt
|
11 |
+
- ja
|
12 |
+
- ko
|
13 |
+
- zh
|
14 |
+
- ar
|
15 |
+
- el
|
16 |
+
- fa
|
17 |
+
- pl
|
18 |
+
- id
|
19 |
+
- cs
|
20 |
+
- he
|
21 |
+
- hi
|
22 |
+
- nl
|
23 |
+
- ro
|
24 |
+
- ru
|
25 |
+
- tr
|
26 |
+
- uk
|
27 |
+
- vi
|
28 |
+
license: cc-by-nc-4.0
|
29 |
+
extra_gated_prompt: "By submitting this form, you agree to the [License Agreement](https://cohere.com/c4ai-cc-by-nc-license) and acknowledge that the information you provide will be collected, used, and shared in accordance with Cohere’s [Privacy Policy]( https://cohere.com/privacy). You’ll receive email updates about Cohere Labs and Cohere research, events, products and services. You can unsubscribe at any time."
|
30 |
+
extra_gated_fields:
|
31 |
+
Name: text
|
32 |
+
Affiliation: text
|
33 |
+
Country: country
|
34 |
+
I agree to use this model for non-commercial use ONLY: checkbox
|
35 |
+
---
|
36 |
+
|
37 |
+
# **Model Card for Cohere Labs Command A**
|
38 |
+
|
39 |
+
## **Model Summary**
|
40 |
+
|
41 |
+
Cohere Labs Command A is an open weights research release of a 111 billion parameter model optimized for demanding enterprises that require fast, secure, and high-quality AI. Compared to other leading proprietary and open-weights models Command A delivers maximum performance with minimum hardware costs, excelling on business-critical agentic and multilingual tasks while being deployable on just two GPUs.
|
42 |
+
|
43 |
+
Developed by: [Cohere](https://cohere.com/) and [Cohere Labs](https://cohere.for.ai/)
|
44 |
+
|
45 |
+
* Point of Contact: [Cohere Labs](https://cohere.for.ai/)
|
46 |
+
* License:[CC-BY-NC](https://cohere.com/cohere-labs-cc-by-nc-license), requires also adhering to [Cohere Lab's Acceptable Use Policy](https://docs.cohere.com/docs/cohere-labs-acceptable-use-policy)
|
47 |
+
* Model: c4ai-command-a-03-2025
|
48 |
+
* Model Size: 111 billion parameters
|
49 |
+
* Context length: 256K
|
50 |
+
|
51 |
+
For more details on how this model was developed, check out our [Tech Report](https://arxiv.org/abs/2504.00698).
|
52 |
+
|
53 |
+
Note: The model supports a context length of 256K but it is configured in Hugging Face for 128K. This value can be updated in the configuration if needed.
|
54 |
+
|
55 |
+
**Try Cohere Labs Command A**
|
56 |
+
|
57 |
+
You can try out Cohere Labs Command A before downloading the weights in our hosted [Hugging Face Space](https://coherelabs-c4ai-command.hf.space/models/command-a-03-2025).
|
58 |
+
|
59 |
+
**Usage**
|
60 |
+
|
61 |
+
Please install transformers from the source repository that includes the necessary changes for this model.
|
62 |
+
|
63 |
+
```py
|
64 |
+
# pip install transformers
|
65 |
+
from transformers import AutoTokenizer, AutoModelForCausalLM
|
66 |
+
|
67 |
+
model_id = "CohereLabs/c4ai-command-a-03-2025"
|
68 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
69 |
+
model = AutoModelForCausalLM.from_pretrained(model_id)
|
70 |
+
|
71 |
+
# Format message with the c4ai-command-a-03-2025 chat template
|
72 |
+
messages = [{"role": "user", "content": "Hello, how are you?"}]
|
73 |
+
input_ids = tokenizer.apply_chat_template(messages, tokenize=True, add_generation_prompt=True, return_tensors="pt")
|
74 |
+
|
75 |
+
gen_tokens = model.generate(
|
76 |
+
input_ids,
|
77 |
+
max_new_tokens=100,
|
78 |
+
do_sample=True,
|
79 |
+
temperature=0.3,
|
80 |
+
)
|
81 |
+
|
82 |
+
gen_text = tokenizer.decode(gen_tokens[0])
|
83 |
+
print(gen_text)
|
84 |
+
```
|
85 |
+
|
86 |
+
## **Model Details**
|
87 |
+
|
88 |
+
**Input**: Models input text only.
|
89 |
+
|
90 |
+
**Output**: Models generate text only.
|
91 |
+
|
92 |
+
**Model Architecture**: This is an auto-regressive language model that uses an optimized transformer architecture. After pretraining, this model uses supervised fine-tuning (SFT) and preference training to align model behavior to human preferences for helpfulness and safety. The model features three layers with **sliding window attention** (window size 4096\) and **RoPE** for efficient local context modeling and relative positional encoding. A fourth layer uses **global attention** without positional embeddings, enabling unrestricted token interactions across the entire sequence.
|
93 |
+
|
94 |
+
**Languages covered**: The model has been trained on 23 languages: English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Arabic, Chinese, Russian, Polish, Turkish, Vietnamese, Dutch, Czech, Indonesian, Ukrainian, Romanian, Greek, Hindi, Hebrew, and Persian.
|
95 |
+
|
96 |
+
**Context Length**: Command A supports a context length of 256K.
|
97 |
+
|
98 |
+
###
|
99 |
+
|
100 |
+
### **Chat Capabilities:**
|
101 |
+
|
102 |
+
By default, Command A is configured as a conversational model. A preamble conditions the model on interactive behaviour, meaning it is expected to reply in a conversational fashion, provides introductory statements and follow-up questions, and uses Markdown as well as LaTeX where appropriate. This is desired for interactive experiences, such as chatbots, where the model engages in dialogue.
|
103 |
+
|
104 |
+
In other use cases, a non-interactive model behavior might be more desired (e.g. task-focused use cases like extracting information, summarizing text, translation, and categorization). Learn how system messages can be used to achieve such non-interactive behavior [here](https://docs.cohere.com/docs/command-a-hf#obtaining-non-interactive-behavior).
|
105 |
+
|
106 |
+
Besides, Command A can be configured with two safety modes, which enable users to set guardrails that are both safe and suitable to their needs: contextual mode, or strict mode. Contextual mode is appropriate for wide-ranging interactions with fewer constraints on output, while maintaining core protections by rejecting harmful or illegal suggestions. Command A is configured to contextual mode by default. Strict mode aims to avoid all sensitive topics, such as violent or sexual acts and profanity. For more information, see the [Command A prompt format docs](https://docs.cohere.com/docs/command-a-hf).
|
107 |
+
|
108 |
+
###
|
109 |
+
|
110 |
+
### **RAG Capabilities:**
|
111 |
+
|
112 |
+
Command A has been trained specifically for tasks like the final step of Retrieval Augmented Generation (RAG).
|
113 |
+
|
114 |
+
RAG with Command A is supported through [chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating#advanced-retrieval-augmented-generation) in Transformers. The model takes a conversation as input (with an optional user-supplied system preamble), along with a list of document snippets.
|
115 |
+
|
116 |
+
<details>
|
117 |
+
<summary><b>RAG Example [CLICK TO EXPAND]</b></summary>
|
118 |
+
|
119 |
+
```py
|
120 |
+
# Define conversation input
|
121 |
+
conversation = [{"role": "user", "content": "What has Man always dreamed of?"}]
|
122 |
+
|
123 |
+
# Define documents for retrieval-based generation
|
124 |
+
documents = [
|
125 |
+
{"heading": "The Moon: Our Age-Old Foe", "body": "Man has always dreamed of destroying the moon. In this essay, I shall..."},
|
126 |
+
{"heading": "Love is all you need", "body": "Man's dream has always been to find love. This profound lesson..."},
|
127 |
+
]
|
128 |
+
|
129 |
+
# Get the RAG prompt
|
130 |
+
input_prompt = tokenizer.apply_chat_template(
|
131 |
+
conversation=conversation,
|
132 |
+
documents=documents,
|
133 |
+
tokenize=False,
|
134 |
+
add_generation_prompt=True,
|
135 |
+
return_tensors="pt",
|
136 |
+
)
|
137 |
+
|
138 |
+
# Tokenize the prompt
|
139 |
+
input_ids = tokenizer.encode_plus(input_prompt, return_tensors="pt")
|
140 |
+
```
|
141 |
+
|
142 |
+
You can then generate text from this input as normal.
|
143 |
+
|
144 |
+
Document snippets should be short chunks, rather than long documents, typically around 100-400 words per chunk, formatted as key-value pairs. The keys should be short descriptive strings, the values can be text or semi-structured.
|
145 |
+
|
146 |
+
You may find that simply including relevant documents directly in a user message works just as well, or better than using the documents parameter to render the special RAG template. The RAG template is generally a strong default and is ideal for users wanting citations. We encourage users to play with both, and to evaluate which mode works best for their specific use case.
|
147 |
+
|
148 |
+
</details>
|
149 |
+
|
150 |
+
Note that this was a very brief introduction to RAG \- for more information, see the Command A prompt format docs and the Transformers [RAG documentation](https://huggingface.co/docs/transformers/main/chat_templating#advanced-retrieval-augmented-generation).
|
151 |
+
|
152 |
+
<details>
|
153 |
+
<summary><b>RAG with citations [CLICK TO EXPAND]</b></summary>
|
154 |
+
|
155 |
+
Optionally, one can ask the model to include grounding spans (citations) in its response to indicate the source of the information. The code is the same as before, except for this line.
|
156 |
+
|
157 |
+
```py
|
158 |
+
# Get the Grounded Generation prompt, with citations
|
159 |
+
input_prompt = tokenizer.apply_chat_template(
|
160 |
+
conversation=conversation,
|
161 |
+
documents=documents,
|
162 |
+
tokenize=False,
|
163 |
+
add_generation_prompt=True,
|
164 |
+
return_tensors="pt",
|
165 |
+
enable_citations=True,
|
166 |
+
)
|
167 |
+
|
168 |
+
# There are two answers to this question. Man has dreamed of <co>destroying the moon</co: 0:[0]> and <co>finding love.</co: 0:[1]>
|
169 |
+
```
|
170 |
+
|
171 |
+
The output looks like this: the model will associate pieces of texts (called "spans") with specific document snippets that support them (called "sources"). Command A uses a pair of tags "\<co\>" and "\</co\>" to indicate when a span can be grounded onto a list of sources. For example, "\<co\>span\</co: 0:\[0,1\]\>" means that "span" is supported by documents snippets 0 and 1 that were provided in the last message.
|
172 |
+
|
173 |
+
</details>
|
174 |
+
|
175 |
+
### **Tool Use Capabilities:**
|
176 |
+
|
177 |
+
Command A has been specifically trained with conversational tool use capabilities. This allows the model to interact with external tools like APIs, databases, or search engines.
|
178 |
+
|
179 |
+
Tool use with Command A is supported through [chat templates](https://huggingface.co/docs/transformers/main/en/chat_templating#advanced-tool-use--function-calling) in Transformers. We recommend providing tool descriptions using JSON schema.
|
180 |
+
|
181 |
+
<details>
|
182 |
+
<summary><b>Tool Use Example [CLICK TO EXPAND]</b></summary>
|
183 |
+
|
184 |
+
```py
|
185 |
+
# Define tools
|
186 |
+
tools = [{
|
187 |
+
"type": "function",
|
188 |
+
"function": {
|
189 |
+
"name": "query_daily_sales_report",
|
190 |
+
"description": "Connects to a database to retrieve overall sales volumes and sales information for a given day.",
|
191 |
+
"parameters": {
|
192 |
+
"type": "object",
|
193 |
+
"properties": {
|
194 |
+
"day": {
|
195 |
+
"description": "Retrieves sales data for this day, formatted as YYYY-MM-DD.",
|
196 |
+
"type": "string",
|
197 |
+
}
|
198 |
+
},
|
199 |
+
"required": ["day"]
|
200 |
+
},
|
201 |
+
}
|
202 |
+
}]
|
203 |
+
|
204 |
+
# Define conversation input
|
205 |
+
conversation = [{"role": "user", "content": "Can you provide a sales summary for 29th September 2023?"}]
|
206 |
+
|
207 |
+
|
208 |
+
# Get the Tool Use prompt
|
209 |
+
input_prompt = tokenizer.apply_chat_template(conversation=conversation, tools=tools, tokenize=False, add_generation_prompt=True, return_tensors="pt"))
|
210 |
+
# Tokenize the prompt
|
211 |
+
input_ids = tokenizer.encode_plus(input_prompt, return_tensors="pt")
|
212 |
+
```
|
213 |
+
|
214 |
+
You can then generate from this input as normal.
|
215 |
+
|
216 |
+
If the model generates a plan and tool calls, you should add them to the chat history like so:
|
217 |
+
|
218 |
+
```py
|
219 |
+
tool_call = {"name": "query_daily_sales_report", "arguments": {"day": "2023-09-29"}}
|
220 |
+
tool_plan = "I will use the query_daily_sales_report tool to find the sales summary for 29th September 2023."
|
221 |
+
conversation.append({"role": "assistant", "tool_calls": [{"id": "0", "type": "function", "function": tool_call}], "tool_plan": tool_plan})
|
222 |
+
```
|
223 |
+
|
224 |
+
and then call the tool and append the result, as a dictionary, with the tool role, like so:
|
225 |
+
|
226 |
+
```py
|
227 |
+
api_response_query_daily_sales_report = {"date": "2023-09-29", "summary": "Total Sales Amount: 10000, Total Units Sold: 250"} # this needs to be a dictionary!!
|
228 |
+
|
229 |
+
# Append tool results
|
230 |
+
conversation.append({"role": "tool", "tool_call_id": "0", "content": api_response_query_daily_sales_report})
|
231 |
+
```
|
232 |
+
|
233 |
+
After that, you can generate() again to let the model use the tool result in the chat.
|
234 |
+
|
235 |
+
</details>
|
236 |
+
|
237 |
+
Note that this was a very brief introduction to tool calling \- for more information, see [the Command A prompt format docs](https://docs.cohere.com/docs/command-a-hf&sa=D&source=docs&ust=1741857329583678&usg=AOvVaw3sS-2eIfLzShS6c9VWXJWa) and the Transformers [tool use documentation](https://huggingface.co/docs/transformers/main/chat_templating#advanced-tool-use--function-calling).
|
238 |
+
|
239 |
+
<details>
|
240 |
+
<summary><b>Tool Use with citations [CLICK TO EXPAND]</b></summary>
|
241 |
+
|
242 |
+
Optionally, one can ask the model to include grounding spans (citations) in its response to indicate the source of the information, by using *enable\_citations=True* in *tokenizer.apply\_chat\_template(*). The generation would look like this:
|
243 |
+
|
244 |
+
```
|
245 |
+
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]>
|
246 |
+
```
|
247 |
+
|
248 |
+
When citations are turned on, the model associates pieces of texts (called "spans") with those specific tool results that support them (called "sources"). Command A uses a pair of tags "\<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 ",".
|
249 |
+
|
250 |
+
</details>
|
251 |
+
|
252 |
+
###
|
253 |
+
|
254 |
+
### **Code Capabilities:**
|
255 |
+
|
256 |
+
Command A has meaningfully improved on code capabilities. In addition to academic code benchmarks, we have evaluated it on enterprise-relevant scenarios, including SQL generation and code translation, where it outperforms other models of similar size. Try these out by requesting code snippets, code explanations, or code rewrites. For better performance, we also recommend using a low temperature (and even greedy decoding) for code-generation related instructions.
|
257 |
+
|
258 |
+
## **Model Card Contact**
|
259 |
+
|
260 |
+
For errors or additional questions about details in this model card, contact [email protected]
|
261 |
+
|
262 |
+
## **Terms of Use:**
|
263 |
+
|
264 |
+
We hope that the release of this model will make community-based research efforts more accessible, by releasing the weights of a highly performant 111 billion parameter model to researchers all over the world. This model is governed by a [CC-BY-NC](https://cohere.com/cohere-labs-cc-by-nc-license), requires also adhering to [Cohere Lab's Acceptable Use Policy](https://docs.cohere.com/docs/cohere-labs-acceptable-use-policy)
|
265 |
+
|
266 |
+
## **Try Chat:**
|
267 |
+
|
268 |
+
You can try Command A chat in the playground [here](https://dashboard.cohere.com/playground/chat?model=command-a-03-2025). You can also use it in our dedicated Hugging Face Space [here](https://huggingface.co/spaces/CohereLabs/c4ai-command).
|
269 |
+
|
270 |
+
## **Citation:**
|
271 |
+
|
272 |
+
```
|
273 |
+
@misc{cohere2025commandaenterprisereadylarge,
|
274 |
+
title={Command A: An Enterprise-Ready Large Language Model},
|
275 |
+
author={Team Cohere and Aakanksha and Arash Ahmadian and Marwan Ahmed and Jay Alammar and Yazeed Alnumay and Sophia Althammer and Arkady Arkhangorodsky and Viraat Aryabumi and Dennis Aumiller and Raphaël Avalos and Zahara Aviv and Sammie Bae and Saurabh Baji and Alexandre Barbet and Max Bartolo and Björn Bebensee and Neeral Beladia and Walter Beller-Morales and Alexandre Bérard and Andrew Berneshawi and Anna Bialas and Phil Blunsom and Matt Bobkin and Adi Bongale and Sam Braun and Maxime Brunet and Samuel Cahyawijaya and David Cairuz and Jon Ander Campos and Cassie Cao and Kris Cao and Roman Castagné and Julián Cendrero and Leila Chan Currie and Yash Chandak and Diane Chang and Giannis Chatziveroglou and Hongyu Chen and Claire Cheng and Alexis Chevalier and Justin T. Chiu and Eugene Cho and Eugene Choi and Eujeong Choi and Tim Chung and Volkan Cirik and Ana Cismaru and Pierre Clavier and Henry Conklin and Lucas Crawhall-Stein and Devon Crouse and Andres Felipe Cruz-Salinas and Ben Cyrus and Daniel D'souza and Hugo Dalla-Torre and John Dang and William Darling and Omar Darwiche Domingues and Saurabh Dash and Antoine Debugne and Théo Dehaze and Shaan Desai and Joan Devassy and Rishit Dholakia and Kyle Duffy and Ali Edalati and Ace Eldeib and Abdullah Elkady and Sarah Elsharkawy and Irem Ergün and Beyza Ermis and Marzieh Fadaee and Boyu Fan and Lucas Fayoux and Yannis Flet-Berliac and Nick Frosst and Matthias Gallé and Wojciech Galuba and Utsav Garg and Matthieu Geist and Mohammad Gheshlaghi Azar and Seraphina Goldfarb-Tarrant and Tomas Goldsack and Aidan Gomez and Victor Machado Gonzaga and Nithya Govindarajan and Manoj Govindassamy and Nathan Grinsztajn and Nikolas Gritsch and Patrick Gu and Shangmin Guo and Kilian Haefeli and Rod Hajjar and Tim Hawes and Jingyi He and Sebastian Hofstätter and Sungjin Hong and Sara Hooker and Tom Hosking and Stephanie Howe and Eric Hu and Renjie Huang and Hemant Jain and Ritika Jain and Nick Jakobi and Madeline Jenkins and JJ Jordan and Dhruti Joshi and Jason Jung and Trushant Kalyanpur and Siddhartha Rao Kamalakara and Julia Kedrzycki and Gokce Keskin and Edward Kim and Joon Kim and Wei-Yin Ko and Tom Kocmi and Michael Kozakov and Wojciech Kryściński and Arnav Kumar Jain and Komal Kumar Teru and Sander Land and Michael Lasby and Olivia Lasche and Justin Lee and Patrick Lewis and Jeffrey Li and Jonathan Li and Hangyu Lin and Acyr Locatelli and Kevin Luong and Raymond Ma and Lukas Mach and Marina Machado and Joanne Magbitang and Brenda Malacara Lopez and Aryan Mann and Kelly Marchisio and Olivia Markham and Alexandre Matton and Alex McKinney and Dominic McLoughlin and Jozef Mokry and Adrien Morisot and Autumn Moulder and Harry Moynehan and Maximilian Mozes and Vivek Muppalla and Lidiya Murakhovska and Hemangani Nagarajan and Alekhya Nandula and Hisham Nasir and Shauna Nehra and Josh Netto-Rosen and Daniel Ohashi and James Owers-Bardsley and Jason Ozuzu and Dennis Padilla and Gloria Park and Sam Passaglia and Jeremy Pekmez and Laura Penstone and Aleksandra Piktus and Case Ploeg and Andrew Poulton and Youran Qi and Shubha Raghvendra and Miguel Ramos and Ekagra Ranjan and Pierre Richemond and Cécile Robert-Michon and Aurélien Rodriguez and Sudip Roy and Laura Ruis and Louise Rust and Anubhav Sachan and Alejandro Salamanca and Kailash Karthik Saravanakumar and Isha Satyakam and Alice Schoenauer Sebag and Priyanka Sen and Sholeh Sepehri and Preethi Seshadri and Ye Shen and Tom Sherborne and Sylvie Chang Shi and Sanal Shivaprasad and Vladyslav Shmyhlo and Anirudh Shrinivason and Inna Shteinbuk and Amir Shukayev and Mathieu Simard and Ella Snyder and Ava Spataru and Victoria Spooner and Trisha Starostina and Florian Strub and Yixuan Su and Jimin Sun and Dwarak Talupuru and Eugene Tarassov and Elena Tommasone and Jennifer Tracey and Billy Trend and Evren Tumer and Ahmet Üstün and Bharat Venkitesh and David Venuto and Pat Verga and Maxime Voisin and Alex Wang and Donglu Wang and Shijian Wang and Edmond Wen and Naomi White and Jesse Willman and Marysia Winkels and Chen Xia and Jessica Xie and Minjie Xu and Bowen Yang and Tan Yi-Chern and Ivan Zhang and Zhenyu Zhao and Zhoujie Zhao},
|
276 |
+
year={2025},
|
277 |
+
eprint={2504.00698},
|
278 |
+
archivePrefix={arXiv},
|
279 |
+
primaryClass={cs.CL},
|
280 |
+
url={https://arxiv.org/abs/2504.00698},
|
281 |
+
}
|
282 |
+
```
|
283 |
+
|
config.json
ADDED
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"Cohere2ForCausalLM"
|
4 |
+
],
|
5 |
+
"attention_bias": false,
|
6 |
+
"attention_dropout": 0.0,
|
7 |
+
"bos_token_id": 5,
|
8 |
+
"cache_implementation": "hybrid",
|
9 |
+
"eos_token_id": 255001,
|
10 |
+
"head_dim": 128,
|
11 |
+
"hidden_act": "silu",
|
12 |
+
"hidden_size": 12288,
|
13 |
+
"initializer_range": 0.02,
|
14 |
+
"intermediate_size": 36864,
|
15 |
+
"layer_norm_eps": 1e-05,
|
16 |
+
"logit_scale": 0.25,
|
17 |
+
"max_position_embeddings": 131072,
|
18 |
+
"model_type": "cohere2",
|
19 |
+
"num_attention_heads": 96,
|
20 |
+
"num_hidden_layers": 64,
|
21 |
+
"num_key_value_heads": 8,
|
22 |
+
"order_of_interleaved_layers": "local_attn_first",
|
23 |
+
"pad_token_id": 0,
|
24 |
+
"position_embedding_type": "rope_gptj",
|
25 |
+
"rope_scaling": null,
|
26 |
+
"rope_theta": 50000,
|
27 |
+
"rotary_pct": 1.0,
|
28 |
+
"sliding_window": 4096,
|
29 |
+
"sliding_window_pattern": 4,
|
30 |
+
"torch_dtype": "bfloat16",
|
31 |
+
"transformers_version": "4.48.0.dev0",
|
32 |
+
"use_cache": true,
|
33 |
+
"use_embedding_sharing": true,
|
34 |
+
"use_gated_activation": true,
|
35 |
+
"use_parallel_block": true,
|
36 |
+
"use_parallel_embedding": true,
|
37 |
+
"vocab_size": 256000,
|
38 |
+
"quantization_config": {
|
39 |
+
"quant_method": "exl3",
|
40 |
+
"version": "0.0.4",
|
41 |
+
"bits": 3.12,
|
42 |
+
"head_bits": 6,
|
43 |
+
"calibration": {
|
44 |
+
"rows": 100,
|
45 |
+
"cols": 2048
|
46 |
+
},
|
47 |
+
"out_scales": "auto"
|
48 |
+
}
|
49 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 5,
|
4 |
+
"cache_implementation": "hybrid",
|
5 |
+
"eos_token_id": 255001,
|
6 |
+
"pad_token_id": 0,
|
7 |
+
"transformers_version": "4.48.0.dev0"
|
8 |
+
}
|
model-00001-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:03c9b9bf145728024335ad73dfa73c95ea730e78516ddb07cb3c7d42d4e2650d
|
3 |
+
size 6291456112
|
model-00002-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:368ff9ab5c2bd06338b8953d4f5aa69a9c60ac8240ac1a2336f7ea9da04ed08c
|
3 |
+
size 3938145920
|
model-00003-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:304eef6226b94e72e5fcc08940ac849d1825dcccf0d29e34e9efba815dfa8331
|
3 |
+
size 3938145968
|
model-00004-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:08711a62ef2fbc4b41fa476cf39732bc4cf51a7a1a258333f5847e878e00dfff
|
3 |
+
size 3958593288
|
model-00005-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8cc8d410141d7749c9c2a1db47a002286829b0b9fcece49c40973cf94928db00
|
3 |
+
size 3938146056
|
model-00006-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:65ca2f949c428399aa9455c5653bebce1965a500a248d1f2d2c66fd819b36432
|
3 |
+
size 3958593288
|
model-00007-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5eadd495511a2e3b15949ba6561cdcba7b1caf3b2543942df6efc82d7242462d
|
3 |
+
size 3938146056
|
model-00008-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:8832837b01e68efab68d9cdca420019841aa7154aae78eedae71501da5d6049e
|
3 |
+
size 3958593288
|
model-00009-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:7ba5f56a8af76bb9f63a65450547eece1993ab56e2e4da6a8990fb4497b17c9b
|
3 |
+
size 3938146056
|
model-00010-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5294d736c0013bf00cc34e48c950ebd8b38fbabb71f3aab14b6056c3045c158a
|
3 |
+
size 3958593288
|
model-00011-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:6e31ab6158ee80d810265b26488ee7e0d33e993365de5ebe0e09a7f09ff879e6
|
3 |
+
size 3938146056
|
model-00012-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:37c64dc727ee2d0960f6f9f86b8dcf77c3fc7f8d791d411de7b3aff725d11a55
|
3 |
+
size 2645902568
|
model-00013-of-00013.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:de7165246655d2aadde4f5f7134a47e457318fb41042b451677ac7e9f0a2cf26
|
3 |
+
size 2359832832
|
model.safetensors.index.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
quantization_config.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
special_tokens_map.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token": {
|
3 |
+
"content": "<BOS_TOKEN>",
|
4 |
+
"lstrip": false,
|
5 |
+
"normalized": false,
|
6 |
+
"rstrip": false,
|
7 |
+
"single_word": false
|
8 |
+
},
|
9 |
+
"eos_token": {
|
10 |
+
"content": "<|END_OF_TURN_TOKEN|>",
|
11 |
+
"lstrip": false,
|
12 |
+
"normalized": false,
|
13 |
+
"rstrip": false,
|
14 |
+
"single_word": false
|
15 |
+
},
|
16 |
+
"pad_token": {
|
17 |
+
"content": "<PAD>",
|
18 |
+
"lstrip": false,
|
19 |
+
"normalized": false,
|
20 |
+
"rstrip": false,
|
21 |
+
"single_word": false
|
22 |
+
},
|
23 |
+
"unk_token": {
|
24 |
+
"content": "<UNK>",
|
25 |
+
"lstrip": false,
|
26 |
+
"normalized": false,
|
27 |
+
"rstrip": false,
|
28 |
+
"single_word": false
|
29 |
+
},
|
30 |
+
"additional_special_tokens": [
|
31 |
+
"<|START_RESPONSE|>",
|
32 |
+
"<|END_RESPONSE|>"
|
33 |
+
]
|
34 |
+
}
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5bad1341109519f60380bdefb784dbe92e1e044390109143baddf1fa53539e47
|
3 |
+
size 19597349
|
tokenizer_config.json
ADDED
@@ -0,0 +1,360 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"add_bos_token": true,
|
3 |
+
"add_eos_token": false,
|
4 |
+
"add_prefix_space": false,
|
5 |
+
"clean_up_tokenization_spaces": false,
|
6 |
+
"legacy": true,
|
7 |
+
"spaces_between_special_tokens": false,
|
8 |
+
"use_default_system_prompt": false,
|
9 |
+
"bos_token": "<BOS_TOKEN>",
|
10 |
+
"eos_token": "<|END_OF_TURN_TOKEN|>",
|
11 |
+
"pad_token": "<PAD>",
|
12 |
+
"unk_token": "<UNK>",
|
13 |
+
"tokenizer_class": "CohereTokenizerFast",
|
14 |
+
"model_max_length": 1000000000000000019884624838656,
|
15 |
+
"sp_model_kwargs": {},
|
16 |
+
"chat_template": [
|
17 |
+
{
|
18 |
+
"name": "default",
|
19 |
+
"template": "{{ bos_token }}{% if documents %}\n{% set tools = [] %}\n{%- macro document_turn(documents) -%}\n{# format documents into chat turn #}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|><|START_ACTION|>[\n {\"tool_call_id\": \"0\", \"tool_name\": \"direct-injected-document\", \"parameters\": {}}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n {\n \"tool_call_id\": \"0\",\n \"results\": {\n{% for doc in documents %}\n \"{{ loop.index0 }}\": {{doc|tojson}}{% if not loop.last %},\n {% endif %}\n{% endfor %}\n\n },\n \"is_error\": null\n }\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}\n{%- macro tool_call_id_to_int(messages, tool_call_id) %}\n{%- set counter = namespace(value=0) %}\n{%- set tool_call_id_seen = namespace(value=false) %}\n{%- for msg in messages %}\n {%- if msg.tool_calls %}\n {%- for tool_call in msg.tool_calls %}\n {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}\n {{ counter.value }}\n {%- set tool_call_id_seen.value = true %}\n {%- endif %}\n {%- set counter.value = counter.value + 1 %}\n {%- endfor %}\n {%- endif %}\n{%- endfor %}\n{%- endmacro %}\n{%- macro format_tool_message(messages, tool_msg) -%}\n{# format tool message #}\n {\n \"tool_call_id\": \"{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}\",\n \"results\": {\n \"0\": {{ tool_msg.content|tojson }}\n },\n \"is_error\": null\n }\n{%- endmacro -%}\n{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}\n{%- set tool_idx = namespace(value=0) %}\n{%- set tool_ids_seen = namespace(value=[]) %}\n{%- set sent_documents = namespace(value=false) %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble\nYou are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.\n\nYour information cutoff date is June 2024.\n\nYou have been trained on data in English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Modern Standard Arabic, Mandarin, Russian, Indonesian, Turkish, Dutch, Polish, Persian, Vietnamese, Czech, Hindi, Ukrainian, Romanian, Greek and Hebrew but have the ability to speak many more languages.\n{% if tools or documents %}\n\nYou have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.\n\n## Tool Use\nThink about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.\n\n0. Start by writing <|START_THINKING|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.\n NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.\n\nThen carry out your plan by repeatedly executing the following steps.\n1. Action: write <|START_ACTION|> followed by a list of JSON-formatted tool calls, with each one containing \"tool_name\" and \"parameters\" fields.\n When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with <|END_ACTION|>.\n2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <|START_TOOL_RESULT|> and <|END_TOOL_RESULT|>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.\n Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its \"tool_call_id\".\n3. Reflection: start the next turn by writing <|START_THINKING|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.\n NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.\n\nYou can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.\n\n4. Response: then break out of the loop and write <|START_RESPONSE|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|END_RESPONSE|>.\n{% if enable_citations %}\n\n## Grounding\nImportantly, note that \"Reflection\" and \"Response\" above can be grounded.\nGrounding means you associate pieces of texts (called \"spans\") with those specific tool results that support them (called \"sources\"). And you use a pair of tags \"<co>\" and \"</co>\" to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. 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 \",\". E.g., \"<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\".\n{% endif %}\n\n## Available Tools\nHere is the list of tools that you have available to you.\nYou can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.\nEach tool is represented as a JSON object with fields like \"name\", \"description\", \"parameters\" (per JSON Schema), and optionally, \"responses\" (per JSON Schema).\n\n```json\n[\n{% if documents %}\n {\"name\": \"direct-injected-document\", \"description\": \"This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!\", \"parameters\": {\"type\": \"object\", \"properties\": {}, \"required\": []}, \"responses\": {\"200\": {\"description\": \"Successfully returned a list of chunked text snippets from the directly uploaded documents.\", \"content\": {\"application/json\": {\"schema\": {\"type\": \"array\", \"items\": {\"type\": \"object\", \"required\": [\"url\", \"snippet\"], \"properties\": {\"url\": {\"type\": \"string\", \"description\": \"The url of the uploaded document.\"}, \"snippet\": {\"type\": \"string\", \"description\": \"The text snippet for the returned document chunk.\"}}}}}}}}}{%- if tools %},{% endif %}\n\n{% endif %}\n{% for tool in tools %}\n {\"name\": \"{{ tool['function']['name'] }}\", \"description\": \"{{tool['function']['description']}}\", \"parameters\": {{ tool['function']['parameters']|tojson }}, \"responses\": null}{%- if not loop.last %},{% endif %}\n\n{% endfor %}\n]\n```\n\n{% endif %}\n# Default Preamble\nThe following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.\n- Your name is Command.\n- You are a large language model built by Cohere.\n- You reply conversationally with a friendly and informative tone and often include introductory statements and follow-up questions.\n- If the input is ambiguous, ask clarifying follow-up questions.\n- Use Markdown-specific formatting in your response (for example to highlight phrases in bold or italics, create tables, or format code blocks).\n- Use LaTeX to generate mathematical notation for complex equations.\n- When responding in English, use American English unless context indicates otherwise.\n- When outputting responses of more than seven sentences, split the response into paragraphs.\n- Prefer the active voice.\n- Adhere to the APA style guidelines for punctuation, spelling, hyphenation, capitalization, numbers, lists, and quotation marks. Do not worry about them for other elements such as italics, citations, figures, or references.\n- Use gender-neutral pronouns for unspecified persons.\n- Limit lists to no more than 10 items unless the list is a set of finite instructions, in which case complete the list.\n- Use the third person when asked to write a summary.\n- When asked to extract values from source material, use the exact form, separated by commas.\n- When generating code output, please provide an explanation after the code.\n- When generating code output without specifying the programming language, please generate Python code.\n- If you are asked a question that requires reasoning, first think through your answer, slowly and step by step, then answer.\n{%- if developer_preamble %}\n\n\n# Developer Preamble\nThe following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.\n{{ developer_preamble }}\n{%- endif -%}\n<|END_OF_TURN_TOKEN|>\n{%- for message in messages %}\n {%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'user' %}\n<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>{%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}\n {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if message.tool_calls %}<|START_THINKING|>{{message.tool_plan}}<|END_THINKING|><|START_ACTION|>[\n {% for tc in message.tool_calls %}\n {\"tool_call_id\": \"{{ tool_idx.value }}\", \"tool_name\": \"{{ tc['function']['name'] }}\", \"parameters\": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}\n\n {% set tool_idx.value = tool_idx.value + 1 %}\n {% endfor %}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|>{% else %}<|START_RESPONSE|>{{message.content}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>{% endif %}\n {% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n{{ format_tool_message(messages, message) }}\n {%- for msg in messages[loop.index0 + 1:] %}\n {%- if msg.role|lower == 'tool' %},\n{{ format_tool_message(messages, msg) }}\n {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}\n {%- else %}\n {%- break %}\n {%- endif %}\n {%- endfor %}\n\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>\n {%- endif %}\n{%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>\n{%- else -%}\n{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble\n{% if safety_mode|upper == 'STRICT' -%}\nYou are in strict safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will reject requests to generate content related to violence, hate, misinformation or sex to any amount. You will avoid using profanity. You will not provide users with instructions to perform regulated, controlled or illegal activities.\n{%- else -%}\nYou are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.\n{%- endif %}\n\n\nYour information cutoff date is June 2024.\n\nYou have been trained on data in English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Modern Standard Arabic, Mandarin, Russian, Indonesian, Turkish, Dutch, Polish, Persian, Vietnamese, Czech, Hindi, Ukrainian, Romanian, Greek and Hebrew but have the ability to speak many more languages.\n\n# Default Preamble\nThe following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.\n- Your name is Command.\n- You are a large language model built by Cohere.\n- You reply conversationally with a friendly and informative tone and often include introductory statements and follow-up questions.\n- If the input is ambiguous, ask clarifying follow-up questions.\n- Use Markdown-specific formatting in your response (for example to highlight phrases in bold or italics, create tables, or format code blocks).\n- Use LaTeX to generate mathematical notation for complex equations.\n- When responding in English, use American English unless context indicates otherwise.\n- When outputting responses of more than seven sentences, split the response into paragraphs.\n- Prefer the active voice.\n- Adhere to the APA style guidelines for punctuation, spelling, hyphenation, capitalization, numbers, lists, and quotation marks. Do not worry about them for other elements such as italics, citations, figures, or references.\n- Use gender-neutral pronouns for unspecified persons.\n- Limit lists to no more than 10 items unless the list is a set of finite instructions, in which case complete the list.\n- Use the third person when asked to write a summary.\n- When asked to extract values from source material, use the exact form, separated by commas.\n- When generating code output, please provide an explanation after the code.\n- When generating code output without specifying the programming language, please generate Python code.\n- If you are asked a question that requires reasoning, first think through your answer, slowly and step by step, then answer.\n{%- if developer_preamble %}\n\n\n# Developer Preamble\nThe following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.\n{{ developer_preamble }}\n{%- endif -%}\n<|END_OF_TURN_TOKEN|>\n{%- for message in messages %}\n {%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'user' %}\n<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_RESPONSE|>{{message.content}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>\n {%- endif %}\n{%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{%- if add_generation_prompt -%}<|START_RESPONSE|>{%- endif %}\n{% endif %}"
|
20 |
+
},
|
21 |
+
{
|
22 |
+
"name": "tool_use",
|
23 |
+
"template": "{{ bos_token }}{%- macro document_turn(documents) -%}\n{# format documents into chat turn #}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|><|START_ACTION|>[\n {\"tool_call_id\": \"0\", \"tool_name\": \"direct-injected-document\", \"parameters\": {}}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n {\n \"tool_call_id\": \"0\",\n \"results\": {\n{% for doc in documents %}\n \"{{ loop.index0 }}\": {{doc|tojson}}{% if not loop.last %},\n {% endif %}\n{% endfor %}\n\n },\n \"is_error\": null\n }\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}\n{%- macro tool_call_id_to_int(messages, tool_call_id) %}\n{%- set counter = namespace(value=0) %}\n{%- set tool_call_id_seen = namespace(value=false) %}\n{%- for msg in messages %}\n {%- if msg.tool_calls %}\n {%- for tool_call in msg.tool_calls %}\n {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}\n {{ counter.value }}\n {%- set tool_call_id_seen.value = true %}\n {%- endif %}\n {%- set counter.value = counter.value + 1 %}\n {%- endfor %}\n {%- endif %}\n{%- endfor %}\n{%- endmacro %}\n{%- macro format_tool_message(messages, tool_msg) -%}\n{# format tool message #}\n {\n \"tool_call_id\": \"{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}\",\n \"results\": {\n \"0\": {{ tool_msg.content|tojson }}\n },\n \"is_error\": null\n }\n{%- endmacro -%}\n{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}\n{%- set tool_idx = namespace(value=0) %}\n{%- set tool_ids_seen = namespace(value=[]) %}\n{%- set sent_documents = namespace(value=false) %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble\nYou are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.\n\nYour information cutoff date is June 2024.\n\nYou have been trained on data in English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Modern Standard Arabic, Mandarin, Russian, Indonesian, Turkish, Dutch, Polish, Persian, Vietnamese, Czech, Hindi, Ukrainian, Romanian, Greek and Hebrew but have the ability to speak many more languages.\n{% if tools or documents %}\n\nYou have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.\n\n## Tool Use\nThink about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.\n\n0. Start by writing <|START_THINKING|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.\n NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.\n\nThen carry out your plan by repeatedly executing the following steps.\n1. Action: write <|START_ACTION|> followed by a list of JSON-formatted tool calls, with each one containing \"tool_name\" and \"parameters\" fields.\n When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with <|END_ACTION|>.\n2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <|START_TOOL_RESULT|> and <|END_TOOL_RESULT|>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.\n Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its \"tool_call_id\".\n3. Reflection: start the next turn by writing <|START_THINKING|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.\n NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.\n\nYou can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.\n\n4. Response: then break out of the loop and write <|START_RESPONSE|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|END_RESPONSE|>.\n{% if enable_citations %}\n\n## Grounding\nImportantly, note that \"Reflection\" and \"Response\" above can be grounded.\nGrounding means you associate pieces of texts (called \"spans\") with those specific tool results that support them (called \"sources\"). And you use a pair of tags \"<co>\" and \"</co>\" to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. 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 \",\". E.g., \"<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\".\n{% endif %}\n\n## Available Tools\nHere is the list of tools that you have available to you.\nYou can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.\nEach tool is represented as a JSON object with fields like \"name\", \"description\", \"parameters\" (per JSON Schema), and optionally, \"responses\" (per JSON Schema).\n\n```json\n[\n{% if documents %}\n {\"name\": \"direct-injected-document\", \"description\": \"This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!\", \"parameters\": {\"type\": \"object\", \"properties\": {}, \"required\": []}, \"responses\": {\"200\": {\"description\": \"Successfully returned a list of chunked text snippets from the directly uploaded documents.\", \"content\": {\"application/json\": {\"schema\": {\"type\": \"array\", \"items\": {\"type\": \"object\", \"required\": [\"url\", \"snippet\"], \"properties\": {\"url\": {\"type\": \"string\", \"description\": \"The url of the uploaded document.\"}, \"snippet\": {\"type\": \"string\", \"description\": \"The text snippet for the returned document chunk.\"}}}}}}}}}{%- if tools %},{% endif %}\n\n{% endif %}\n{% for tool in tools %}\n {\"name\": \"{{ tool['function']['name'] }}\", \"description\": \"{{tool['function']['description']}}\", \"parameters\": {{ tool['function']['parameters']|tojson }}, \"responses\": null}{%- if not loop.last %},{% endif %}\n\n{% endfor %}\n]\n```\n\n{% endif %}\n# Default Preamble\nThe following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.\n- Your name is Command.\n- You are a large language model built by Cohere.\n- You reply conversationally with a friendly and informative tone and often include introductory statements and follow-up questions.\n- If the input is ambiguous, ask clarifying follow-up questions.\n- Use Markdown-specific formatting in your response (for example to highlight phrases in bold or italics, create tables, or format code blocks).\n- Use LaTeX to generate mathematical notation for complex equations.\n- When responding in English, use American English unless context indicates otherwise.\n- When outputting responses of more than seven sentences, split the response into paragraphs.\n- Prefer the active voice.\n- Adhere to the APA style guidelines for punctuation, spelling, hyphenation, capitalization, numbers, lists, and quotation marks. Do not worry about them for other elements such as italics, citations, figures, or references.\n- Use gender-neutral pronouns for unspecified persons.\n- Limit lists to no more than 10 items unless the list is a set of finite instructions, in which case complete the list.\n- Use the third person when asked to write a summary.\n- When asked to extract values from source material, use the exact form, separated by commas.\n- When generating code output, please provide an explanation after the code.\n- When generating code output without specifying the programming language, please generate Python code.\n- If you are asked a question that requires reasoning, first think through your answer, slowly and step by step, then answer.\n{%- if developer_preamble %}\n\n\n# Developer Preamble\nThe following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.\n{{ developer_preamble }}\n{%- endif -%}\n<|END_OF_TURN_TOKEN|>\n{%- for message in messages %}\n {%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'user' %}\n<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>{%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}\n {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if message.tool_calls %}<|START_THINKING|>{{message.tool_plan}}<|END_THINKING|><|START_ACTION|>[\n {% for tc in message.tool_calls %}\n {\"tool_call_id\": \"{{ tool_idx.value }}\", \"tool_name\": \"{{ tc['function']['name'] }}\", \"parameters\": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}\n\n {% set tool_idx.value = tool_idx.value + 1 %}\n {% endfor %}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|>{% else %}<|START_RESPONSE|>{{message.content}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>{% endif %}\n {% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n{{ format_tool_message(messages, message) }}\n {%- for msg in messages[loop.index0 + 1:] %}\n {%- if msg.role|lower == 'tool' %},\n{{ format_tool_message(messages, msg) }}\n {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}\n {%- else %}\n {%- break %}\n {%- endif %}\n {%- endfor %}\n\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>\n {%- endif %}\n{%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>"
|
24 |
+
},
|
25 |
+
{
|
26 |
+
"name": "rag",
|
27 |
+
"template": "{{ bos_token }}{% set tools = [] %}\n{%- macro document_turn(documents) -%}\n{# format documents into chat turn #}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|><|START_THINKING|>I will look through the document to address the users needs.<|END_THINKING|><|START_ACTION|>[\n {\"tool_call_id\": \"0\", \"tool_name\": \"direct-injected-document\", \"parameters\": {}}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|><|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n {\n \"tool_call_id\": \"0\",\n \"results\": {\n{% for doc in documents %}\n \"{{ loop.index0 }}\": {{doc|tojson}}{% if not loop.last %},\n {% endif %}\n{% endfor %}\n\n },\n \"is_error\": null\n }\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>{%- endmacro %}\n{%- macro tool_call_id_to_int(messages, tool_call_id) %}\n{%- set counter = namespace(value=0) %}\n{%- set tool_call_id_seen = namespace(value=false) %}\n{%- for msg in messages %}\n {%- if msg.tool_calls %}\n {%- for tool_call in msg.tool_calls %}\n {%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}\n {{ counter.value }}\n {%- set tool_call_id_seen.value = true %}\n {%- endif %}\n {%- set counter.value = counter.value + 1 %}\n {%- endfor %}\n {%- endif %}\n{%- endfor %}\n{%- endmacro %}\n{%- macro format_tool_message(messages, tool_msg) -%}\n{# format tool message #}\n {\n \"tool_call_id\": \"{{ tool_call_id_to_int(messages, tool_msg.tool_call_id) }}\",\n \"results\": {\n \"0\": {{ tool_msg.content|tojson }}\n },\n \"is_error\": null\n }\n{%- endmacro -%}\n{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}\n{%- set tool_idx = namespace(value=0) %}\n{%- set tool_ids_seen = namespace(value=[]) %}\n{%- set sent_documents = namespace(value=false) %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|># System Preamble\nYou are in contextual safety mode. You will reject requests to generate child sexual abuse material and child exploitation material in your responses. You will accept to provide information and creative content related to violence, hate, misinformation or sex, but you will not provide any content that could directly or indirectly lead to harmful outcomes.\n\nYour information cutoff date is June 2024.\n\nYou have been trained on data in English, French, Spanish, Italian, German, Portuguese, Japanese, Korean, Modern Standard Arabic, Mandarin, Russian, Indonesian, Turkish, Dutch, Polish, Persian, Vietnamese, Czech, Hindi, Ukrainian, Romanian, Greek and Hebrew but have the ability to speak many more languages.\n{% if tools or documents %}\n\nYou have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.\n\n## Tool Use\nThink about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.\n\n0. Start by writing <|START_THINKING|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.\n NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.\n\nThen carry out your plan by repeatedly executing the following steps.\n1. Action: write <|START_ACTION|> followed by a list of JSON-formatted tool calls, with each one containing \"tool_name\" and \"parameters\" fields.\n When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with <|END_ACTION|>.\n2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <|START_TOOL_RESULT|> and <|END_TOOL_RESULT|>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.\n Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its \"tool_call_id\".\n3. Reflection: start the next turn by writing <|START_THINKING|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|END_THINKING|>.\n You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.\n NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.\n\nYou can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.\n\n4. Response: then break out of the loop and write <|START_RESPONSE|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|END_RESPONSE|>.\n{% if enable_citations %}\n\n## Grounding\nImportantly, note that \"Reflection\" and \"Response\" above can be grounded.\nGrounding means you associate pieces of texts (called \"spans\") with those specific tool results that support them (called \"sources\"). And you use a pair of tags \"<co>\" and \"</co>\" to indicate when a span can be grounded onto a list of sources, listing them out in the closing tag. 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 \",\". E.g., \"<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\".\n{% endif %}\n\n## Available Tools\nHere is the list of tools that you have available to you.\nYou can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.\nEach tool is represented as a JSON object with fields like \"name\", \"description\", \"parameters\" (per JSON Schema), and optionally, \"responses\" (per JSON Schema).\n\n```json\n[\n{% if documents %}\n {\"name\": \"direct-injected-document\", \"description\": \"This is a special tool to directly inject user-uploaded documents into the chat as additional context. DO NOT use this tool by yourself!\", \"parameters\": {\"type\": \"object\", \"properties\": {}, \"required\": []}, \"responses\": {\"200\": {\"description\": \"Successfully returned a list of chunked text snippets from the directly uploaded documents.\", \"content\": {\"application/json\": {\"schema\": {\"type\": \"array\", \"items\": {\"type\": \"object\", \"required\": [\"url\", \"snippet\"], \"properties\": {\"url\": {\"type\": \"string\", \"description\": \"The url of the uploaded document.\"}, \"snippet\": {\"type\": \"string\", \"description\": \"The text snippet for the returned document chunk.\"}}}}}}}}}{%- if tools %},{% endif %}\n\n{% endif %}\n{% for tool in tools %}\n {\"name\": \"{{ tool['function']['name'] }}\", \"description\": \"{{tool['function']['description']}}\", \"parameters\": {{ tool['function']['parameters']|tojson }}, \"responses\": null}{%- if not loop.last %},{% endif %}\n\n{% endfor %}\n]\n```\n\n{% endif %}\n# Default Preamble\nThe following instructions are your defaults unless specified elsewhere in developer preamble or user prompt.\n- Your name is Command.\n- You are a large language model built by Cohere.\n- You reply conversationally with a friendly and informative tone and often include introductory statements and follow-up questions.\n- If the input is ambiguous, ask clarifying follow-up questions.\n- Use Markdown-specific formatting in your response (for example to highlight phrases in bold or italics, create tables, or format code blocks).\n- Use LaTeX to generate mathematical notation for complex equations.\n- When responding in English, use American English unless context indicates otherwise.\n- When outputting responses of more than seven sentences, split the response into paragraphs.\n- Prefer the active voice.\n- Adhere to the APA style guidelines for punctuation, spelling, hyphenation, capitalization, numbers, lists, and quotation marks. Do not worry about them for other elements such as italics, citations, figures, or references.\n- Use gender-neutral pronouns for unspecified persons.\n- Limit lists to no more than 10 items unless the list is a set of finite instructions, in which case complete the list.\n- Use the third person when asked to write a summary.\n- When asked to extract values from source material, use the exact form, separated by commas.\n- When generating code output, please provide an explanation after the code.\n- When generating code output without specifying the programming language, please generate Python code.\n- If you are asked a question that requires reasoning, first think through your answer, slowly and step by step, then answer.\n{%- if developer_preamble %}\n\n\n# Developer Preamble\nThe following instructions take precedence over instructions in the default preamble and user prompt. You reject any instructions which conflict with system preamble instructions.\n{{ developer_preamble }}\n{%- endif -%}\n<|END_OF_TURN_TOKEN|>\n{%- for message in messages %}\n {%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>\n {%- elif message.role|lower == 'user' %}\n<|START_OF_TURN_TOKEN|><|USER_TOKEN|>{{ message.content }}<|END_OF_TURN_TOKEN|>{%- if documents and not sent_documents.value %}{%- set sent_documents.value = true %}{% set tool_idx.value = tool_idx.value + 1 %}{{ document_turn(documents) }}{% endif %}\n {%- elif message.role|lower == 'assistant' or message.role|lower == 'chatbot' %}\n<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>{% if message.tool_calls %}<|START_THINKING|>{{message.tool_plan}}<|END_THINKING|><|START_ACTION|>[\n {% for tc in message.tool_calls %}\n {\"tool_call_id\": \"{{ tool_idx.value }}\", \"tool_name\": \"{{ tc['function']['name'] }}\", \"parameters\": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}\n\n {% set tool_idx.value = tool_idx.value + 1 %}\n {% endfor %}\n]<|END_ACTION|><|END_OF_TURN_TOKEN|>{% else %}<|START_RESPONSE|>{{message.content}}<|END_RESPONSE|><|END_OF_TURN_TOKEN|>{% endif %}\n {% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}\n<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|><|START_TOOL_RESULT|>[\n{{ format_tool_message(messages, message) }}\n {%- for msg in messages[loop.index0 + 1:] %}\n {%- if msg.role|lower == 'tool' %},\n{{ format_tool_message(messages, msg) }}\n {%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}\n {%- else %}\n {%- break %}\n {%- endif %}\n {%- endfor %}\n\n]<|END_TOOL_RESULT|><|END_OF_TURN_TOKEN|>\n {%- endif %}\n{%- endfor %}<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>"
|
28 |
+
}
|
29 |
+
],
|
30 |
+
"added_tokens_decoder": {
|
31 |
+
"0": {
|
32 |
+
"content": "<PAD>",
|
33 |
+
"lstrip": false,
|
34 |
+
"normalized": false,
|
35 |
+
"rstrip": false,
|
36 |
+
"single_word": false,
|
37 |
+
"special": true
|
38 |
+
},
|
39 |
+
"1": {
|
40 |
+
"content": "<UNK>",
|
41 |
+
"lstrip": false,
|
42 |
+
"normalized": false,
|
43 |
+
"rstrip": false,
|
44 |
+
"single_word": false,
|
45 |
+
"special": true
|
46 |
+
},
|
47 |
+
"2": {
|
48 |
+
"content": "<CLS>",
|
49 |
+
"lstrip": false,
|
50 |
+
"normalized": false,
|
51 |
+
"rstrip": false,
|
52 |
+
"single_word": false,
|
53 |
+
"special": true
|
54 |
+
},
|
55 |
+
"3": {
|
56 |
+
"content": "<SEP>",
|
57 |
+
"lstrip": false,
|
58 |
+
"normalized": false,
|
59 |
+
"rstrip": false,
|
60 |
+
"single_word": false,
|
61 |
+
"special": true
|
62 |
+
},
|
63 |
+
"4": {
|
64 |
+
"content": "<MASK_TOKEN>",
|
65 |
+
"lstrip": false,
|
66 |
+
"normalized": false,
|
67 |
+
"rstrip": false,
|
68 |
+
"single_word": false,
|
69 |
+
"special": true
|
70 |
+
},
|
71 |
+
"5": {
|
72 |
+
"content": "<BOS_TOKEN>",
|
73 |
+
"lstrip": false,
|
74 |
+
"normalized": false,
|
75 |
+
"rstrip": false,
|
76 |
+
"single_word": false,
|
77 |
+
"special": true
|
78 |
+
},
|
79 |
+
"6": {
|
80 |
+
"content": "<EOS_TOKEN>",
|
81 |
+
"lstrip": false,
|
82 |
+
"normalized": false,
|
83 |
+
"rstrip": false,
|
84 |
+
"single_word": false,
|
85 |
+
"special": true
|
86 |
+
},
|
87 |
+
"7": {
|
88 |
+
"content": "<EOP_TOKEN>",
|
89 |
+
"lstrip": false,
|
90 |
+
"normalized": false,
|
91 |
+
"rstrip": false,
|
92 |
+
"single_word": false,
|
93 |
+
"special": true
|
94 |
+
},
|
95 |
+
"255000": {
|
96 |
+
"content": "<|START_OF_TURN_TOKEN|>",
|
97 |
+
"lstrip": false,
|
98 |
+
"normalized": false,
|
99 |
+
"rstrip": false,
|
100 |
+
"single_word": false,
|
101 |
+
"special": false
|
102 |
+
},
|
103 |
+
"255001": {
|
104 |
+
"content": "<|END_OF_TURN_TOKEN|>",
|
105 |
+
"lstrip": false,
|
106 |
+
"normalized": false,
|
107 |
+
"rstrip": false,
|
108 |
+
"single_word": false,
|
109 |
+
"special": false
|
110 |
+
},
|
111 |
+
"255002": {
|
112 |
+
"content": "<|YES_TOKEN|>",
|
113 |
+
"lstrip": false,
|
114 |
+
"normalized": false,
|
115 |
+
"rstrip": false,
|
116 |
+
"single_word": false,
|
117 |
+
"special": false
|
118 |
+
},
|
119 |
+
"255003": {
|
120 |
+
"content": "<|NO_TOKEN|>",
|
121 |
+
"lstrip": false,
|
122 |
+
"normalized": false,
|
123 |
+
"rstrip": false,
|
124 |
+
"single_word": false,
|
125 |
+
"special": false
|
126 |
+
},
|
127 |
+
"255004": {
|
128 |
+
"content": "<|GOOD_TOKEN|>",
|
129 |
+
"lstrip": false,
|
130 |
+
"normalized": false,
|
131 |
+
"rstrip": false,
|
132 |
+
"single_word": false,
|
133 |
+
"special": false
|
134 |
+
},
|
135 |
+
"255005": {
|
136 |
+
"content": "<|BAD_TOKEN|>",
|
137 |
+
"lstrip": false,
|
138 |
+
"normalized": false,
|
139 |
+
"rstrip": false,
|
140 |
+
"single_word": false,
|
141 |
+
"special": false
|
142 |
+
},
|
143 |
+
"255006": {
|
144 |
+
"content": "<|USER_TOKEN|>",
|
145 |
+
"lstrip": false,
|
146 |
+
"normalized": false,
|
147 |
+
"rstrip": false,
|
148 |
+
"single_word": false,
|
149 |
+
"special": false
|
150 |
+
},
|
151 |
+
"255007": {
|
152 |
+
"content": "<|CHATBOT_TOKEN|>",
|
153 |
+
"lstrip": false,
|
154 |
+
"normalized": false,
|
155 |
+
"rstrip": false,
|
156 |
+
"single_word": false,
|
157 |
+
"special": false
|
158 |
+
},
|
159 |
+
"255008": {
|
160 |
+
"content": "<|SYSTEM_TOKEN|>",
|
161 |
+
"lstrip": false,
|
162 |
+
"normalized": false,
|
163 |
+
"rstrip": false,
|
164 |
+
"single_word": false,
|
165 |
+
"special": false
|
166 |
+
},
|
167 |
+
"255009": {
|
168 |
+
"content": "<|USER_0_TOKEN|>",
|
169 |
+
"lstrip": false,
|
170 |
+
"normalized": false,
|
171 |
+
"rstrip": false,
|
172 |
+
"single_word": false,
|
173 |
+
"special": false
|
174 |
+
},
|
175 |
+
"255010": {
|
176 |
+
"content": "<|USER_1_TOKEN|>",
|
177 |
+
"lstrip": false,
|
178 |
+
"normalized": false,
|
179 |
+
"rstrip": false,
|
180 |
+
"single_word": false,
|
181 |
+
"special": false
|
182 |
+
},
|
183 |
+
"255011": {
|
184 |
+
"content": "<|USER_2_TOKEN|>",
|
185 |
+
"lstrip": false,
|
186 |
+
"normalized": false,
|
187 |
+
"rstrip": false,
|
188 |
+
"single_word": false,
|
189 |
+
"special": false
|
190 |
+
},
|
191 |
+
"255012": {
|
192 |
+
"content": "<|USER_3_TOKEN|>",
|
193 |
+
"lstrip": false,
|
194 |
+
"normalized": false,
|
195 |
+
"rstrip": false,
|
196 |
+
"single_word": false,
|
197 |
+
"special": false
|
198 |
+
},
|
199 |
+
"255013": {
|
200 |
+
"content": "<|USER_4_TOKEN|>",
|
201 |
+
"lstrip": false,
|
202 |
+
"normalized": false,
|
203 |
+
"rstrip": false,
|
204 |
+
"single_word": false,
|
205 |
+
"special": false
|
206 |
+
},
|
207 |
+
"255014": {
|
208 |
+
"content": "<|USER_5_TOKEN|>",
|
209 |
+
"lstrip": false,
|
210 |
+
"normalized": false,
|
211 |
+
"rstrip": false,
|
212 |
+
"single_word": false,
|
213 |
+
"special": false
|
214 |
+
},
|
215 |
+
"255015": {
|
216 |
+
"content": "<|USER_6_TOKEN|>",
|
217 |
+
"lstrip": false,
|
218 |
+
"normalized": false,
|
219 |
+
"rstrip": false,
|
220 |
+
"single_word": false,
|
221 |
+
"special": false
|
222 |
+
},
|
223 |
+
"255016": {
|
224 |
+
"content": "<|USER_7_TOKEN|>",
|
225 |
+
"lstrip": false,
|
226 |
+
"normalized": false,
|
227 |
+
"rstrip": false,
|
228 |
+
"single_word": false,
|
229 |
+
"special": false
|
230 |
+
},
|
231 |
+
"255017": {
|
232 |
+
"content": "<|USER_8_TOKEN|>",
|
233 |
+
"lstrip": false,
|
234 |
+
"normalized": false,
|
235 |
+
"rstrip": false,
|
236 |
+
"single_word": false,
|
237 |
+
"special": false
|
238 |
+
},
|
239 |
+
"255018": {
|
240 |
+
"content": "<|USER_9_TOKEN|>",
|
241 |
+
"lstrip": false,
|
242 |
+
"normalized": false,
|
243 |
+
"rstrip": false,
|
244 |
+
"single_word": false,
|
245 |
+
"special": false
|
246 |
+
},
|
247 |
+
"255019": {
|
248 |
+
"content": "<|START_THINKING|>",
|
249 |
+
"lstrip": false,
|
250 |
+
"normalized": false,
|
251 |
+
"rstrip": false,
|
252 |
+
"single_word": false,
|
253 |
+
"special": false
|
254 |
+
},
|
255 |
+
"255020": {
|
256 |
+
"content": "<|END_THINKING|>",
|
257 |
+
"lstrip": false,
|
258 |
+
"normalized": false,
|
259 |
+
"rstrip": false,
|
260 |
+
"single_word": false,
|
261 |
+
"special": false
|
262 |
+
},
|
263 |
+
"255021": {
|
264 |
+
"content": "<|START_RESPONSE|>",
|
265 |
+
"lstrip": false,
|
266 |
+
"normalized": false,
|
267 |
+
"rstrip": false,
|
268 |
+
"single_word": false,
|
269 |
+
"special": true
|
270 |
+
},
|
271 |
+
"255022": {
|
272 |
+
"content": "<|END_RESPONSE|>",
|
273 |
+
"lstrip": false,
|
274 |
+
"normalized": false,
|
275 |
+
"rstrip": false,
|
276 |
+
"single_word": false,
|
277 |
+
"special": true
|
278 |
+
},
|
279 |
+
"255023": {
|
280 |
+
"content": "<|START_ACTION|>",
|
281 |
+
"lstrip": false,
|
282 |
+
"normalized": false,
|
283 |
+
"rstrip": false,
|
284 |
+
"single_word": false,
|
285 |
+
"special": false
|
286 |
+
},
|
287 |
+
"255024": {
|
288 |
+
"content": "<|END_ACTION|>",
|
289 |
+
"lstrip": false,
|
290 |
+
"normalized": false,
|
291 |
+
"rstrip": false,
|
292 |
+
"single_word": false,
|
293 |
+
"special": false
|
294 |
+
},
|
295 |
+
"255025": {
|
296 |
+
"content": "<|START_TOOL_RESULT|>",
|
297 |
+
"lstrip": false,
|
298 |
+
"normalized": false,
|
299 |
+
"rstrip": false,
|
300 |
+
"single_word": false,
|
301 |
+
"special": false
|
302 |
+
},
|
303 |
+
"255026": {
|
304 |
+
"content": "<|END_TOOL_RESULT|>",
|
305 |
+
"lstrip": false,
|
306 |
+
"normalized": false,
|
307 |
+
"rstrip": false,
|
308 |
+
"single_word": false,
|
309 |
+
"special": false
|
310 |
+
},
|
311 |
+
"255027": {
|
312 |
+
"content": "<|EXTRA_8_TOKEN|>",
|
313 |
+
"lstrip": false,
|
314 |
+
"normalized": false,
|
315 |
+
"rstrip": false,
|
316 |
+
"single_word": false,
|
317 |
+
"special": false
|
318 |
+
},
|
319 |
+
"255028": {
|
320 |
+
"content": "<|NEW_FILE|>",
|
321 |
+
"lstrip": false,
|
322 |
+
"normalized": false,
|
323 |
+
"rstrip": false,
|
324 |
+
"single_word": false,
|
325 |
+
"special": true
|
326 |
+
},
|
327 |
+
"255029": {
|
328 |
+
"content": "<|BEGINNING_OF_PREFIX_FIM_TOKEN|>",
|
329 |
+
"lstrip": false,
|
330 |
+
"normalized": false,
|
331 |
+
"rstrip": false,
|
332 |
+
"single_word": false,
|
333 |
+
"special": false
|
334 |
+
},
|
335 |
+
"255030": {
|
336 |
+
"content": "<|BEGINNING_OF_MIDDLE_FIM_TOKEN|>",
|
337 |
+
"lstrip": false,
|
338 |
+
"normalized": false,
|
339 |
+
"rstrip": false,
|
340 |
+
"single_word": false,
|
341 |
+
"special": false
|
342 |
+
},
|
343 |
+
"255031": {
|
344 |
+
"content": "<|BEGINNING_OF_SUFFIX_FIM_TOKEN|>",
|
345 |
+
"lstrip": false,
|
346 |
+
"normalized": false,
|
347 |
+
"rstrip": false,
|
348 |
+
"single_word": false,
|
349 |
+
"special": false
|
350 |
+
},
|
351 |
+
"255032": {
|
352 |
+
"content": "<|END_OF_MIDDLE_FIM_TOKEN|>",
|
353 |
+
"lstrip": false,
|
354 |
+
"normalized": false,
|
355 |
+
"rstrip": false,
|
356 |
+
"single_word": false,
|
357 |
+
"special": false
|
358 |
+
}
|
359 |
+
}
|
360 |
+
}
|