今天在使用transformers加载allenai/led-base-16384的时候,出现了下面的错误:
File "/home/eric/anaconda3/envs/sent/lib/python3.7/site-packages/transformers/models/led/modeling_led.py", line 204, in forward
query_vectors, key_vectors, self.one_sided_attn_window_size
File "/home/eric/anaconda3/envs/sent/lib/python3.7/site-packages/transformers/models/led/modeling_led.py", line 465, in _sliding_chunks_query_key_matmul
chunks_count = torch.div(seq_len, window_overlap, rounding_mode="trunc") - 1
TypeError: div() got an unexpected keyword argument 'rounding_mode'
我的transformers的版本是4.2.4
python版本是3.7
torch版本是1.7
搜了一下发现是我的torch版本太低,最低需要1.8
解决方法
升级1.7版本到1.8版本
pip install torch==1.8
参考文献
TypeError: div() got an unexpected keyword argument ‘rounding_mode’