KG-BERT BERT for Knowledge Graph Completion

原文 https://arxiv.org/pdf/1909.03193.pdf

一.背景补充

知识图谱普遍存在不完备的问题。以上图为例,黑色的箭头表示已经存在的关系,红色的虚线则是缺失的关系。知识图谱补全是基于图谱里已有的关系去推理出缺失的关系。由于BERT在NLP取得的成绩,作者将其迁移到知识图谱补全的应用上。

二.结构

作者设计了两种训练方式的KG - BERT, 可以运用到不同的知识图谱补全任务当中。

2.1 Illustrations of fine-tuning KG-BERT for predicting the plausibility of a triple

输入由三部分组成,HeadHeadRelationRelationTailTail。举个例子,HeadHead可以是“Steven Paul Jobs was an American business magnate,entrepreneur and investor.” 或者“Steve Jobs”,RelationRelation可以是“founded”,TailTail可以是“Apple Inc. is an American multinational technology company headquartered in Cupertino, California.”或者“Apple Inc.”。用[SEP][SEP]分隔实体和关系。输入为3个向量的sum,即token, segment 和position embeddings。对于segment,实体的segment Embedding为eAeA,而关系的segment Embedding为eBeB。对于position ,相同position的不同token使用相同的position embedding。

对于输入的三元组τ=(h,r,t)τ=(h,r,t),目标函数为:

Sτ=f(h,r,t)=sigmoid(CWT)SτR2,Sτ0,Sτ1[0,1]Sτ=f(h,r,t)=sigmoid(CWT)SτR2,Sτ0,Sτ1[0,1]

损失函数是SSyy的交叉熵:

L=τD+D(yτlog(Sτ0)+(1yτlog(Sτ1)))L=τD+D(yτlog(Sτ0)+(1yτlog(Sτ1)))

其中yτ{0,1}yτ{0,1}是标签。

关于负样本的构造,作者是将正样本的HeadHead或者TailTail变成随机替换成别的,如下

D={(h,r,t)|hEhh(h,r,t)D+}{(h,r,t)|tEtt(h,r,t)D+}D={(h,r,t)|hEhh(h,r,t)D+}{(h,r,t)|tEtt(h,r,t)D+}

其中EE为实体的集合。

2.2 Illustrations of fine-tuning KG-BERT for predicting the relation between two entities

作者发现直接使用两个实体去预测关系,效果优于使用两个实体和一个随机关系(这里本人认为一个随机的关系本来就是错误特征,感觉肯定会影响预测结果)。这里和2.1结构的差异在于:1.输入从实体加关系的三输入变成基于实体的双输入2.输出从二分类变成多分类

目标函数为:

Sτ=f(h,r,t)=softmax(CWT)Sτ=f(h,r,t)=softmax(CWT)

损失函数为SSyy的交叉熵:

L=τD+Ri=1yτilog(sτi)L=τD+Ri=1yτilog(sτi)

三.实验

setting: We choose pre-trained BERT-Base model with 12 layers, 12 self-attention heads and H = 768 as the initialization of KG-BERT, then fine tune KG-BERT with Adam implemented in BERT.

参考

https://github.com/yao8839836/kg-bert

https://zhuanlan.zhihu.com/p/355391327


和你们这些少爷不同,我们光是活着就竭尽全力了。

From《银魂》

Provider-风亦扬