Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Jinja] GPT4All 3.5.1 breaks GPT4All-Community/gemma-2-9b-it-GGUF #3282

Open
ThiloteE opened this issue Dec 13, 2024 · 2 comments
Open

[Jinja] GPT4All 3.5.1 breaks GPT4All-Community/gemma-2-9b-it-GGUF #3282

ThiloteE opened this issue Dec 13, 2024 · 2 comments
Labels

Comments

@ThiloteE
Copy link
Collaborator

Bug Report

  1. System message field triggers following error: "System message is not "plain text""
  2. Jinja default chat template triggers following error: "Syntax error: 4:2: error: Unexpected token '}'. Expected: '>' '}}{% endif %} -^-------"

Image

Default Jinja template

{{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% 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 (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + '
' + message['content'] | trim + '<end_of_turn>
' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model
'}}{% endif %}

Fixed Jinja template:

{{ bos_token }}{% if messages[0]['role'] == 'system' %}{{ raise_exception('System role not supported') }}{% 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 (message['role'] == 'assistant') %}{% set role = 'model' %}{% else %}{% set role = message['role'] %}{% endif %}{{ '<start_of_turn>' + role + '
' + message['content'] | trim + '<end_of_turn>
' }}{% endfor %}{% if add_generation_prompt %}{{'<start_of_turn>model
' }}{% endif %}

Steps to Reproduce

Download and use the model

Expected Behavior

  1. Model just works.
  2. gemma-2-9b-it was trained without system prompt, so having none should just work instead of triggering an error.
  3. Default Jinja template works out of the box.

Your Environment

@ThiloteE
Copy link
Collaborator Author

Oh, once the jinja template is fixed, the error message related to the system message also vanishes.
Image

@ThiloteE
Copy link
Collaborator Author

Even better working template:

{{ bos_token }}
{% if messages[0]['role'] == 'system' %}
	 {{ raise_exception('System role not supported') }}
{% 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 (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 %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant