-
Notifications
You must be signed in to change notification settings - Fork 816
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 bytelevel normalizer to fix decode when adding tokens to BPE #1555
Conversation
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. |
tokenizers/src/tokenizer/mod.rs
Outdated
let tokens = ids | ||
.iter() | ||
.filter_map(|id| { | ||
self.added_vocabulary | ||
.id_to_token(*id, &self.model) | ||
.filter(|token| { | ||
!skip_special_tokens || !self.added_vocabulary.is_special_token(token) | ||
}) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
if let Some(decoder) = &self.decoder { | ||
decoder.decode(tokens) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reverted to what we originally had
The test passes locally ! |
/// Strip the normalized string inplace | ||
fn normalize(&self, normalized: &mut NormalizedString) -> Result<()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this live in NormalizedString
like so:
impl NormalizedString {
fn normalize_byte_level(&mut self) -> Result<()> { // ... }
}
?
Feels a bit weird to have an empty stateless struct for just a function, but may be due to the structure of tokenizers / python.
add it fix
Co-authored-by: Luc Georges <McPatate@users.noreply.github.com>
This revert the previous breaking change.
Also add a new
ByteLevel
normalizer, which replaces the ByteLevel pre_tokenizer.Checked that we can add chines / Cyrillic tokens which are properly encoded and decoder.
Fixes #1392