深度学习 / 自然语言 · 6月 13, 2022 0

解决add_code_sample_docstrings() got an unexpected keyword argument ‘qa_target_start_index’

内容纲要
/opt/conda/lib/python3.7/site-packages/transformers/utils/import_utils.py in __getattr__(self, name)
    845 
    846     # Needed for autocompletion in an IDE
--> 847     def __dir__(self):
    848         result = super().__dir__()
    849         # The elements of self.__all__ that are submodules may or may not be in the dir already, depending on whether

/opt/conda/lib/python3.7/site-packages/transformers/utils/import_utils.py in _get_module(self, module_name)
    859         if name in self._modules:
    860             value = self._get_module(name)
--> 861         elif name in self._class_to_module.keys():
    862             module = self._get_module(self._class_to_module[name])
    863             value = getattr(module, name)

RuntimeError: Failed to import transformers.models.bert.modeling_bert because of the following error (look up to see its traceback):
add_code_sample_docstrings() got an unexpected keyword argument 'qa_target_start_index'

原因出在transformers库在较新版本中删除了此文档字符串。
1) 使用transformers指定的版本
2) 手动删除 doc 字符串。

参考链接
https://github.com/HKUNLP/UnifiedSKG/issues/16#issuecomment-1102949121

%d 博主赞过: