nemonameless commited on
Commit
6f520c3
1 Parent(s): eea4ee0

add Hermes-2 in conversation.py

Browse files
Files changed (1) hide show
  1. conversation.py +31 -1
conversation.py CHANGED
@@ -30,7 +30,7 @@ class SeparatorStyle(IntEnum):
30
  FALCON_CHAT = auto()
31
  CHATGLM3 = auto()
32
  INTERNVL_ZH = auto()
33
-
34
 
35
  @dataclasses.dataclass
36
  class Conversation:
@@ -234,6 +234,16 @@ class Conversation:
234
  else:
235
  ret += role + ':'
236
  return ret
 
 
 
 
 
 
 
 
 
 
237
  else:
238
  raise ValueError(f'Invalid style: {self.sep_style}')
239
 
@@ -1213,6 +1223,26 @@ register_conv_template(
1213
  )
1214
 
1215
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1216
  if __name__ == '__main__':
1217
  from fastchat.conversation import get_conv_template
1218
 
 
30
  FALCON_CHAT = auto()
31
  CHATGLM3 = auto()
32
  INTERNVL_ZH = auto()
33
+ MPT = auto()
34
 
35
  @dataclasses.dataclass
36
  class Conversation:
 
234
  else:
235
  ret += role + ':'
236
  return ret
237
+ elif self.sep_style == SeparatorStyle.MPT:
238
+ ret = system_prompt + self.sep
239
+ for role, message in self.messages:
240
+ if message:
241
+ if type(message) is tuple:
242
+ message, _, _ = message
243
+ ret += role + message + self.sep
244
+ else:
245
+ ret += role
246
+ return ret
247
  else:
248
  raise ValueError(f'Invalid style: {self.sep_style}')
249
 
 
1223
  )
1224
 
1225
 
1226
+ # Hermes-2 template
1227
+ register_conv_template(
1228
+ Conversation(
1229
+ name='Hermes-2',
1230
+ system_template='<|im_start|>system\n{system_message}',
1231
+ system_message='Answer the questions.',
1232
+ roles=('<|im_start|>user\n', '<|im_start|>assistant\n'),
1233
+ sep_style=SeparatorStyle.MPT,
1234
+ sep='<|im_end|>',
1235
+ stop_token_ids=[
1236
+ 2,
1237
+ 6,
1238
+ 7,
1239
+ 8,
1240
+ ], # "<|endoftext|>", "<|im_start|>", "<|im_end|>", "<|im_sep|>"
1241
+ stop_str='<|endoftext|>',
1242
+ )
1243
+ )
1244
+
1245
+
1246
  if __name__ == '__main__':
1247
  from fastchat.conversation import get_conv_template
1248