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
72402d1a
Commit
72402d1a
authored
Sep 24, 2019
by
LysandreJik
Browse files
Fixed DistilBERT tokenizer
parent
d340e232
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
9 deletions
+4
-9
pytorch_transformers/tests/tokenization_distilbert_test.py
pytorch_transformers/tests/tokenization_distilbert_test.py
+4
-2
pytorch_transformers/tokenization_distilbert.py
pytorch_transformers/tokenization_distilbert.py
+0
-7
No files found.
pytorch_transformers/tests/tokenization_distilbert_test.py
View file @
72402d1a
...
@@ -39,8 +39,10 @@ class DistilBertTokenizationTest(BertTokenizationTest):
...
@@ -39,8 +39,10 @@ class DistilBertTokenizationTest(BertTokenizationTest):
encoded_sentence
=
tokenizer
.
add_special_tokens_single_sequence
(
text
)
encoded_sentence
=
tokenizer
.
add_special_tokens_single_sequence
(
text
)
encoded_pair
=
tokenizer
.
add_special_tokens_sequence_pair
(
text
,
text_2
)
encoded_pair
=
tokenizer
.
add_special_tokens_sequence_pair
(
text
,
text_2
)
assert
encoded_sentence
==
text
assert
encoded_sentence
==
[
tokenizer
.
cls_token_id
]
+
text
+
[
tokenizer
.
sep_token_id
]
assert
encoded_pair
==
text
+
[
102
]
+
text_2
assert
encoded_pair
==
[
tokenizer
.
cls_token_id
]
+
text
+
[
tokenizer
.
sep_token_id
]
+
\
text_2
+
[
tokenizer
.
sep_token_id
]
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
pytorch_transformers/tokenization_distilbert.py
View file @
72402d1a
...
@@ -60,10 +60,3 @@ class DistilBertTokenizer(BertTokenizer):
...
@@ -60,10 +60,3 @@ class DistilBertTokenizer(BertTokenizer):
vocab_files_names
=
VOCAB_FILES_NAMES
vocab_files_names
=
VOCAB_FILES_NAMES
pretrained_vocab_files_map
=
PRETRAINED_VOCAB_FILES_MAP
pretrained_vocab_files_map
=
PRETRAINED_VOCAB_FILES_MAP
max_model_input_sizes
=
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
max_model_input_sizes
=
PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES
def
add_special_tokens_single_sequence
(
self
,
token_ids
):
return
token_ids
def
add_special_tokens_sequence_pair
(
self
,
token_ids_0
,
token_ids_1
):
sep
=
[
self
.
sep_token_id
]
return
token_ids_0
+
sep
+
token_ids_1
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