Readable token streaming support#397
Merged
Merged
Conversation
greshilov
force-pushed
the
readable-streaming-fixed
branch
from
January 30, 2024 10:54
dc24155 to
1ae8852
Compare
Contributor
Author
|
@microsoft-github-policy-service agree company="JetBrains" |
mrwyattii
approved these changes
Jan 31, 2024
Contributor
|
This is amazing! Thank you for the contribution @greshilov |
2 tasks
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.
Hey folks,
Thank you for this amazing library! :)
I waited a bit for #311 to resolve, but eventually decided to help complete it.
The original @jeffra's commit is cherry-picked, so the commit history stays valid!
Description
While testing the original PR, I stumbled upon several issues:
It trimmed redundant spaces (
the examplebecomesthe example), because it was based on the space splittingIt sometimes replaced more characters than needed (if the previous token was found multiple times in the current token, like
an anchorbecomesan chor)It didn't work properly when more than two tokens are required to decode the symbol
For example, with
tiiuae/falcon-7btokenizer,例如becomes�如(the first symbol is a UnicodeREPLACEMENT CHARACTER)My approach is slightly different then used before.
Two consequent tokens are always stored in the form of a token_ids sequence. The idea is to find the difference between previous and (previous + current) token decode results:
I added unit tests for the
ReadableStreamfor all supported models + one sanity test checking consistency between regular inference and streaming inference.Should address: #306, #281, #347