We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e47442f commit 22b8932Copy full SHA for 22b8932
rust/src/lib.rs
@@ -81,12 +81,9 @@ impl TokenizerWrapper {
81
}
82
83
pub fn encode(&mut self, text: &str, add_special_tokens: bool) {
84
- self.encode_ids = Vec::from(
85
- self.tokenizer
86
- .encode(text, add_special_tokens)
87
- .unwrap()
88
- .get_ids(),
89
- );
+ let encoded = self.tokenizer.encode(text, add_special_tokens).unwrap();
+ self.encode_ids.resize(encoded.len(), 0);
+ self.encode_ids.copy_from_slice(encoded.get_ids());
90
91
92
pub fn decode(&mut self, ids: &[u32], skip_special_tokens: bool) {
0 commit comments