Skip to content

Commit

Permalink
Templates: Remove whitespace from metadata
Browse files Browse the repository at this point in the history
Apparently setting variables also adds extraneous whitespace before
the template itself.

Doing {%- set stop_strings = ["string1"] -%} fixes this issue.

Signed-off-by: kingbri <bdashore3@proton.me>
  • Loading branch information
kingbri1 committed Sep 8, 2024
1 parent 776bfd8 commit d6ad170
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion templates/alpaca.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# Metadata #}
{% set stop_strings = ["### Instruction:", "### Input:", "### Response:"] %}
{%- set stop_strings = ["### Instruction:", "### Input:", "### Response:"] -%}

{# Template #}
{{ (messages|selectattr('role', 'equalto', 'system')|list|last).content|trim if (messages|selectattr('role', 'equalto', 'system')|list) else '' }}
Expand Down
2 changes: 1 addition & 1 deletion templates/chatml.jinja
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{# Metadata #}
{% set stop_strings = ["<|im_start|>", "<|im_end|>"] %}
{%- 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 %}
Expand Down
8 changes: 4 additions & 4 deletions templates/tool_calls/chatml_with_headers.jinja
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{# Metadata #}
{% set stop_strings = ["<|im_start|>", "<|im_end|>"] %}
{% set message_roles = ['system', 'user', 'assistant', 'tool'] %}
{% set tool_start = "<|tool_start|>" %}
{% set tool_end = "<|tool_end|>" %}
{%- set stop_strings = ["<|im_start|>", "<|im_end|>"] -%}
{%- set message_roles = ['system', 'user', 'assistant', 'tool'] -%}
{%- set tool_start = "<|tool_start|>" -%}
{%- set tool_end = "<|tool_end|>" -%}
{%- set start_header = "<|start_header_id|>" -%}
{%- set end_header = "<|end_header_id|>\n" -%}

Expand Down

0 comments on commit d6ad170

Please sign in to comment.