Skip to content

Commit 45ace28

Browse files
fix: better handling of truncation to avoid warning
1 parent ab58e26 commit 45ace28

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • torchTextClassifiers/tokenizers

torchTextClassifiers/tokenizers/base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ def tokenize(
124124

125125
# Pad to longest sequence if no output_dim is specified
126126
padding = True if self.output_dim is None else "max_length"
127+
truncation = True if self.output_dim is not None else False
127128

128129
tokenize_output = self.tokenizer(
129130
text,
130131
padding=padding,
131132
return_tensors="pt",
132-
truncation=True,
133+
truncation=truncation,
133134
max_length=self.output_dim,
134135
return_offsets_mapping=return_offsets_mapping,
135136
) # method from PreTrainedTokenizerFast

0 commit comments

Comments
 (0)