mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
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
This commit is contained in:
parent
34e07f4ba8
commit
884b2215c3
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user