From e5f2d9122c73db985e34beaa1c80fef98be99510 Mon Sep 17 00:00:00 2001 From: thomwolf Date: Thu, 14 Mar 2019 09:55:01 +0100 Subject: [PATCH 1/2] adding absolute imports to gpt2, openai and transfo-xl --- pytorch_pretrained_bert/modeling_gpt2.py | 2 ++ pytorch_pretrained_bert/modeling_openai.py | 2 ++ pytorch_pretrained_bert/modeling_transfo_xl.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/pytorch_pretrained_bert/modeling_gpt2.py b/pytorch_pretrained_bert/modeling_gpt2.py index 69bd088a4e..c381b288f8 100644 --- a/pytorch_pretrained_bert/modeling_gpt2.py +++ b/pytorch_pretrained_bert/modeling_gpt2.py @@ -15,6 +15,8 @@ # limitations under the License. """PyTorch OpenAI GPT-2 model.""" +from __future__ import absolute_import, division, print_function, unicode_literals + import collections import copy import json diff --git a/pytorch_pretrained_bert/modeling_openai.py b/pytorch_pretrained_bert/modeling_openai.py index d73ee66f50..296abbfc31 100644 --- a/pytorch_pretrained_bert/modeling_openai.py +++ b/pytorch_pretrained_bert/modeling_openai.py @@ -15,6 +15,8 @@ # limitations under the License. """PyTorch OpenAI GPT model.""" +from __future__ import absolute_import, division, print_function, unicode_literals + import collections import copy import json diff --git a/pytorch_pretrained_bert/modeling_transfo_xl.py b/pytorch_pretrained_bert/modeling_transfo_xl.py index b225316f3d..ac895a03a7 100644 --- a/pytorch_pretrained_bert/modeling_transfo_xl.py +++ b/pytorch_pretrained_bert/modeling_transfo_xl.py @@ -18,6 +18,8 @@ In particular https://github.com/kimiyoung/transformer-xl/blob/master/pytorch/mem_transformer.py """ +from __future__ import absolute_import, division, print_function, unicode_literals + import os import copy import json From a98dfe4cedc53ededb05a10e688034a68c4843c4 Mon Sep 17 00:00:00 2001 From: thomwolf Date: Thu, 14 Mar 2019 09:57:06 +0100 Subject: [PATCH 2/2] fixing #377 (empty nbest_predictions.json) --- examples/run_squad.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/run_squad.py b/examples/run_squad.py index a29362ffb9..783c5f530e 100644 --- a/examples/run_squad.py +++ b/examples/run_squad.py @@ -620,7 +620,7 @@ def write_predictions(all_examples, all_features, all_results, n_best_size, all_predictions[example.qas_id] = "" else: all_predictions[example.qas_id] = best_non_null_entry.text - all_nbest_json[example.qas_id] = nbest_json + all_nbest_json[example.qas_id] = nbest_json with open(output_prediction_file, "w") as writer: writer.write(json.dumps(all_predictions, indent=4) + "\n")