Skip to content

Commit

Permalink
styling
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurZucker committed Jun 10, 2024
1 parent 0a16ca0 commit 35d442d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions tokenizers/src/models/wordlevel/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,17 @@ impl WordLevelBuilder {
}

#[derive(PartialEq, Clone, Eq, Display)]
#[display(fmt = "vocab={{{}, ...}}, unk_token={}", "vocab.iter().take(5).fold(String::new(), |mut acc, (key, value)| {
#[display(
fmt = "vocab={{{}, ...}}, unk_token={}",
"vocab.iter().take(5).fold(String::new(), |mut acc, (key, value)| {
if !acc.is_empty() {
acc.push_str(\", \");
}
acc.push_str(&format!(\"\'{}\': {}\", key, value));
acc
})", unk_token)]
})",
unk_token
)]
pub struct WordLevel {
vocab: HashMap<String, u32>,
vocab_r: HashMap<u32, String>,
Expand Down
10 changes: 9 additions & 1 deletion tokenizers/src/utils/padding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ impl std::convert::AsRef<str> for PaddingDirection {
}

#[derive(Debug, Clone, Serialize, Deserialize, Display)]
#[display(fmt="strategy={}, direction={}, pad_to_multiple_of={}, pad_id={}, pad_type_id={}, pad_token={}", strategy, direction, "pad_to_multiple_of.unwrap()", pad_id, pad_type_id, pad_token)]
#[display(
fmt = "strategy={}, direction={}, pad_to_multiple_of={}, pad_id={}, pad_type_id={}, pad_token={}",
strategy,
direction,
"pad_to_multiple_of.unwrap()",
pad_id,
pad_type_id,
pad_token
)]
pub struct PaddingParams {
pub strategy: PaddingStrategy,
pub direction: PaddingDirection,
Expand Down
2 changes: 1 addition & 1 deletion tokenizers/src/utils/truncation.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::tokenizer::{Encoding, Result};
use display_derive::StructDisplay;
use derive_more::Display;
use display_derive::StructDisplay;
use serde::{Deserialize, Serialize};
use std::cmp;
use std::mem;
Expand Down

0 comments on commit 35d442d

Please sign in to comment.