-
-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Bugfix] Fix Incremental Detokenization with tokenizers == 0.22.0
#24159
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
Changes from all commits
4adf155
f3dadb9
f8dbaf6
095f441
c447eab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -234,7 +234,7 @@ def _protected_step(self, next_token_id: int) -> Optional[str]: | |
| try: | ||
| token = self.stream.step(self.tokenizer, next_token_id) | ||
| except Exception as e: | ||
| if str(e) != INVALID_PREFIX_ERR_MSG: | ||
| if not str(e).startswith(INVALID_PREFIX_ERR_MSG): | ||
| raise e | ||
| # Recover from edge case where tokenizer can produce non-monotonic, | ||
| # invalid UTF-8 output, which breaks the internal state of | ||
|
|
@@ -243,7 +243,8 @@ def _protected_step(self, next_token_id: int) -> Optional[str]: | |
| logger.warning( | ||
| "Encountered invalid prefix detokenization error" | ||
| " for request %s, resetting decode stream.", self.request_id) | ||
| self.stream = DecodeStream(self.skip_special_tokens) | ||
| self.stream = DecodeStream( | ||
| skip_special_tokens=self.skip_special_tokens) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this change necessary?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, as can be seen from: https://github.com/huggingface/tokenizers/pull/1856/files#diff-780be0b9b76e7260ed2be2249d17c4a879b7e2e98e9f30f26dc9c65501f775d1R672. Otherwise, we would get an error that ids should not be Boolean type. |
||
| token = self.stream.step(self.tokenizer, next_token_id) | ||
| return token | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.