File tree Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Expand file tree Collapse file tree 2 files changed +5
-19
lines changed Original file line number Diff line number Diff line change @@ -216,17 +216,14 @@ impl AddedVocabulary {
216
216
}
217
217
218
218
/// 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
- ) ]
223
219
pub fn id_to_token ( & self , id : u32 , model : & impl Model ) -> Option < String > {
224
220
self . added_tokens_map_r
225
221
. get ( & id)
226
222
. map ( |t| t. content . clone ( ) )
227
223
. or_else ( || model. id_to_token ( id) )
228
224
}
229
225
226
+ //
230
227
pub fn simple_id_to_token ( & self , id : u32 ) -> Option < String > {
231
228
self . added_tokens_map_r . get ( & id) . map ( |t| t. content . clone ( ) )
232
229
}
Original file line number Diff line number Diff line change @@ -851,24 +851,13 @@ where
851
851
. iter ( )
852
852
. filter_map ( |id| {
853
853
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)
867
857
} )
868
- . or_else ( || self . model . id_to_token ( * id) )
869
858
} )
870
859
. collect :: < Vec < _ > > ( ) ;
871
- println ! ( "This should print: {:?}" , tokens ) ;
860
+
872
861
if let Some ( decoder) = & self . decoder {
873
862
decoder. decode ( tokens)
874
863
} else {
You can’t perform that action at this time.
0 commit comments