Skip to content

Commit f53e514

Browse files
committed
revert and simplify
1 parent ed3428a commit f53e514

File tree

2 files changed

+5
-19
lines changed

2 files changed

+5
-19
lines changed

tokenizers/src/tokenizer/added_vocabulary.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,17 +216,14 @@ impl AddedVocabulary {
216216
}
217217

218218
/// Get the token matching the given id if it exists
219-
#[deprecated(
220-
since = "0.19.0",
221-
note = "please use `added_vocabulary.simple_id_to_token(id).or_else(|| model.id_to_token(id)` instead"
222-
)]
223219
pub fn id_to_token(&self, id: u32, model: &impl Model) -> Option<String> {
224220
self.added_tokens_map_r
225221
.get(&id)
226222
.map(|t| t.content.clone())
227223
.or_else(|| model.id_to_token(id))
228224
}
229225

226+
//
230227
pub fn simple_id_to_token(&self, id: u32) -> Option<String> {
231228
self.added_tokens_map_r.get(&id).map(|t| t.content.clone())
232229
}

tokenizers/src/tokenizer/mod.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -851,24 +851,13 @@ where
851851
.iter()
852852
.filter_map(|id| {
853853
self.added_vocabulary
854-
.simple_id_to_token(*id)
855-
.and_then(|token| {
856-
if skip_special_tokens && self.added_vocabulary.is_special_token(&token) {
857-
None
858-
} else if let Some(pre_tok) = &self.pre_tokenizer {
859-
let mut string = PreTokenizedString::from(token);
860-
pre_tok.pre_tokenize(&mut string);
861-
println!("Pre-tok String: {}", string.original);
862-
Some(string.original)
863-
} else {
864-
println!("String: {}", token);
865-
Some(token)
866-
}
854+
.id_to_token(*id, &self.model)
855+
.filter(|token| {
856+
!skip_special_tokens || !self.added_vocabulary.is_special_token(token)
867857
})
868-
.or_else(|| self.model.id_to_token(*id))
869858
})
870859
.collect::<Vec<_>>();
871-
println!("This should print: {:?}", tokens);
860+
872861
if let Some(decoder) = &self.decoder {
873862
decoder.decode(tokens)
874863
} else {

0 commit comments

Comments
 (0)