当前位置:   article > 正文

已解决:KeyError ‘attention_mask‘_the attention mask and the pad token id were not s

the attention mask and the pad token id were not set. as a consequence, you

已解决:KeyError: ‘attention_mask’

调用bert模型预训练时报错KeyError: ‘attention_mask’
已知是transformers与tokenizers的版本号不匹配,导致attention_mask丢失
可使用 pip show 包查看对应版本号
Name: transformers
Version: 2.8.0
Summary: State-of-the-art Natural Language Processing for TensorFlow 2.0 and PyTorch
Home-page: https://github.com/huggingface/transformers
Author: Thomas Wolf, Lysandre Debut, Victor Sanh, Julien Chaumond, Google AI Language Team Authors, Open AI team Authors, Facebook AI Authors, Carnegie Mellon University Authors
Author-email: thomas@huggingface.co
License: Apache
Location: c:\programdata\anaconda3\envs\win_torch\lib\site-packages
Requires: sacremoses, regex, requests, tqdm, numpy, sentencepiece, boto3
Required-by:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
Name: tokenizers
Version: 0.5.2
Summary: Fast and Customizable Tokenizers
Home-page: https://github.com/huggingface/tokenizers
Author: Anthony MOI
Author-email: anthony@huggingface.co
License: Apache License 2.0
Location: c:\programdata\anaconda3\envs\win_torch\lib\site-packages
Requires:
Required-by: transformers
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

目前已知 transformers=2.8.0,tokenizers=0.5.2,或 transformers=3.4.0,tokenizers=0.9.2

可以解决此问题

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/AllinToyou/article/detail/311456
推荐阅读
相关标签
  

闽ICP备14008679号