Add chat_template so that it can be used for chat out-of-box
#109
by
chujiezheng
- opened
- tokenizer_config.json +1 -0
tokenizer_config.json
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
"input_ids",
|
6 |
"attention_mask"
|
7 |
],
|
|
|
8 |
"model_max_length": 2048,
|
9 |
"special_tokens_map_file": null,
|
10 |
"tokenizer_class": "PreTrainedTokenizerFast"
|
|
|
5 |
"input_ids",
|
6 |
"attention_mask"
|
7 |
],
|
8 |
+
"chat_template": "{% if messages[0]['role'] == 'system' %}{% set loop_messages = messages[1:] %}{% set system_message = messages[0]['content'] %}{% else %}{% set loop_messages = messages %}{% set system_message = '' %}{% endif %}{% for message in loop_messages %}{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}{% endif %}{% if loop.index0 == 0 %}{{ system_message }}{% endif %}{% if message['role'] == 'user' %}{{ '\\n\\nUser: ' + message['content'].strip() }}{% elif message['role'] == 'assistant' %}{{ '\\n\\nAssistant: ' + message['content'].strip() }}{% endif %}{% endfor %}{% if add_generation_prompt %}{{ '\\n\\nAssistant:' }}{% endif %}",
|
9 |
"model_max_length": 2048,
|
10 |
"special_tokens_map_file": null,
|
11 |
"tokenizer_class": "PreTrainedTokenizerFast"
|