fix Llama-template's system prompt bug

This commit is contained in:
“Wzw” 2024-08-12 19:22:12 +08:00
parent c93d55bfb0
commit bcbbf45063
1 changed files with 1 additions and 1 deletions

View File

@ -320,7 +320,7 @@ def _get_jinja_template(template: "Template", tokenizer: "PreTrainedTokenizer")
jinja_template += "{% for message in messages %}"
jinja_template += "{% set content = message['content'] %}"
if isinstance(template, Llama2Template):
jinja_template += "{% if loop.index0 == 0 and system_message is defined %}"
jinja_template += "{% if system_message is defined and (loop.index0 == 0 and messages[0]['role'] != 'system' or loop.index0 == 1 and messages[0]['role'] == 'system') %}"
jinja_template += "{% set content = " + system_message + " + message['content'] %}"
jinja_template += "{% endif %}"