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
6e61e060
Commit
6e61e060
authored
Dec 09, 2019
by
Morgan Funtowicz
Browse files
batch_encode_plus generates the encoder_attention_mask to avoid attending over padded values.
parent
02110485
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
transformers/pipelines.py
transformers/pipelines.py
+5
-2
No files found.
transformers/pipelines.py
View file @
6e61e060
...
@@ -132,7 +132,7 @@ class QuestionAnsweringPipeline(Pipeline):
...
@@ -132,7 +132,7 @@ class QuestionAnsweringPipeline(Pipeline):
# Tabular input
# Tabular input
if
'question'
in
kwargs
and
'context'
in
kwargs
:
if
'question'
in
kwargs
and
'context'
in
kwargs
:
texts
=
QuestionAnsweringPipeline
.
create_sample
(
kwargs
[
'question
s
'
],
kwargs
[
'context
s
'
])
texts
=
QuestionAnsweringPipeline
.
create_sample
(
kwargs
[
'question'
],
kwargs
[
'context'
])
elif
'data'
in
kwargs
:
elif
'data'
in
kwargs
:
texts
=
kwargs
[
'data'
]
texts
=
kwargs
[
'data'
]
# Generic compatibility with sklearn and Keras
# Generic compatibility with sklearn and Keras
...
@@ -156,7 +156,10 @@ class QuestionAnsweringPipeline(Pipeline):
...
@@ -156,7 +156,10 @@ class QuestionAnsweringPipeline(Pipeline):
)
)
# Remove special_tokens_mask to avoid KeyError
# Remove special_tokens_mask to avoid KeyError
_
=
inputs
.
pop
(
'special_tokens_mask'
)
special_tokens_mask
,
input_len
=
inputs
.
pop
(
'special_tokens_mask'
),
inputs
.
pop
(
'input_len'
)
# TODO : Harmonize model arguments across all model
inputs
[
'attention_mask'
]
=
inputs
.
pop
(
'encoder_attention_mask'
)
# if is_tf_available():
# if is_tf_available():
if
False
:
if
False
:
...
...
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