Unverified Commit 884b2215 authored by igeni's avatar igeni Committed by GitHub
Browse files

replaced concatenation to f-strings to improve readability and unify … (#29785)

replaced concatenation to f-strings to improve readability and unify with the rest code
parent 34e07f4b
......@@ -3657,7 +3657,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
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:
......@@ -3669,7 +3669,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
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 "
......@@ -3753,7 +3753,7 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment