Skip to content

Commit

Permalink
Merge pull request #282 from wlhgtc/master
Browse files Browse the repository at this point in the history
Fix some bug about SQuAD code
  • Loading branch information
thomwolf authored Feb 15, 2019
2 parents 0e774e5 + 8efaf8f commit 5faf386
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/run_squad.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,13 @@ def write_predictions(all_examples, all_features, all_results, n_best_size,
text="",
start_logit=null_start_logit,
end_logit=null_end_logit))

# In very rare edge cases we could only have single null prediction.
# So we just create a nonce prediction in this case to avoid failure.
if len(nbest)==1:
nbest.insert(0,
_NbestPrediction(text="empty", start_logit=0.0, end_logit=0.0))

# In very rare edge cases we could have no valid predictions. So we
# just create a nonce prediction in this case to avoid failure.
if not nbest:
Expand Down

0 comments on commit 5faf386

Please sign in to comment.