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
29e45979
"...git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "9802b9340dd45ee133620dcd60c344423d2d7ae4"
Unverified
Commit
29e45979
authored
Dec 11, 2020
by
Sylvain Gugger
Committed by
GitHub
Dec 11, 2020
Browse files
Fix min_null_pred in the run_qa script (#9067)
parent
9cc9f412
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
4 deletions
+2
-4
examples/question-answering/utils_qa.py
examples/question-answering/utils_qa.py
+2
-4
No files found.
examples/question-answering/utils_qa.py
View file @
29e45979
...
@@ -76,9 +76,7 @@ def postprocess_qa_predictions(
...
@@ -76,9 +76,7 @@ def postprocess_qa_predictions(
assert
len
(
predictions
)
==
2
,
"`predictions` should be a tuple with two elements (start_logits, end_logits)."
assert
len
(
predictions
)
==
2
,
"`predictions` should be a tuple with two elements (start_logits, end_logits)."
all_start_logits
,
all_end_logits
=
predictions
all_start_logits
,
all_end_logits
=
predictions
assert
len
(
predictions
[
0
])
==
len
(
assert
len
(
predictions
[
0
])
==
len
(
features
),
f
"Got
{
len
(
predictions
[
0
])
}
predictions and
{
len
(
features
)
}
features."
features
),
f
"Got
{
len
(
predictions
[
0
])
}
predicitions and
{
len
(
features
)
}
features."
# Build a map example to its corresponding features.
# Build a map example to its corresponding features.
example_id_to_index
=
{
k
:
i
for
i
,
k
in
enumerate
(
examples
[
"id"
])}
example_id_to_index
=
{
k
:
i
for
i
,
k
in
enumerate
(
examples
[
"id"
])}
...
@@ -118,7 +116,7 @@ def postprocess_qa_predictions(
...
@@ -118,7 +116,7 @@ def postprocess_qa_predictions(
# Update minimum null prediction.
# Update minimum null prediction.
feature_null_score
=
start_logits
[
0
]
+
end_logits
[
0
]
feature_null_score
=
start_logits
[
0
]
+
end_logits
[
0
]
if
min_null_prediction
is
None
or
min_null_prediction
[
"score"
]
<
feature_null_score
:
if
min_null_prediction
is
None
or
min_null_prediction
[
"score"
]
>
feature_null_score
:
min_null_prediction
=
{
min_null_prediction
=
{
"offsets"
:
(
0
,
0
),
"offsets"
:
(
0
,
0
),
"score"
:
feature_null_score
,
"score"
:
feature_null_score
,
...
...
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