Preserve list type of additional_special_tokens in special_token_map (#12759)
* preserve type of `additional_special_tokens` in `special_token_map` * format * Update src/transformers/tokenization_utils_base.py Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Co-authored-by: Sylvain Gugger <35901082+sgugger@users.noreply.github.com>
This commit is contained in:
@@ -1192,7 +1192,11 @@ class SpecialTokensMixin:
|
||||
for attr in self.SPECIAL_TOKENS_ATTRIBUTES:
|
||||
attr_value = getattr(self, "_" + attr)
|
||||
if attr_value:
|
||||
set_attr[attr] = str(attr_value)
|
||||
set_attr[attr] = (
|
||||
type(attr_value)(str(attr_value_sub) for attr_value_sub in attr_value)
|
||||
if isinstance(attr_value, (list, tuple))
|
||||
else str(attr_value)
|
||||
)
|
||||
return set_attr
|
||||
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user