mirror of
https://github.com/huggingface/transformers.git
synced 2025-07-31 02:02:21 +06:00
Check if text
is set to avoid IndexError (#4209)
Fix for https://github.com/huggingface/transformers/issues/3809
This commit is contained in:
parent
90f4b24520
commit
d2a7c86dc3
@ -236,7 +236,7 @@ class RobertaTokenizer(GPT2Tokenizer):
|
||||
add_prefix_space = kwargs["add_prefix_space"]
|
||||
else:
|
||||
add_prefix_space = add_special_tokens
|
||||
if add_prefix_space and not text[0].isspace():
|
||||
if add_prefix_space and len(text) > 0 and not text[0].isspace():
|
||||
text = " " + text
|
||||
return text
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user