Skip to content

Commit

Permalink
rename modeled token_to_id
Browse files Browse the repository at this point in the history
rename modeled `token_to_id` into `token_to_id_model`
  • Loading branch information
chris-ha458 committed Oct 27, 2023
1 parent c718c53 commit 0c94da5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions tokenizers/src/tokenizer/added_vocabulary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl AddedVocabulary {
}

/// Get the id matching one of our token if it exists
pub fn token_to_id(&self, token: &str, model: &impl Model) -> Option<u32> {
pub fn token_to_id_model(&self, token: &str, model: &impl Model) -> Option<u32> {
self.added_tokens_map
.get(token)
.copied()
Expand Down Expand Up @@ -256,7 +256,7 @@ impl AddedVocabulary {
continue;
}
// If a token is already part of the vocabulary, we mark it as added
let new_id = if let Some(new_id) = self.token_to_id(&token.content, model) {
let new_id = if let Some(new_id) = self.token_to_id_model(&token.content, model) {
new_id
} else {
self.added_tokens_map.values().cloned().max().map_or(
Expand Down Expand Up @@ -307,7 +307,7 @@ impl AddedVocabulary {
.map(|token| {
(
token,
self.token_to_id(&token.content, model)
self.token_to_id_model(&token.content, model)
.expect("Missing additional token"),
)
})
Expand Down
2 changes: 1 addition & 1 deletion tokenizers/src/tokenizer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ where

/// Converts a token in the corresponding id.
pub fn token_to_id(&self, token: &str) -> Option<u32> {
self.added_vocabulary.token_to_id(token, &self.model)
self.added_vocabulary.token_to_id_model(token, &self.model)
}

/// Converts an id to the corresponding token.
Expand Down

0 comments on commit 0c94da5

Please sign in to comment.