Templates: Modify alpaca and chatml

Add the stop_strings metadata parameter.

Signed-off-by: kingbri <bdashore3@proton.me>
This commit is contained in:
kingbri 2024-03-27 22:28:41 -04:00
parent dc456f4cc2
commit 271f5ba7a4
2 changed files with 8 additions and 0 deletions

View file

@ -1,3 +1,7 @@
{# Metadata #}
{% set stop_strings = ["### Instruction:", "### Input:", "### Response:"] %}
{# Template #}
{{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }}
{% for message in messages %}

View file

@ -1,2 +1,6 @@
{# Metadata #}
{% set stop_strings = ["<|im_start|>", "<|im_end|>"] %}
{# Template #}
{% for message in messages %}{{'<|im_start|>' + message['role'] + '\n' + message['content']}}{% if (loop.last and add_generation_prompt) or not loop.last %}{{ '<|im_end|>' + '\n'}}{% endif %}{% endfor %}
{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{ '<|im_start|>assistant\n' }}{% endif %}