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

Tokenizer: fix issue when decoding a single token at a time #1559

Merged
merged 3 commits into from
Jul 8, 2024

Conversation

Andrei-Aksionov
Copy link
Collaborator

Hi there 👋

When I was working on Phi-3 integration I've spotted an issue with HF Tokenizer that if to decode a single token at time (like in chat script), then it drops all the spaces and the output looks like a single looooooong string (huggingface/transformers#31643).
So, instead of This is a test string the code prints Thisisateststring.

As was mentioned in the issue by @itazap, the problem happens with LlamaTokenizer and thus affects not only Phi-3, but other models too.

This PR applies the hack from Phi-3 to other models.

@Andrei-Aksionov Andrei-Aksionov marked this pull request as ready for review July 7, 2024 16:35
Copy link
Collaborator

@rasbt rasbt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@Andrei-Aksionov Andrei-Aksionov merged commit 7f75e01 into main Jul 8, 2024
9 checks passed
@Andrei-Aksionov Andrei-Aksionov deleted the tokenizer_single_token_decoding branch July 8, 2024 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants