Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
32d20314
Unverified
Commit
32d20314
authored
Jun 30, 2020
by
Sam Shleifer
Committed by
GitHub
Jun 30, 2020
Browse files
[fix] slow fill_mask test failure (#5406)
parent
80aa4b8a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
4 deletions
+5
-4
src/transformers/pipelines.py
src/transformers/pipelines.py
+1
-0
tests/test_pipelines.py
tests/test_pipelines.py
+4
-4
No files found.
src/transformers/pipelines.py
View file @
32d20314
...
...
@@ -827,6 +827,7 @@ class FillMaskPipeline(Pipeline):
values
,
predictions
=
topk
.
values
.
numpy
(),
topk
.
indices
.
numpy
()
else
:
masked_index
=
(
input_ids
==
self
.
tokenizer
.
mask_token_id
).
nonzero
().
item
()
logits
=
outputs
[
i
,
masked_index
,
:]
probs
=
logits
.
softmax
(
dim
=
0
)
values
,
predictions
=
probs
.
topk
(
self
.
topk
)
...
...
tests/test_pipelines.py
View file @
32d20314
...
...
@@ -31,12 +31,12 @@ TF_TRANSLATION_FINETUNED_MODELS = [("patrickvonplaten/t5-tiny-random", "translat
expected_fill_mask_result
=
[
[
{
"sequence"
:
"<s>
My name is
:
</s>"
,
"score"
:
0.00
9954338893294334
,
"token"
:
35
},
{
"sequence"
:
"<s>
My name is
John
</s>"
,
"score"
:
0.00
80940006300807
,
"token"
:
610
},
{
"sequence"
:
"<s>My name is
John
</s>"
,
"score"
:
0.00
782308354973793
,
"token"
:
610
,
"token_str"
:
"ĠJohn"
},
{
"sequence"
:
"<s>My name is
Chris
</s>"
,
"score"
:
0.00
7475061342120171
,
"token"
:
1573
,
"token_str"
:
"ĠChris"
},
],
[
{
"sequence"
:
"<s>
The largest city in France is Paris</s>"
,
"score"
:
0.3185044229030609
,
"token"
:
2201
},
{
"sequence"
:
"<s>
The largest city in France is Lyon</s>"
,
"score"
:
0.21112334728240967
,
"token"
:
12790
},
{
"sequence"
:
"<s>The largest city in France is Paris</s>"
,
"score"
:
0.3185044229030609
,
"token"
:
2201
},
{
"sequence"
:
"<s>The largest city in France is Lyon</s>"
,
"score"
:
0.21112334728240967
,
"token"
:
12790
},
],
]
SUMMARIZATION_KWARGS
=
dict
(
num_beams
=
2
,
min_length
=
2
,
max_length
=
5
)
...
...
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