I am trying to run the run_ner.py example described here: (https://huggingface.co/transformers/examples.html#named-entity-recognition)
When running the example I get the following exception:
I1217 09:36:10.744300 14416 file_utils.py:40] PyTorch version 1.3.1 available.
W1217 09:36:11.329299 14416 run_ner.py:422] Process rank: -1, device: cuda, n_gpu: 1, distributed training: False, 16-bits training: False
I1217 09:36:11.863193 14416 configuration_utils.py:160] loading configuration file https://s3.amazonaws.com/models.huggingface.co/bert/bert_base_uncased/config.json from cache at s3_cache\67674340071d93960fbc3eb74cf1d0b51de232689bfc75d63e3f4ab1c9a052f9
Traceback (most recent call last):
File ".\run_ner.py", line 531, in <module>
main()
File ".\run_ner.py", line 441, in main
cache_dir=args.cache_dir if args.cache_dir else None)
File "C:\Program Files\Python\Python37\lib\site-packages\transformers\configuration_utils.py", line 163, in from_pretrained
config = cls.from_json_file(resolved_config_file)
File "C:\Program Files\Python\Python37\lib\site-packages\transformers\configuration_utils.py", line 196, in from_json_file
return cls.from_dict(json.loads(text))
File "C:\Program Files\Python\Python37\lib\json\__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "C:\Program Files\Python\Python37\lib\json\decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "C:\Program Files\Python\Python37\lib\json\decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
A JSON files does not seemed to be found. Can someone tell me which file this is?
A few questions (the ones asked in the issue templates...):
transformers are you using?Hi,
sorry, my bad.
I am calling run_ner.py with
python .\run_ner.py --data_dir ./ --model_type bert --labels .\labels.txt --model_name_or_path bert_base_uncased --output_dir pytorch_ner --max_seq_length 75 --n
um_train_epochs 5 --per_gpu_train_batch_size 12 --save_steps 750 --seed 4711 --do_train --do_eval --do_predict --cache_dir s3_cache
I am using transformers 2.2.2
The JSON file the Python script is trying to use is the configuration of BERT model (config.json)?
I am trying to run the run_ner.py example described here: (https://huggingface.co/transformers/examples.html#named-entity-recognition)
When running the example I get the following exception:
I1217 09:36:10.744300 14416 file_utils.py:40] PyTorch version 1.3.1 available. W1217 09:36:11.329299 14416 run_ner.py:422] Process rank: -1, device: cuda, n_gpu: 1, distributed training: False, 16-bits training: False I1217 09:36:11.863193 14416 configuration_utils.py:160] loading configuration file https://s3.amazonaws.com/models.huggingface.co/bert/bert_base_uncased/config.json from cache at s3_cache\67674340071d93960fbc3eb74cf1d0b51de232689bfc75d63e3f4ab1c9a052f9 Traceback (most recent call last): File ".\run_ner.py", line 531, in <module> main() File ".\run_ner.py", line 441, in main cache_dir=args.cache_dir if args.cache_dir else None) File "C:\Program Files\Python\Python37\lib\site-packages\transformers\configuration_utils.py", line 163, in from_pretrained config = cls.from_json_file(resolved_config_file) File "C:\Program Files\Python\Python37\lib\site-packages\transformers\configuration_utils.py", line 196, in from_json_file return cls.from_dict(json.loads(text)) File "C:\Program Files\Python\Python37\lib\json\__init__.py", line 348, in loads return _default_decoder.decode(s) File "C:\Program Files\Python\Python37\lib\json\decoder.py", line 337, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Program Files\Python\Python37\lib\json\decoder.py", line 355, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)A JSON files does not seemed to be found. Can someone tell me which file this is?
Do I have to retrieve the file from somewhere ? I assumed everything is retrieved automatically by the script?
Reminds me of this isse: https://github.com/huggingface/transformers/issues/2154
Well, the bert_base_uncased for the model_name_or_path option is not correct. Just use: bert-base-uncased :)
Yes, the bert_base_uncased should be bert-base-uncased.
I've improved these error messages on the master with #2164 by the way, it should be more explicit now that the configuration file can't be found.
@Horsmann Additionally, if you want to use an uncased model, make sure that you pass --do_lower_case to the run_ner.py script!
Thanks! It is working now. The exception looked like I am missing a file so I didn't checked for the model name.
Most helpful comment
@Horsmann Additionally, if you want to use an uncased model, make sure that you pass
--do_lower_caseto therun_ner.pyscript!