我正在尝试训练一个seq2seq模型。我在Colab中运行了示例代码:
!git clone https://github.com/huggingface/transformers!git clone https://github.com/huggingface/datasets!pip install transformers!pip install datasets
!python transformers/examples/seq2seq/run_seq2seq.py \ --model_name_or_path t5-small \ --do_train \ --do_eval \ --task summarization \ --dataset_name xsum \ --output_dir /tmp/tst-summarization \ --per_device_train_batch_size=4 \ --per_device_eval_batch_size=4 \ --overwrite_output_dir \ --predict_with_generate \ --max_train_samples 500 \ --max_val_samples 500
然后得到了这个错误
I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library libcudart.so.11.0Traceback (most recent call last): File "transformers/examples/seq2seq/run_seq2seq.py", line 47, in <module> from transformers.file_utils import is_offline_modeImportError: cannot import name 'is_offline_mode' from 'transformers.file_utils' (/usr/local/lib/python3.7/dist-packages/transformers/file_utils.py)
有什么建议吗?
回答:
问题在于你克隆了仓库的主分支,并尝试使用一个落后于该主分支的transformers版本(4.3.3)来运行run_seq2seq.py
脚本。
run_seq2seq.py
在3月6日被更新以导入is_offline_mode
,这是通过这个合并完成的。
你需要做的就是克隆用于你所使用的transformers版本的分支:
!git clone --branch v4.3.3-release https://github.com/huggingface/transformers
附注:我认为你不需要克隆数据集库。