From 74cd5abdd14b8a7b24a6bf4929f64ae59a3bbd5c Mon Sep 17 00:00:00 2001 From: KKY Date: Tue, 9 Jan 2024 11:13:02 -0600 Subject: [PATCH] Add baichuan chat template jinjia file (#2390) --- examples/template_baichuan.jinja | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 examples/template_baichuan.jinja diff --git a/examples/template_baichuan.jinja b/examples/template_baichuan.jinja new file mode 100644 index 0000000000000..a1812a6c09ab1 --- /dev/null +++ b/examples/template_baichuan.jinja @@ -0,0 +1,22 @@ +{{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }} + +{% for message in messages %} +{% if message['role'] == 'user' %} + +{{ message['content']|trim -}} +{% if not loop.last %} + + +{% endif %} +{% elif message['role'] == 'assistant' %} + +{{ message['content']|trim -}} +{% if not loop.last %} + + +{% endif %} +{% endif %} +{% endfor %} +{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %} + +{% endif %} \ No newline at end of file