Husnain commited on
Commit
31a6c9b
1 Parent(s): 3ed391d

💎 [Feature] New model supported: command-r-plus (CohereForai/c4ai-com…

Browse files
Files changed (1) hide show
  1. messagers/message_composer.py +9 -5
messagers/message_composer.py CHANGED
@@ -52,7 +52,7 @@ class MessageComposer:
52
  # - https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1#instruction-format
53
  # - https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO#prompt-format
54
  # - https://huggingface.co/openchat/openchat-3.5-0106
55
- # - https://huggingface.co/google/gemma-1.1-7b-it#chat-template
56
 
57
  # Mistral and Mixtral:
58
  # <s> [INST] Instruction [/INST] Model answer </s> [INST] Follow-up instruction [/INST]
@@ -125,8 +125,8 @@ class MessageComposer:
125
  )
126
  self.merged_str_list.append(f"GPT4 Correct Assistant:\n")
127
  self.merged_str = "\n".join(self.merged_str_list)
128
- # https://huggingface.co/google/gemma-1.1-7b-it#chat-template
129
- elif self.model in ["gemma-1.1-7b"]:
130
  self.messages = self.concat_messages_by_role(messages)
131
  self.merged_str_list = []
132
  self.end_of_turn = "<end_of_turn>"
@@ -152,10 +152,14 @@ class MessageComposer:
152
  # https://huggingface.co/openchat/openchat-3.5-0106
153
  # elif self.model in ["openchat-3.5", "nous-mixtral-8x7b"]:
154
  elif self.model in ["openchat-3.5", "command-r-plus"]:
155
- tokenizer = AutoTokenizer.from_pretrained("self.model_fullname")
156
  self.merged_str = tokenizer.apply_chat_template(
157
  messages, tokenize=False, add_generation_prompt=True
158
  )
 
 
 
 
159
 
160
  return self.merged_str
161
 
@@ -163,7 +167,7 @@ class MessageComposer:
163
  if __name__ == "__main__":
164
  # model = "mixtral-8x7b"
165
  # model = "nous-mixtral-8x7b"
166
- # model = "gemma-1.1-7b"
167
  # model = "openchat-3.5"
168
  model = "command-r-plus"
169
  composer = MessageComposer(model)
 
52
  # - https://huggingface.co/mistralai/Mixtral-8x7B-Instruct-v0.1#instruction-format
53
  # - https://huggingface.co/NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO#prompt-format
54
  # - https://huggingface.co/openchat/openchat-3.5-0106
55
+ # - https://huggingface.co/google/gemma-7b-it#chat-template
56
 
57
  # Mistral and Mixtral:
58
  # <s> [INST] Instruction [/INST] Model answer </s> [INST] Follow-up instruction [/INST]
 
125
  )
126
  self.merged_str_list.append(f"GPT4 Correct Assistant:\n")
127
  self.merged_str = "\n".join(self.merged_str_list)
128
+ # https://huggingface.co/google/gemma-7b-it#chat-template
129
+ elif self.model in ["gemma-7b"]:
130
  self.messages = self.concat_messages_by_role(messages)
131
  self.merged_str_list = []
132
  self.end_of_turn = "<end_of_turn>"
 
152
  # https://huggingface.co/openchat/openchat-3.5-0106
153
  # elif self.model in ["openchat-3.5", "nous-mixtral-8x7b"]:
154
  elif self.model in ["openchat-3.5", "command-r-plus"]:
155
+ tokenizer = AutoTokenizer.from_pretrained(self.model_fullname)
156
  self.merged_str = tokenizer.apply_chat_template(
157
  messages, tokenize=False, add_generation_prompt=True
158
  )
159
+ else:
160
+ self.merged_str = "\n\n".join(
161
+ [f"{message['role']}: {message['content']}" for message in messages]
162
+ )
163
 
164
  return self.merged_str
165
 
 
167
  if __name__ == "__main__":
168
  # model = "mixtral-8x7b"
169
  # model = "nous-mixtral-8x7b"
170
+ # model = "gemma-7b"
171
  # model = "openchat-3.5"
172
  model = "command-r-plus"
173
  composer = MessageComposer(model)