Blueberry / chat_template.jinja
CrowdMind's picture
Release Blueberry gated three-pass model
5c693b6 verified
Raw History Blame Contribute Delete
862 Bytes
{{- bos_token -}}
{%- set turns = messages -%}
{%- set system_prefix = '' -%}
{%- if turns and turns[0]['role'] == 'system' -%}
{%- set system_prefix = turns[0]['content'] + '
' -%}
{%- set turns = turns[1:] -%}
{%- endif -%}
{%- for message in turns -%}
{%- if loop.index0 % 2 == 0 and message['role'] == 'user' -%}
{{- '<|user_start|>' + (system_prefix if loop.first else '') + message['content'] + '<|user_end|>' -}}
{%- elif loop.index0 % 2 == 1 and message['role'] == 'assistant' -%}
{{- '<|assistant_start|>' + message['content'] + '<|assistant_end|>' -}}
{%- else -%}
{{- raise_exception('Blueberry expects alternating user and assistant turns beginning with the user.') -}}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- '<|assistant_start|>' -}}
{%- endif -%}