Unverified Commit f5c0fa9f authored by Zhiyuan Chen's avatar Zhiyuan Chen Committed by GitHub
Browse files

fix loading special_tokens_map_file (#31012)

parent 9b85e405
...@@ -2285,11 +2285,14 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin): ...@@ -2285,11 +2285,14 @@ class PreTrainedTokenizerBase(SpecialTokensMixin, PushToHubMixin):
# We keep this new value and ignore the one stored in the special_tokens_map_file # We keep this new value and ignore the one stored in the special_tokens_map_file
continue continue
if isinstance(value, dict): if isinstance(value, dict):
value = AddedToken(**value, special=True) value["special"] = True
value = AddedToken(**value)
elif key == "additional_special_tokens" and isinstance(value, list): elif key == "additional_special_tokens" and isinstance(value, list):
additional_special_tokens = init_kwargs.pop("additional_special_tokens", []) or [] additional_special_tokens = init_kwargs.pop("additional_special_tokens", []) or []
for token in value: for token in value:
token = AddedToken(**token, special=True) if isinstance(token, dict) else token if isinstance(token, dict):
token["special"] = True
token = AddedToken(**token)
if token not in additional_special_tokens: if token not in additional_special_tokens:
additional_special_tokens.append(token) additional_special_tokens.append(token)
value = additional_special_tokens value = additional_special_tokens
......
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