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

llamamodel: always print special tokens #2701

Merged
merged 1 commit into from
Jul 22, 2024
Merged

llamamodel: always print special tokens #2701

merged 1 commit into from
Jul 22, 2024

Conversation

cebtenzzre
Copy link
Member

@cebtenzzre cebtenzzre commented Jul 19, 2024

This assertion fails when gemma-2-9b-it tries to print <end_of_text>, which is not its EOS token. Historically, special tokens in output have been rendered as an empty string in llama.cpp and thus GPT4All has done the same.

Q_ASSERT(!response.empty());

This is a familiar problem with other models such as Hermes 2 Pro Mistral 7B and even Llama 3 (prior to the upstream fix), see also #2167.

This works around the problem by printing the tokens instead of rendering them as blanks, which recently became possible with the special argument to llama_token_to_piece. We should also fix the bugs that cause empty tokens to crash/hang GPT4All, as there's nothing strictly preventing tokenToString from returning an empty string, but this should get us by for now.

Hermes 2 Pro Mistral 7B generates garbage after its response with this change since it was never trained on generations past the EOS token it tries to output, but at least you can stop the generation instead of having to restart GPT4All due to the hang.


The changelog is not merged yet, but the entry for this PR should be under "Fixed" and read:

- Fix crash/hang when certain models finish generation by printing special tokens in output ([#2701](https://github.com/nomic-ai/gpt4all/pull/2701))

Signed-off-by: Jared Van Bortel <jared@nomic.ai>
@cebtenzzre cebtenzzre requested a review from manyoso July 19, 2024 23:06
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.

None yet

2 participants