Fixed Whitespace Error in Streaming mode - #423
Open
enochlev wants to merge 1 commit into
Open
Conversation
4 tasks
|
I confirm that this change fixes the issue. Thank you! |
|
I notice that LlamaTokenizer has an add_prefix_space option, which when active, will insert a space at the beginning of a string passed to encode, and trim a space from the first character of the output returned by decode. This behavior can be turned off by setting Doing so will allow spaces to be emitted in the streaming output. However I think this is an indication that Tokenizer.decode is not meant for decoding sub-sequences of emitted tokens from an output, and there might be other oddities with this usage. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a TensorRTLLM is deployed with streaming mode tokens have no white spaces in between streaming chunks.
Link to Issue
This is because calling tokenizer.decode does a whitespace strip of the output and this functionality cannot be disabled. So we must manually look for those white spaces and add.
The standard way of going about this is holding tokens in cache until a space is detected, in which everything after the space is put again into cache.
The other suggested method decodes the token_id text instead of the string text to look for a "_" symbol
This PR should be able to fix these issues