Onion12138 / CasRelPyTorch

Reimplement CasRel model in PyTorch.使用PyTorch对吉林大学CasRel模型进行复现,并在百度关系抽取数据集上训练测试。
180 stars 26 forks source link

Notice

This repository is no longer maintained. If any issues, check by yourself.

CasRel Model Pytorch reimplement 3

The code is the PyTorch reimplement of the paper "A Novel Cascade Binary Tagging Framework for Relational Triple Extraction" ACL2020. The official code was written in keras.

I have encountered a lot of troubles with the keras version, so I decided to rewrite the code in PyTorch.

Introduction

I followed the previous work of longlongman and JuliaSun623.

So I have to express sincere thanks to them.

I made some changes in order to better apply to the Chinese Dataset. The changes I have made are listed:

The data are in form of json. Take one as an example:

{
    "text": "陶喆的一首《好好说再见》推荐给大家,希望你们能够喜欢",
    "spo_list": [
        {
            "predicate": "歌手",
            "object_type": "人物",
            "subject_type": "歌曲",
            "object": "陶喆",
            "subject": "好好说再见"
        }
    ]
}

In fact the field object_type and subject_type are not used.

If you have your own data, you can organize your data in the same format.

Usage

python run.py

I have already set the default value of the model, but you can still set your own configuration in model/config.py

Results

The best F1 score on test data is 0.78 with a precision of 0.80 and recall of 0.76.

It is to my expectation although it may not reach its utmost.

I have also trained the SpERT model, and CasRel turns out to perform better. More experiments need to be carried out since there are slight differences in both criterion and datasets.

Experiences