Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
f5c0fa9f
Unverified
Commit
f5c0fa9f
authored
Jun 06, 2024
by
Zhiyuan Chen
Committed by
GitHub
Jun 06, 2024
Browse files
fix loading special_tokens_map_file (#31012)
parent
9b85e405
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
src/transformers/tokenization_utils_base.py
src/transformers/tokenization_utils_base.py
+5
-2
No files found.
src/transformers/tokenization_utils_base.py
View file @
f5c0fa9f
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment