From 501040fd30b526758ee38787bff74e6b7796d5a1 Mon Sep 17 00:00:00 2001 From: Hong Xu Date: Tue, 30 Jun 2020 16:45:35 -0700 Subject: [PATCH] In the run_ner.py example, give the optional label arg a default value (#5326) Otherwise, if label is not specified, the following error occurs: Traceback (most recent call last): File "run_ner.py", line 303, in main() File "run_ner.py", line 101, in main model_args, data_args, training_args = parser.parse_json_file(json_file=os.path.abspath(sys.argv[1])) File "/home/user/anaconda3/envs/bert/lib/python3.7/site-packages/transformers/hf_argparser.py", line 159, in parse_json_file obj = dtype(**inputs) TypeError: __init__() missing 1 required positional argument: 'labels' --- examples/token-classification/run_ner.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/token-classification/run_ner.py b/examples/token-classification/run_ner.py index a5698f5838..6cc2a5c9aa 100644 --- a/examples/token-classification/run_ner.py +++ b/examples/token-classification/run_ner.py @@ -75,7 +75,8 @@ class DataTrainingArguments: metadata={"help": "The input data dir. Should contain the .txt files for a CoNLL-2003-formatted task."} ) labels: Optional[str] = field( - metadata={"help": "Path to a file containing all labels. If not specified, CoNLL-2003 labels are used."} + default=None, + metadata={"help": "Path to a file containing all labels. If not specified, CoNLL-2003 labels are used."}, ) max_seq_length: int = field( default=128,