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
65ee1a43
Unverified
Commit
65ee1a43
authored
Sep 13, 2021
by
Nicolas Patry
Committed by
GitHub
Sep 13, 2021
Browse files
fixing BC in `fill-mask` (wasn't tested in theses test suites (#13540)
apparently).
parent
9d60eebe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
src/transformers/pipelines/fill_mask.py
src/transformers/pipelines/fill_mask.py
+4
-1
tests/test_pipelines_fill_mask.py
tests/test_pipelines_fill_mask.py
+12
-0
No files found.
src/transformers/pipelines/fill_mask.py
View file @
65ee1a43
...
...
@@ -219,4 +219,7 @@ class FillMaskPipeline(Pipeline):
- **token** (:obj:`int`) -- The predicted token id (to replace the masked one).
- **token** (:obj:`str`) -- The predicted token (to replace the masked one).
"""
return
super
().
__call__
(
inputs
,
**
kwargs
)
outputs
=
super
().
__call__
(
inputs
,
**
kwargs
)
if
isinstance
(
inputs
,
list
)
and
len
(
inputs
)
==
1
:
return
outputs
[
0
]
return
outputs
tests/test_pipelines_fill_mask.py
View file @
65ee1a43
...
...
@@ -186,6 +186,18 @@ class FillMaskPipelineTests(unittest.TestCase, metaclass=PipelineTestCaseMeta):
],
)
outputs
=
fill_masker
([
f
"This is a
{
tokenizer
.
mask_token
}
"
])
self
.
assertEqual
(
outputs
,
[
{
"sequence"
:
ANY
(
str
),
"score"
:
ANY
(
float
),
"token"
:
ANY
(
int
),
"token_str"
:
ANY
(
str
)},
{
"sequence"
:
ANY
(
str
),
"score"
:
ANY
(
float
),
"token"
:
ANY
(
int
),
"token_str"
:
ANY
(
str
)},
{
"sequence"
:
ANY
(
str
),
"score"
:
ANY
(
float
),
"token"
:
ANY
(
int
),
"token_str"
:
ANY
(
str
)},
{
"sequence"
:
ANY
(
str
),
"score"
:
ANY
(
float
),
"token"
:
ANY
(
int
),
"token_str"
:
ANY
(
str
)},
{
"sequence"
:
ANY
(
str
),
"score"
:
ANY
(
float
),
"token"
:
ANY
(
int
),
"token_str"
:
ANY
(
str
)},
],
)
outputs
=
fill_masker
([
f
"This is a
{
tokenizer
.
mask_token
}
"
,
f
"Another
{
tokenizer
.
mask_token
}
great test."
])
self
.
assertEqual
(
outputs
,
...
...
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