@@ -40,6 +40,7 @@ static ChatTemplate()
40
40
new MistralInstructTemplate ( ) ,
41
41
new LLama2ChatTemplate ( ) ,
42
42
new LLama2Template ( ) ,
43
+ new LLama3ChatTemplate ( ) ,
43
44
new Phi2Template ( ) ,
44
45
new VicunaTemplate ( ) ,
45
46
new ZephyrTemplate ( ) ,
@@ -229,7 +230,7 @@ public override string[] GetStop(string playerName, string AIName)
229
230
public class LLama2Template : ChatTemplate
230
231
{
231
232
public override string GetName ( ) { return "llama" ; }
232
- public override string GetDescription ( ) { return "llama" ; }
233
+ public override string GetDescription ( ) { return "llama 2 " ; }
233
234
234
235
protected override string SystemPrefix ( ) { return "<<SYS>>\n " ; }
235
236
protected override string SystemSuffix ( ) { return "\n <</SYS>> " ; }
@@ -250,8 +251,8 @@ public override string[] GetStop(string playerName, string AIName)
250
251
public class LLama2ChatTemplate : LLama2Template
251
252
{
252
253
public override string GetName ( ) { return "llama chat" ; }
253
- public override string GetDescription ( ) { return "llama (modified for chat)" ; }
254
- public override string [ ] GetNameMatches ( ) { return new string [ ] { "llama" } ; }
254
+ public override string GetDescription ( ) { return "llama 2 (modified for chat)" ; }
255
+ public override string [ ] GetNameMatches ( ) { return new string [ ] { "llama-2" , "llama v2 "} ; }
255
256
256
257
protected override string PlayerPrefix ( string playerName ) { return "### " + playerName + ":" ; }
257
258
protected override string AIPrefix ( string AIName ) { return "### " + AIName + ":" ; }
@@ -263,6 +264,33 @@ public override string[] GetStop(string playerName, string AIName)
263
264
}
264
265
}
265
266
267
+ /// @ingroup template
268
+ /// <summary>
269
+ /// Class implementing the LLama3 template for chat
270
+ /// </summary>
271
+ public class LLama3ChatTemplate : ChatTemplate
272
+ {
273
+ public override string GetName ( ) { return "llama3 chat" ; }
274
+ public override string GetDescription ( ) { return "llama 3 (chat)" ; }
275
+ public override string [ ] GetNameMatches ( ) { return new string [ ] { "llama-3" , "llama v3" } ; }
276
+ public override string [ ] GetChatTemplateMatches ( ) { return new string [ ] { "{% set loop_messages = messages %}{% for message in loop_messages %}{% set content = '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n \n '+ message['content'] | trim + '<|eot_id|>' %}{% if loop.index0 == 0 %}{% set content = bos_token + content %}{% endif %}{{ content }}{% endfor %}{{ '<|start_header_id|>assistant<|end_header_id|>\n \n ' }}" } ; }
277
+
278
+ protected override string PromptPrefix ( ) { return "<|begin_of_text|>" ; }
279
+ protected override string SystemPrefix ( ) { return "<|start_header_id|>system<|end_header_id|>\n \n " ; }
280
+ protected override string SystemSuffix ( ) { return "<|eot_id|>" ; }
281
+
282
+ protected override string RequestSuffix ( ) { return "<|eot_id|>" ; }
283
+ protected override string PairSuffix ( ) { return "<|eot_id|>" ; }
284
+
285
+ protected override string PlayerPrefix ( string playerName ) { return $ "<|start_header_id|>{ playerName } <|end_header_id|>\n \n "; }
286
+ protected override string AIPrefix ( string AIName ) { return $ "<|start_header_id|>{ AIName } <|end_header_id|>\n \n "; }
287
+
288
+ public override string [ ] GetStop ( string playerName , string AIName )
289
+ {
290
+ return AddStopNewlines ( new string [ ] { "<|eot_id|>" } ) ;
291
+ }
292
+ }
293
+
266
294
/// @ingroup template
267
295
/// <summary>
268
296
/// Class implementing the Mistral Instruct template
0 commit comments