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
835b76a4
Unverified
Commit
835b76a4
authored
Dec 26, 2019
by
Anthony MOI
Browse files
Handle unk_token
As we discussed, this is handled here directly cc @thomwolf
parent
7ead04ce
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
src/transformers/tokenization_utils.py
src/transformers/tokenization_utils.py
+4
-1
No files found.
src/transformers/tokenization_utils.py
View file @
835b76a4
...
...
@@ -1508,7 +1508,10 @@ class PreTrainedTokenizerFast(PreTrainedTokenizer):
return
self
.
tokenizer
.
encode
(
text
).
tokens
def
_convert_token_to_id_with_added_voc
(
self
,
token
):
return
self
.
tokenizer
.
token_to_id
(
token
)
id
=
self
.
tokenizer
.
token_to_id
(
token
)
if
id
is
None
:
return
self
.
unk_token_id
return
id
def
_convert_id_to_token
(
self
,
index
):
return
self
.
tokenizer
.
id_to_token
(
int
(
index
))
...
...
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