From 4e739dc211466b58b6e1f68d481200ebe9567db4 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:22:25 -0700 Subject: [PATCH] Add an instruction template for Command R --- instruction-templates/Command-R.yaml | 26 ++++++++++++++++++++++++++ models/config.yaml | 2 ++ 2 files changed, 28 insertions(+) create mode 100644 instruction-templates/Command-R.yaml diff --git a/instruction-templates/Command-R.yaml b/instruction-templates/Command-R.yaml new file mode 100644 index 00000000..f8bb8a08 --- /dev/null +++ b/instruction-templates/Command-R.yaml @@ -0,0 +1,26 @@ +instruction_template: |- + {%- if messages[0]['role'] == 'system' -%} + {%- set loop_messages = messages[1:] -%} + {%- set system_message = messages[0]['content'] -%} + {%- elif false == true -%} + {%- set loop_messages = messages -%} + {%- set system_message = 'You are Command-R, a brilliant, sophisticated, AI-assistant trained to assist human users by providing thorough responses. You are trained by Cohere.' -%} + {%- else -%} + {%- set loop_messages = messages -%} + {%- set system_message = false -%} + {%- endif -%} + {%- if system_message != false -%} + {{ '<|START_OF_TURN_TOKEN|><|SYSTEM_TOKEN|>' + system_message + '<|END_OF_TURN_TOKEN|>' }} + {%- endif -%} + {%- for message in loop_messages -%} + {%- set content = message['content'] -%} + {%- if message['role'] == 'user' -%} + {{ '<|START_OF_TURN_TOKEN|><|USER_TOKEN|>' + content.strip() + '<|END_OF_TURN_TOKEN|>' }} + {%- elif message['role'] == 'assistant' -%} + {{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' + content.strip() + '<|END_OF_TURN_TOKEN|>' }} + {%- endif -%} + {%- endfor -%} + {%- if add_generation_prompt -%} + {{ '<|START_OF_TURN_TOKEN|><|CHATBOT_TOKEN|>' }} + {%- endif -%} + diff --git a/models/config.yaml b/models/config.yaml index fc7bc44f..184528ab 100644 --- a/models/config.yaml +++ b/models/config.yaml @@ -192,3 +192,5 @@ instruction_template: 'Synthia' .*(hercules|hyperion): instruction_template: 'ChatML' +.*command-r: + instruction_template: 'Command-R'