gpt4 book ai didi

nlp - 导入 Pytorch_Transformers 时找不到模块错误

转载 作者:行者123 更新时间:2023-12-04 16:01:22 28 4
gpt4 key购买 nike

通过 Anaconda 下载 pytorch_transformers 并通过 Jupyter Notebook 执行导入命令后,我面临几个与缺少模块相关的错误。

我尝试搜索 sacremoses 以通过 Anaconda 导入包,但它仅适用于 Linux 机器。有没有其他人遇到过类似的问题?提前致谢!
from pytorch_transformers import BertTokenizer, BertModel, BertForMaskedLM
这是错误:

<ipython-input-5-218d0858d00f> in <module>
----> 1 from pytorch_transformers import BertTokenizer, BertModel, BertForMaskedLM

~\Anaconda3\lib\site-packages\pytorch_transformers\__init__.py in <module>
1 __version__ = "1.2.0"
----> 2 from .tokenization_auto import AutoTokenizer
3 from .tokenization_bert import BertTokenizer, BasicTokenizer, WordpieceTokenizer
4 from .tokenization_openai import OpenAIGPTTokenizer
5 from .tokenization_transfo_xl import (TransfoXLTokenizer, TransfoXLCorpus)

~\Anaconda3\lib\site-packages\pytorch_transformers\tokenization_auto.py in <module>
24 from .tokenization_transfo_xl import TransfoXLTokenizer
25 from .tokenization_xlnet import XLNetTokenizer
---> 26 from .tokenization_xlm import XLMTokenizer
27 from .tokenization_roberta import RobertaTokenizer
28 from .tokenization_distilbert import DistilBertTokenizer

~\Anaconda3\lib\site-packages\pytorch_transformers\tokenization_xlm.py in <module>
25 from io import open
26
---> 27 import sacremoses as sm
28
29 from .tokenization_utils import PreTrainedTokenizer

ModuleNotFoundError: No module named 'sacremoses'```

最佳答案

请尝试使用以下步骤创建 conda 环境并在创建的环境中安装软件包:

conda create -n env_pytorch -c intel python=3.5
source activate env_pytorch
pip install pytorch-transformers
enter image description here

关于nlp - 导入 Pytorch_Transformers 时找不到模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58011563/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com