question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

BERT Issues with run_squad.py

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5

github_iconTop GitHub Comments

6reactions
benbatlcommented, May 31, 2019

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

0reactions
LAnastasiiacommented, Jan 15, 2020

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)

Read more comments on GitHub >

github_iconTop Results From Across the Web

BERT: run_squad.py falling over after eval · Issue #891
I'm having an issue fine-tuning BERT with run.squad.py, as it falls over at the end of the evaluation stage. I'm fine tuning on...
Read more >
How to run 'run_squad.py' on google colab? It gives 'invalid ...
SOLVED: It was giving error because I was downloading the github link rather than the script in github. Once I copied and used...
Read more >
Examples — transformers 2.8.0 documentation
Based on the script run_tf_glue.py . Fine-tuning the library TensorFlow 2.0 Bert model for sequence classification on the MRPC task of the GLUE...
Read more >
AI Challenge - SQuAD 1.1 with BERT-Base Guidelines
This processing is implemented and documented in run_squad.py. 1.2 Running SQuAD 1.1 fine tuning and inference. 1.2.1 Using Docker ...
Read more >
Visualizing attention zones in machine reading ...
Our experiments are carried out under the Python 3.7.3 environment, ... Download the BERT-base-cased pre-trained language model.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found