You need to sign in or sign up before continuing.
Commit 2e6797cc authored by danai-antoniou's avatar danai-antoniou
Browse files

Added valuerror for duplicate added tokens

parent 0d1dad6d
...@@ -503,6 +503,9 @@ class PreTrainedTokenizer(object): ...@@ -503,6 +503,9 @@ class PreTrainedTokenizer(object):
if not new_tokens: if not new_tokens:
return 0 return 0
if len(new_tokens) != len(set(new_tokens)):
raise ValueError("The provided list of tokens contains duplicates.")
to_add_tokens = [] to_add_tokens = []
for token in new_tokens: for token in new_tokens:
assert isinstance(token, str) or (six.PY2 and isinstance(token, unicode)) assert isinstance(token, str) or (six.PY2 and isinstance(token, unicode))
......
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