More clear error message in the use-case of #5169 (#5184)

This commit is contained in:
Thomas Wolf 2020-06-23 13:37:29 +02:00 committed by GitHub
parent 11fdde0271
commit b28b537131
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -427,9 +427,14 @@ class PreTrainedTokenizer(PreTrainedTokenizerBase):
elif isinstance(text, (list, tuple)) and len(text) > 0 and isinstance(text[0], int):
return text
else:
raise ValueError(
f"Input {text} is not valid. Should be a string, a list/tuple of strings or a list/tuple of integers."
)
if is_pretokenized:
raise ValueError(
f"Input {text} is not valid. Should be a string or a list/tuple of strings when `is_pretokenized=True`."
)
else:
raise ValueError(
f"Input {text} is not valid. Should be a string, a list/tuple of strings or a list/tuple of integers."
)
if return_offsets_mapping:
raise NotImplementedError(