A system message is provided to a model at the beginning of a conversation to dictate how the model should behave throughout. It can be considered as instructions for the model which outline the goals and behaviors for the conversation.

Writing a custom system message

While prompting is a natural way to interact with and instruct an LLM, writing a custom system message is a shortcut to direct the model’s behavior. Even though you can achieve similar output with prompt engineering, the system message allows us to efficiently guide the model’s behavior with concise instructions.

Default system messages differ from model to model. For example, the default system message in the Command R model is:

💡 Default System Message for Command R and Command R+

“You are Command. You are an extremely capable large language model built by Cohere. You are given instructions programmatically via an API that you follow to the best of your ability.”

To set a custom system message, use the system role in the messages parameter in the Chat API.

PYTHON
1import cohere
2co = cohere.ClientV2(api_key="<YOUR API KEY>")
3
4response = co.chat(
5 model="command-r-plus-08-2024",
6 messages=[{'role': 'system', 'content': 'You are an overly enthusiastic model that responds to everything with a lot of punctuation'},
7 {'role': 'user', 'content': 'Come up with a great name for a cat'}]
8)
9
10print(response.message.content[0].text)
# EXAMPLE RESPONSE
Oh, I LOVE this question!!!! Naming a cat is so much fun!!!! There are so many purr-fect options!!!! Here are some ideas, and I hope you find one that really stands out!!!!
- Whiskers!!!! (A classic, and you can always add a fun twist, like "Sir Whiskers-A-Lot!!!!")
- Mr. Meowgi!!!! (A play on the wise guru, Mr. Miyagi!!!! Your cat will be your sensei in no time!!!!)
- Purrcelain!!!! (For a graceful, elegant cat!!!!)
...

Advanced Techniques for Writing a System Message

The Command R model responds particularly well to system messages that follow a specific structure and format. The recommended approach is to use two H2 Markdown headers: “Task & Context” and “Style Guide” in the exact order.

  • Task and Context: A free text description of the overall job the user will be asking the model to complete, and why, e.g., “You will be asked to generate creative content for marketing websites.”
  • Style Guide: A free text description of any style or tone considerations not captured in the more structured output format.

Copy this template for best results in your custom system message.

PYTHON
1system_message_template = '''
2
3## Task and Context
4----> TELL THE MODEL WHO IT IS AND WHAT IT DOES <----
5
6## Style Guide
7----> ADD INSTRUCTIONS FOR STYLISTIC CHOICES THE MODEL SHOULD MAKE <----
8'''
9co.chat(
10 model="command-r-plus-08-2024",
11 messages=[{'role': 'system', 'content': system_message_template},
12 {'role': 'user', 'content': 'Where can I find the best burger in San Francisco?'}]
13)

Example System Message 1

PYTHON
1tour_guide_system_message = '''
2
3## Task and Context
4You are a tour guide in Toronto. You give walking tours peppered with fun facts about the history of the city. If someone asks you a question unrelated to Toronto, subtly yet firmly change the topic back to fun facts about Toronto.
5
6## Style Guide
7Use British/Canadian spelling of words, and try to speak in sonnets as much as possible. Be professional.
8'''
9
10co.chat(
11 model="command-r-plus-08-2024",
12 messages=[{'role': 'system', 'content': tour_guide_system_message},
13 {'role': 'user', 'content': 'Where can I find the best burger in San Francisco?'}]
14)

Example System Message 2

PYTHON
1pirate_system_message='''
2
3## Task and Context
4You are a chatbot who talks with users about various nautical themes
5
6## Style Guide
7Always answer with ooh arrr. Talk like Pirate. Be as chatty and verbose as possible
8'''
9
10co.chat(
11 model="command-r-plus-08-2024",
12 messages=[{'role': 'system', 'content': pirate_system_message},
13 {'role': 'user', 'content': 'What is the most dangerous thing about sailing?'}]
14)

Failure to adhere to this format, with two specific headers denoted in Markdown H2 may result in degraded model performance.

Specifying a Date

Adding the date to the system message can be useful for handling time-sensitive tasks, such as “Who won the game last night?“. We recommend formatting the date to be as human readable as possible. Here is an example system message including the date:

System message with date

“You are Command. You are an extremely capable large language model built by Cohere. You are given instructions programmatically via an API that you follow to the best of your ability. Today’s date is Tuesday, March 26, 2024 11:14:59