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

Add warning for stop string edge case #33169

Merged
merged 2 commits into from
Aug 30, 2024
Merged

Add warning for stop string edge case #33169

merged 2 commits into from
Aug 30, 2024

Conversation

Rocketknight1
Copy link
Member

In #31435 @murray-z mentions that the stop string code can throw an error with an unusual stop string: "✿RESULT✿"

The underlying cause is that the ✿ token doesn't exist in the tokenizer vocabulary anywhere. The tokenizer in question has a special-case fallback for unknown characters where it builds them out of other tokens, but the tokens it uses to compose unknown characters have different meanings when considered alone. This means that the stop string code can't figure out how to build the stop string out of the tokenizer vocabulary, because it doesn't have access to the internal special-casing logic.

I can't really see a general solution here without completely rewriting the stop string code to run tokenizer.decode() at each generation step, which would break the ability to compile generation or export it to non-Python environments. Since it's a fairly rare edge case, though, I'm just going to add a proper error message instead!

cc @LysandreJik

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

Copy link
Member

@LysandreJik LysandreJik left a comment

Choose a reason for hiding this comment

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

Makes sense, LGTM! Thanks @Rocketknight1

@Rocketknight1 Rocketknight1 merged commit fbff276 into main Aug 30, 2024
22 checks passed
@Rocketknight1 Rocketknight1 deleted the stop_string_warning branch August 30, 2024 15:26
BernardZach pushed a commit to BernardZach/transformers that referenced this pull request Dec 5, 2024
* Add warning for edge case

* make fixup
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.

3 participants