# PRGC

PRGC: Potential Relation and Global Correspondence Based Joint Relational Triple Extraction

先抽实体再进行关系分类，一般存在误差传递的问题

所以这篇论文采取联合抽取的方式（但其实哪种方法更好也不绝对）

方法有：百度的三元组融入序列标注，苏神的半指针，转化成QA的形式

这篇论文是基于指针的

![image-20220222225904485](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-54768b83577fbd115be44277580e1587c1a29a06%2Fimage-20220222225904485.png?alt=media)

![image-20220222230010227](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-08e6031f75ba7ac1436bab1b1f956abe5d9c48ef%2Fimage-20220222230010227.png?alt=media)

![image-20220222230127855](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-fed0f1f68e4b09df18edbba1335328c38c68cf0b%2Fimage-20220222230127855.png?alt=media)

![image-20220222230139664](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-431a85abc4fc7440abb83af2bb4df12389c98963%2Fimage-20220222230139664.png?alt=media)

第一个：

![image-20220222230205064](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-b176d94511de0cd6c9f500f0363b72252cf9ab5b%2Fimage-20220222230205064.png?alt=media)

先做个分类（多分类任务），如果没有关系，后面的步骤就不需要了

文本有多个关系，会拆成多段文本，再输入预测

![image-20220222230401653](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-99e5830402ee36653bb2384ab963c2586afb6d9c%2Fimage-20220222230401653.png?alt=media)

第二个：

![image-20220222230422117](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-1390c5a6e8813d48e8447230d1cc622f48acdc26%2Fimage-20220222230422117.png?alt=media)

第三个：

![image-20220222230518842](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-d51332557dd91bad5babc43c894a47a402ff86f4%2Fimage-20220222230518842.png?alt=media)

字之间是否存在关系

![image-20220222230552696](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-8e736c002e5d800a4c24d06c47c0aaf3a5637122%2Fimage-20220222230552696.png?alt=media)

这里是变成了一维再拼接，显存消耗大

![image-20220222230735945](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-8757a27fce3c87b58f7a72e8877aa8d3a60b34a1%2Fimage-20220222230735945.png?alt=media)

训练代码

![image-20220222230755024](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-56cda7f0931ecfcc3d26abf77b14e910b94711bf%2Fimage-20220222230755024.png?alt=media)

![image-20220222230855663](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-76704c927b2663c8fb209f57d793278218607505%2Fimage-20220222230855663.png?alt=media)

主客体的序列标注

![image-20220222230927719](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-c219954efa6d4b81943d8899fc70482ffda802d8%2Fimage-20220222230927719.png?alt=media)

损失

![image-20220222231023786](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-6b1888fc2bef5cf099ea07c36bce6cc1a725ced2%2Fimage-20220222231023786.png?alt=media)

预测

![image-20220222231031648](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-5dc3185c711c8ab41aecb9338863776b17399c3d%2Fimage-20220222231031648.png?alt=media)

![image-20220222231221536](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-d5f940e2984c6b10eb5b7dd7f22bf857c74a1140%2Fimage-20220222231221536.png?alt=media)

效果

![image-20220222231240932](https://2635718429-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MF66ktDIaNeQvkO0bzL%2Fuploads%2Fgit-blob-81ad092cd4d5ee362e08f78320dbc0ba9f4a4700%2Fimage-20220222231240932.png?alt=media)

### 参考资料

[【Whalepaper】NLP分享：PRGC](https://www.bilibili.com/video/BV1EU4y1T7Xe)
