我首先使用以下方法下载了该文件:
!curl -L -O https://github.com/huggingface/transformers/blob/master/examples/legacy/question-answering/run_squad.py然后使用以下代码:
!python run_squad.py \
--model_type bert \
--model_name_or_path bert-base-uncased \
--output_dir models/bert/ \
--data_dir data/squad \
--overwrite_output_dir \
--overwrite_cache \
--do_train \
--train_file /content/train.json \
--version_2_with_negative \
--do_lower_case \
--do_eval \
--predict_file /content/val.json \
--per_gpu_train_batch_size 2 \
--learning_rate 3e-5 \
--num_train_epochs 2.0 \
--max_seq_length 384 \
--doc_stride 128 \
--threads 10 \
--save_steps 5000 还尝试了以下几点:
!python run_squad.py \
--model_type bert \
--model_name_or_path bert-base-cased \
--do_train \
--do_eval \
--do_lower_case \
--train_file /content/train.json \
--predict_file /content/val.json \
--per_gpu_train_batch_size 12 \
--learning_rate 3e-5 \
--num_train_epochs 2.0 \
--max_seq_length 584 \
--doc_stride 128 \
--output_dir /content/这两个代码中都显示了错误:
文件"run_squad.py",第7行^ SyntaxError:无效语法
究竟是什么问题?如何运行.py文件?
发布于 2021-07-30 13:50:48
解决:这是错误的,因为我下载的是github链接,而不是github中的脚本。一旦我复制并使用“原始”链接下载脚本,代码就会运行。
https://stackoverflow.com/questions/68589222
复制相似问题