当前位置:   article > 正文

Ditto环境配置问题( Deep Entity Matching with Pre-Trained Language Models)_ditto配置

ditto配置

论文项目在GitHub - megagonlabs/ditto: Code for the paper "Deep Entity Matching with Pre-trained Language Models"

首先配置requirements.txt文件中提到的环境:

gensim==3.8.1
numpy==1.19.2
regex==2019.12.20
scipy==1.3.2
sentencepiece==0.1.85
sklearn==0.0
spacy==3.1
torch==1.9.0+cu111
transformers==4.9.2
tqdm==4.41.0
jsonlines==1.2.0
nltk==3.5

其中除了torch==1.9.0+cu111要根据自己机器的CUDA版本安装,其他均可pip install或者conda install配置。

 在conda命令行中输入如下命令安装自然语言处理工具spacy:

  1. #conda config --add channels conda-forge
  2. conda install spacy
  3. python -m spacy download en

执行下面命令配置NVIDIA Apex

conda install -c conda-forge nvidia-apex 

执行下面命令下载en_core_web_lg

python -m spacy download en_core_web_lg

这一步可能会报错:ModuleNotFoundError: No module named ‘en_core_web_lg,此时需要我们手动下载en_core_web_lg安装,进入官网English · spaCy Models Documentation,下载对应文件。(en_core_web_sm同理下载安装)

拖拽进指定文件夹执行命令安装,示例:

pip install path\to\en_core_web_md-3.7.1-py3-none-any.whl

参考:pip安装en_core_web_lg(解决ModuleNotFoundError: No module named ‘en_core_web_lg报错问题)-CSDN博客

python如何安装本地的.whl文件_python本地安装whl-CSDN博客

上述过程配置好了文件里要求的环境,执行下面命令可以尝试运行ditto。

python train_ditto.py

运行过程可能会产生的报错:

一、AttributeError: module ‘nltk‘ has no attribute ‘stopwords‘

解决方法:手动下载,创建一个.py文件或者进入python命令行

  1. import nltk
  2. nltk.download()

在命令行进入“Corpora”,找到‘stopwords‘下载即可。

参考:

AttributeError: module ‘nltk‘ has no attribute ‘download‘的可能解决办法_attributeerror: partially initialized module 'nltk-CSDN博客

Resource punkt not found. Please use the NLTK Downloader to obtain the resource错误解决方案-CSDN博客

二、使用apex的过程中报错ImportError: cannot import name ‘container_abcs‘ from ‘torch._six‘

在1.8版本之后container_abcs就已经被移除了。所以导入方式不同会出现这样的错误:cannot import name ‘container_abcs’ from ‘torch._six’
因此使用不同版本的torch会出现不同问题。
1.8以下版本使用 from torch._six import container_abcs;
1.8以上版本使用import collections.abc as container_abcs

解决方法:从报错地址中到出错代码

  1. if TORCH_MAJOR == 0:
  2. import collections.abc as container_abcs
  3. else:
  4. from torch._six import container_abcs

 把上面代码替换成

  1. if TORCH_MAJOR == 1 and TORCH_MINOR < 8:
  2. from torch._six import container_abcs
  3. else:
  4. import collections.abc as container_abcs

参考:

关于升级pytorch1.9后出现cannot import name ‘container_abcs‘ from ‘torch._six‘错误的解决方法-CSDN博客

ImportError: cannot import name ‘container_abcs‘ from ‘torch._six‘_cannot import name 'container_abcs' from 'torch._s-CSDN博客

三、Connection error, and we cannot find the requested files in the cached path. Please try again or make sure your Internet connection is on.

可能是由于 HuggingFace Transformers 库版本过时造成的。

pip install --upgrade transformers

四、OSError: We couldn't connect to 'https://huggingface.co' to load this file, couldn't find it in the cached files and it looks like THUDM/chatglm-6b is not the path to a directory containing a file named configuration_chatglm.py.Checkout your internet connection or see how to run the library in offline mode at  'https://huggingface.co/docs/transformers/installation#offline-mode

方法一:因为网络的无法连接到 https://huggingface.co   然后提示我们有离线模式,找到我们需要的文件并一个一个的下载,最后手动添加到文件中

参考:

从服务器上直接下载huggingface模型,解决huggingface无法连接问题_failed to connect to huggingface.co port 443-CSDN博客

OSError: We couldn‘t connect to ‘https://huggingface.co‘ to load this file_checkout your internet connection or see how to ru-CSDN博客

huggingface 模型下载与离线加载 - 知乎

方法二(更推荐):使用镜像网站加载huggingface模型。

运行前执行下面代码,从下面这个镜像网站加载模型。

export HF_ENDPOINT=https://hf-mirror.com

参考:

HF-Mirror - Huggingface 镜像站

Huggingface镜像站,飞速下载,再也不担心网络问题! - 知乎

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

闽ICP备14008679号