Skip to content

Commit

Permalink
Add trimming whitespace to Qwen2-1.5b-Instruct and Gemma-2-9b-it
Browse files Browse the repository at this point in the history
  • Loading branch information
ThiloteE authored Dec 13, 2024
1 parent 3f7061a commit 3dd0704
Showing 1 changed file with 24 additions and 24 deletions.
48 changes: 24 additions & 24 deletions gpt4all-bindings/python/docs/gpt4all_desktop/chat_templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,37 +210,37 @@ For standard templates, GPT4All combines the user message, sources, and attachme
See issue [3282](https://github.com/nomic-ai/gpt4all/issues/3282)
```jinja
{{ bos_token }}
{% if messages[0]['role'] == 'system' %}
{%- if messages[0]['role'] == 'system' %}
{{ raise_exception('System role not supported') }}
{% endif %}
{%- endif %}
{% for message in messages %}
{% if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
{%- for message in messages %}
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
{{ raise_exception('Conversation roles must alternate user/assistant/user/assistant/...') }}
{% endif %}
{% if (message['role'] == 'assistant') %}
{% set role = 'model' %}
{% else %}{% set role = message['role'] %}
{% endif %}
{{ '<start_of_turn>' + role + '\n' + message['content'] | trim + '<end_of_turn>\n' }}
{% endfor %}
{% if add_generation_prompt %}
{{'<start_of_turn>model\n' }}
{% endif %}
{%- endif %}
{%- if (message['role'] == 'assistant') %}
{%- set role = 'model' %}
{%- else %}{% set role = message['role'] %}
{%- endif %}
{{- '<start_of_turn>' + role + '\n' + message['content'] | trim + '<end_of_turn>\n' }}
{%- endfor %}
{%- if add_generation_prompt %}
{{ '<start_of_turn>model\n' }}
{%- endif %}
```

## Qwen/Qwen2-1.5B-Instruct
See issue [3263](https://github.com/nomic-ai/gpt4all/issues/3263)
```jinja
{% for message in messages %}
{% if loop.first and messages[0]['role'] != 'system' %}
{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
{% endif %}
{{'<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n' }}
{% endfor %}
{% if add_generation_prompt %}
{%- for message in messages %}
{%- if loop.first and messages[0]['role'] != 'system' %}
{{ '<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n' }}
{%- endif %}
{{ '<|im_start|>' + message['role'] + '\n' + message['content'] + '<|im_end|>' + '\n' }}
{%- endfor %}
{%- if add_generation_prompt %}
{{ '<|im_start|>assistant\n' }}
{% endif %}
{%- endif %}
```

0 comments on commit 3dd0704

Please sign in to comment.