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

Fix prompt incorrectly set to empty when suffix is empty string #5757

Merged
merged 41 commits into from
Mar 26, 2024

Conversation

Yiximail
Copy link
Contributor

While using the qwen model, I use the template from its tokenizer_config.json.

"{% 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']}}{% if (loop.last and add_generation_prompt) or not loop.last %}{{ '<|im_end|>' + '\n'}}{% endif %}{% endfor %}{% if add_generation_prompt and messages[-1]['role'] != 'assistant' %}{{ '<|im_start|>assistant\n' }}{% endif %}"

In this case, the suffix is an empty string, which len is 0.

The execution of prompt[:-0], will incorrectly set the prompt to an empty string.

The conversation works fine, but use "continue" will get an error.

Checklist:

@oobabooga oobabooga merged commit 8c9aca2 into oobabooga:dev Mar 26, 2024
PoetOnTheRun pushed a commit to PoetOnTheRun/text-generation-webui that referenced this pull request Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants