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
cbad90d8
Unverified
Commit
cbad90d8
authored
Oct 26, 2020
by
Lysandre Debut
Committed by
GitHub
Oct 26, 2020
Browse files
Fix + Test (#8049)
parent
664c7ec4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
src/transformers/tokenization_blenderbot.py
src/transformers/tokenization_blenderbot.py
+3
-0
tests/test_tokenization_blenderbot.py
tests/test_tokenization_blenderbot.py
+9
-0
No files found.
src/transformers/tokenization_blenderbot.py
View file @
cbad90d8
...
@@ -166,6 +166,9 @@ class BlenderbotSmallTokenizer(PreTrainedTokenizer):
...
@@ -166,6 +166,9 @@ class BlenderbotSmallTokenizer(PreTrainedTokenizer):
tokens
=
token
.
split
(
" "
)
tokens
=
token
.
split
(
" "
)
words
=
[]
words
=
[]
for
token
in
tokens
:
for
token
in
tokens
:
if
not
len
(
token
):
continue
token
=
token
.
lower
()
token
=
token
.
lower
()
word
=
tuple
(
token
)
word
=
tuple
(
token
)
word
=
tuple
(
list
(
word
[:
-
1
])
+
[
word
[
-
1
]
+
"</w>"
])
word
=
tuple
(
list
(
word
[:
-
1
])
+
[
word
[
-
1
]
+
"</w>"
])
...
...
tests/test_tokenization_blenderbot.py
View file @
cbad90d8
...
@@ -75,6 +75,15 @@ class BlenderbotSmallTokenizerTest(TokenizerTesterMixin, unittest.TestCase):
...
@@ -75,6 +75,15 @@ class BlenderbotSmallTokenizerTest(TokenizerTesterMixin, unittest.TestCase):
assert
src_text
!=
decoded
# I wish it did!
assert
src_text
!=
decoded
# I wish it did!
assert
decoded
==
"i am a small frog ."
assert
decoded
==
"i am a small frog ."
def
test_empty_word_small_tok
(
self
):
tok
=
BlenderbotSmallTokenizer
.
from_pretrained
(
"facebook/blenderbot-90M"
)
src_text
=
"I am a small frog ."
src_text_dot
=
"."
encoded
=
tok
(
src_text
)[
"input_ids"
]
encoded_dot
=
tok
(
src_text_dot
)[
"input_ids"
]
assert
encoded
[
-
1
]
==
encoded_dot
[
0
]
class
Blenderbot3BTokenizerTests
(
unittest
.
TestCase
):
class
Blenderbot3BTokenizerTests
(
unittest
.
TestCase
):
@
cached_property
@
cached_property
...
...
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