From 29e4597950e9de8cc32321e4286f1a61894b46d4 Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Fri, 11 Dec 2020 16:26:05 -0500 Subject: [PATCH] Fix min_null_pred in the run_qa script (#9067) --- examples/question-answering/utils_qa.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/examples/question-answering/utils_qa.py b/examples/question-answering/utils_qa.py index 13dda6da3c..c26d37f9db 100644 --- a/examples/question-answering/utils_qa.py +++ b/examples/question-answering/utils_qa.py @@ -76,9 +76,7 @@ def postprocess_qa_predictions( assert len(predictions) == 2, "`predictions` should be a tuple with two elements (start_logits, end_logits)." all_start_logits, all_end_logits = predictions - assert len(predictions[0]) == len( - features - ), f"Got {len(predictions[0])} predicitions and {len(features)} features." + assert len(predictions[0]) == len(features), f"Got {len(predictions[0])} predictions and {len(features)} features." # Build a map example to its corresponding features. example_id_to_index = {k: i for i, k in enumerate(examples["id"])} @@ -118,7 +116,7 @@ def postprocess_qa_predictions( # Update minimum null prediction. 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 = { "offsets": (0, 0), "score": feature_null_score,