Skip to content

Commit

Permalink
replaced concatenation to f-strings to improve readability and unify … (
Browse files Browse the repository at this point in the history
#29785)

replaced concatenation to f-strings to improve readability and unify with the rest code
  • Loading branch information
igeni authored and Ita Zaporozhets committed May 14, 2024
1 parent 170682f commit db1a761
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/transformers/tokenization_utils_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -3668,7 +3668,7 @@ def truncate_sequences(
ids = ids[ids_to_move:]
pair_ids = pair_ids[pair_ids_to_move:] if pair_ids is not None else None
else:
raise ValueError("invalid truncation strategy:" + str(self.truncation_side))
raise ValueError(f"invalid truncation strategy:{self.truncation_side}")

elif truncation_strategy == TruncationStrategy.ONLY_SECOND and pair_ids is not None:
if len(pair_ids) > num_tokens_to_remove:
Expand All @@ -3680,7 +3680,7 @@ def truncate_sequences(
overflowing_tokens = pair_ids[:window_len]
pair_ids = pair_ids[num_tokens_to_remove:]
else:
raise ValueError("invalid truncation strategy:" + str(self.truncation_side))
raise ValueError(f"invalid truncation strategy:{self.truncation_side}")
else:
logger.error(
f"We need to remove {num_tokens_to_remove} to truncate the input "
Expand Down Expand Up @@ -3764,7 +3764,7 @@ def _pad(
encoded_inputs["special_tokens_mask"] = [1] * difference + encoded_inputs["special_tokens_mask"]
encoded_inputs[self.model_input_names[0]] = [self.pad_token_id] * difference + required_input
else:
raise ValueError("Invalid padding strategy:" + str(self.padding_side))
raise ValueError(f"Invalid padding strategy:{self.padding_side}")

return encoded_inputs

Expand Down

0 comments on commit db1a761

Please sign in to comment.