Bert: BERT Issues with run_squad.py

Created on 25 Apr 2019  路  5Comments  路  Source: google-research/bert

Hello!
I was trying to run the SQuAD 1.1 example (run_squad.py)
I followed the instructions from README.md in Google BERT GitHub repository.

My configuration code is the following:

export BERT_BASE_DIR="$/mnt/c/Users/MyUsername/bert/multi_cased_L-12_H-768_A-12"
export SQUAD_DIR="$/mnt/c/Users/MyUsername/bert/squad"
python -u run_squad.py \
   --vocab_file=$BERT_BASE_DIR/vocab.txt \
   --bert_config_file=$BERT_BASE_DIR/bert_config.json \
   --init_checkpoint=$BERT_BASE_DIR/bert_model.ckpt \
   --do_train=True \
   --train_file=$SQUAD_DIR/train-v1.1.json \
   --do_predict=True \
   --predict_file=$SQUAD_DIR/dev-v1.1.json \
   --train_batch_size=12 \
   --learning_rate=3e-5 \
   --num_train_epochs=2.0 \
   --max_seq_length=384 \
   --doc_stride=128 \
   --version_2_with_negative True \
   --output_dir=/tmp/squad_base/

And then I got this:

Traceback (most recent call last):
  File "run_squad.py", line 1283, in <module>
    tf.app.run()
  File "/home/MyUsername/.local/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 125, in run
    _sys.exit(main(argv))
  File "run_squad.py", line 1129, in main
    bert_config = modeling.BertConfig.from_json_file(FLAGS.bert_config_file)
  File "/mnt/c/Users/MyUsername/bert/modeling.py", line 93, in from_json_file
    text = reader.read()
  File "/home/MyUsername/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 125, in read
    self._preread_check()
  File "/home/MyUsername/.local/lib/python2.7/site-packages/tensorflow/python/lib/io/file_io.py", line 85, in _preread_check
    compat.as_bytes(self.__name), 1024 * 512, status)
  File "/home/MyUsername/.local/lib/python2.7/site-packages/tensorflow/python/framework/errors_impl.py", line 528, in __exit__
    c_api.TF_GetCode(self.status.status))
/bert_config.json; No such file or directoryoundError: $/mnt/c/Users/MyUsername/bert/multi_cased_L-12_H-768_A-12

Files in "multi_cased_L-12_H-768_A-12" folder :

.../MyUsername/bert/multi_cased_L-12_H-768_A-12$/bert/multi_cased_L-12_H-768_A-12$ ls
bert_config.json  bert_model.ckpt.data-00000-of-00001  bert_model.ckpt.index  bert_model.ckpt.meta  vocab.txt

What am I doing wrong? Can someone help me?
Thank you in advance.

All 5 comments

Remove the '$' from your paths:

export BERT_BASE_DIR="/mnt/c/Users/MyUsername/bert/multi_cased_L-12_H-768_A-12"
export SQUAD_DIR="/mnt/c/Users/MyUsername/bert/squad"

bert_config.json should be in the same folder as run_squad.py. Resolved!

there is no bert_config.json,should I create a new one?

bert_config.json should be in the same folder as run_squad.py. Resolved!

hi,I hava the same problem.Where can I find bert_config.json file?please tell me,thank u in advance.

Hi @MrChenJianhui
bert_config.json file is included in the archive with pre-trained models. You can download it from Google AI official repo. (e.g. https://storage.googleapis.com/bert_models/2018_11_23/multi_cased_L-12_H-768_A-12.zip)

Was this page helpful?
0 / 5 - 0 ratings