Bidirectional Machine Reading Comprehension for Aspect Sentiment Triplet Extraction 复现

论文地址(AAAI 2021):https://arxiv.org/pdf/2103.07665.pdf
论文代码:https://github.com/NKU-IIPLab/BMRC
论文讲解:https://blog.csdn.net/jst100/article/details/124293263

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

1.1根据readme.md文件创建环境:

conda create -n BMRC python=3.6.9

进入到环境中:

conda activate BMRC

1.2.下载pytoch(1.10.1)的gpu版本

readme.md文件1.2.0不同的是我这里是安装的是1.10.1的pytorch版本
安装pytorch:https://pytorch.org
历史版本pytorch下载:https://pytorch.org/get-started/previous-versions/

pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu113

下载transformers包

pip install transformers==2.9.0

2.下载数据集(注意是V1版本):

xuuuluuu/SemEval-Triplet-data: Aspect Sentiment Triplet Extraction (ASTE) dataset in AAAI 2020, EMNLP 2020 and ACL 2021. (github.com)
通过下载可以得到文件夹: ASTE-Data-V1-AAAI2020
在这里插入图片描述

当前项目新建文件夹data, 将下载得到的文件夹ASTE-Data-V1-AAAI2020重命名original放入到data下面
并且将14res,15res,16res都重命名为14rest, 15rest, 16rest, 就是后面加个t
如下图所示
在这里插入图片描述
为了统一格式把15rest_前面的东西也去掉
在这里插入图片描述
改完之后如图所示:
在这里插入图片描述

3.运行dataProcess.py

错误:

FileNotFoundError: [Errno 2] No such file or directory: './data/original/14rest/14rest_pair/train_pair.pkl'

原因: 因为不存在14rest_pair文件夹
解决:
找到数据集中的14rest下的文件14rest pair 重命名14rest_pair

4.运行makeData_dual.py

错误:

NameError: name 'if_tokenized' is not defined

解决:注释这两行
在这里插入图片描述

5.运行makeData_standard.py

错误:

NameError: name 'standard_list' is not defined

原因: (standard_list没有被定义)
解决:找到报错的位置,在for循环上面添加一个代码定义standard_list列表
在这里插入图片描述
到这里数据处理部分结束。正常情况下data/preprocess下有如下文件
在这里插入图片描述

6.运行main.py

6.1运行main.py

错误:

ModuleNotFoundError: No module named 'pytest'

原因:缺少测试包pytest
解决:安装pytest

pip install pytest

6.2运行main.py

报错百度一下说是54行test方法命名的问题
解决
test方法改为其他名字我这里改成cheshi
其他之前调用这个test方法的地方也要改462,570, 581行

6.3运行main.py

错误:

FileNotFoundError: [Errno 2] No such file or directory: '/home/xxx/workspace/BMRC-main/log/14lap_1.log'

原因:没有存放日志的文件夹
解决:在当前项目文件夹下创建文件夹log
在这里插入图片描述

6.4运行main.py

错误:运行1epoch之后出现

FileNotFoundError: [Errno 2] No such file or directory: './model/14lap_1.pth'

原因:没有存放模型的文件夹
解决:在项目当前路径中在新建一个model文件夹用于保存模型
在这里插入图片描述
再次运行main.py即可正常运行代码

7.运行结果:

在这里插入图片描述
本人自用笔记,水平有限,如果错误欢迎大家指正交流

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值