Skip to content

Commit

Permalink
+ configs
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Shaposhnikov committed Oct 15, 2024
1 parent c89301a commit efd99a7
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
34 changes: 34 additions & 0 deletions configs/exp/templates/gemma2.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{%- set replica_start = ['<start_of_turn>'] -%}
{%- set replica_end = ['<end_of_turn>'] -%}

{%- if messages[0]['role'] == 'system' %}
{%- set system_message = messages[0]['content'] | trim + '\n\n' %}
{%- set messages = messages[1:] %}
{%- else %}
{%- set system_message = '' %}
{%- endif %}

{%- for message in messages %}
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
{{- raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
{%- endif %}

{%- if loop.index0 == 0 %}
{%- set content = system_message + message['content'] %}
{%- else %}
{%- set content = message['content'] %}
{%- endif %}

{%- if (message['role'] == 'bot') %}
{{- '<start_of_turn>' + message['role'] + '\n'}}
{%- generation %}
{{- content | trim + '<end_of_turn>' }}
{%- endgeneration %}
{%- else %}
{{- '<start_of_turn>' + message['role'] + '\n' + content | trim + '<end_of_turn>' }}
{%- endif %}
{%- endfor %}

{%- if add_generation_prompt %}
{{- '<start_of_turn>model\n' }}
{%- endif %}
18 changes: 18 additions & 0 deletions configs/exp/templates/llama3.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{%- set replica_start = ['<|start_header_id|>'] -%}
{%- set replica_end = ['<|eot_id|>'] -%}
{{- '<|begin_of_text|>' -}}

{%- for message in messages -%}
{%- if (message['role'] != 'bot') %}
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' + message['content'] + '<|eot_id|>' -}}
{%- elif (message['role'] == 'bot') %}
{{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>\n\n' -}}
{%- generation %}
{{- message['content'] + '<|eot_id|>' -}}
{%- endgeneration %}
{%- endif -%}
{%- endfor -%}

{%- if add_generation_prompt -%}
{{- '<|start_header_id|>' + 'bot' + '<|end_header_id|>\n\n' -}}
{%- endif -%}

0 comments on commit efd99a7

Please sign in to comment.