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
69ed3606
Unverified
Commit
69ed3606
authored
Jan 13, 2021
by
Suraj Patil
Committed by
GitHub
Jan 13, 2021
Browse files
fix BlenderbotSmallTokenizer (#9538)
* add model_input_names * fix test
parent
2df34f4a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
4 deletions
+1
-4
src/transformers/models/blenderbot_small/tokenization_blenderbot_small.py
.../models/blenderbot_small/tokenization_blenderbot_small.py
+1
-0
tests/test_modeling_blenderbot_small.py
tests/test_modeling_blenderbot_small.py
+0
-4
No files found.
src/transformers/models/blenderbot_small/tokenization_blenderbot_small.py
View file @
69ed3606
...
@@ -92,6 +92,7 @@ class BlenderbotSmallTokenizer(PreTrainedTokenizer):
...
@@ -92,6 +92,7 @@ class BlenderbotSmallTokenizer(PreTrainedTokenizer):
},
},
}
}
max_model_input_sizes
=
{
"facebook/blenderbot_small-90M"
:
512
}
max_model_input_sizes
=
{
"facebook/blenderbot_small-90M"
:
512
}
model_input_names
=
[
"attention_mask"
]
def
__init__
(
def
__init__
(
self
,
self
,
...
...
tests/test_modeling_blenderbot_small.py
View file @
69ed3606
...
@@ -288,8 +288,6 @@ class Blenderbot90MIntegrationTests(unittest.TestCase):
...
@@ -288,8 +288,6 @@ class Blenderbot90MIntegrationTests(unittest.TestCase):
model_inputs
=
self
.
tokenizer
(
src_text
,
return_tensors
=
"pt"
).
to
(
torch_device
)
model_inputs
=
self
.
tokenizer
(
src_text
,
return_tensors
=
"pt"
).
to
(
torch_device
)
# model does not have "token_type_ids"
model_inputs
.
pop
(
"token_type_ids"
)
assert
isinstance
(
self
.
tokenizer
,
BlenderbotSmallTokenizer
)
assert
isinstance
(
self
.
tokenizer
,
BlenderbotSmallTokenizer
)
generated_ids
=
self
.
model
.
generate
(
**
model_inputs
)[
0
]
generated_ids
=
self
.
model
.
generate
(
**
model_inputs
)[
0
]
reply
=
self
.
tokenizer
.
decode
(
generated_ids
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
True
)
reply
=
self
.
tokenizer
.
decode
(
generated_ids
,
skip_special_tokens
=
True
,
clean_up_tokenization_spaces
=
True
)
...
@@ -302,8 +300,6 @@ class Blenderbot90MIntegrationTests(unittest.TestCase):
...
@@ -302,8 +300,6 @@ class Blenderbot90MIntegrationTests(unittest.TestCase):
def
test_90_generation_from_short_input
(
self
):
def
test_90_generation_from_short_input
(
self
):
model_inputs
=
self
.
tokenizer
([
"sam"
],
return_tensors
=
"pt"
).
to
(
torch_device
)
model_inputs
=
self
.
tokenizer
([
"sam"
],
return_tensors
=
"pt"
).
to
(
torch_device
)
# model does not have "token_type_ids"
model_inputs
.
pop
(
"token_type_ids"
)
generated_utterances
=
self
.
model
.
generate
(
**
model_inputs
)
generated_utterances
=
self
.
model
.
generate
(
**
model_inputs
)
clean_txt
=
self
.
tokenizer
.
decode
(
clean_txt
=
self
.
tokenizer
.
decode
(
...
...
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