Learning Span-Level Interactions for Aspect Sentiment Triplet Extraction 复现

论文地址:https://aclanthology.org/2021.acl-long.367.pdf
论文代码:https://github.com/wireless911/span-aste
论文讲解:https://blog.csdn.net/qq_36234441/article/details/119791326

1.创建环境(如有需要)

conda create -n SpanASTE python=3.8.0

进入到环境中:

conda activate SpanASTE

2.下载pytoch(1.8.1)的gpu版本

安装pytorch:https://pytorch.org
历史版本pytorch下载:https://pytorch.org/get-started/previous-versions/

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html

3.下载数据集:

xuuuluuu/SemEval-Triplet-data: Aspect Sentiment Triplet Extraction (ASTE) dataset in AAAI 2020, EMNLP 2020 and ACL 2021. (github.com)
通过下载可以得到文件夹: ASTE-Data-V2-EMNLP2020
在这里插入图片描述
当前项目新建文件夹data, 将下载得到的文件夹ASTE-Data-V2-EMNLP2020放入到data下面
在这里插入图片描述

4.下载Glove词向量表示文件glove.42B.300d.txt(大小4.68GB)

点击: stanfordnlp/GloVe: GloVe model for distributed word representation (github.com)
找到glove.42B.300d.zip下载即可在这里插入图片描述

5.将下载得到的glove.42B.300d.txt放入到项目中

例如我创建一个文件夹corpus将glove.42B.300d.txt复制则第一个参数为: corpus/glove.42B.300d.txt
那么我将convert.py中的代码改为

(count, dimensions) = glove2word2vec("corpus/glove.42B.300d.txt", "corpus/42B_w2v.txt")

在这里插入图片描述

6.运行convert.py文件

报错:

ModuleNotFoundError: No module named 'gensim'

解决方法:

pip install gensim==4.1.2
继续运行convert.py 运行结束之后会生成一个corpus/42B_w2v.txt文件

7.train.py修改参数

由于我们刚刚将目标路径设置为corpus/42B_w2v.txt
将代码

parser.add_argument("-w", "--glove_word2vector", required=True, type=str,default="vector_cache/42B_w2v.txt",
help="the glove word2vector file path")

改为:

parser.add_argument("-w", "--glove_word2vector", required=True, type=str, default="corpus/42B_w2v.txt",
help="the glove word2vector file path")

继续运行train.py文件

8.报错pydantic:

ModuleNotFoundError: No module named 'pydantic'

解决方法:

pip install pydantic

安装成功之后继续运行:

9.报错tensorboard:

ModuleNotFoundError: No module named 'tensorboard'

解决方法:

pip install tensorboard==2.7.0

10.报错:

train.py: error: the following arguments are required: -w/--glove_word2vector, -d/--dataset, -o/--output_path

解决方法:

参考博客:https://blog.csdn.net/qq_45056135/article/details/123991879

第一步复制:

--glove_word2vector "corpus/42B_w2v.txt" --dataset "data/ASTE-Data-V2-EMNLP2020/15res/" --output_path "output"

第二步: 打开Run---->Edit Configurations…

如图所示
在这里插入图片描述
选择对应好的需要设置train.py将刚刚复制好的参数和默认值黏贴点击ok结束

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-406FK1MH-1651203507930)(C:\Users\74538\AppData\Roaming\Typora\typora-user-images\image-20220428223406737.png)]
设置完成之后继续运行train.py文件

11报错:

FileNotFoundError: [Errno 2] No such file or directory: 'output/checkpoint_epoch_0.pkl'

出错原因:

缺少一个存放项目模型目录的文件output

解决方法:

在当前项目中创建一个output文件夹即可
在这里插入图片描述

12.成功运行train.py文件

运行结果:

在这里插入图片描述

  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值