论文浅尝 | Complex Embeddings for Simple Link Prediction

本文探讨了基于复数表示的ComplEx模型如何解决知识图谱中的链接预测问题,尤其在非对称关系上的优势。通过引入复数向量表示,ComplEx能更准确地捕捉实体间复杂的关系特性。

读完Knowledge Graph Embedding with Iterative Guidance from Soft Rules的大致思想后,好奇为什么要用复数来表示一个向量,就想看另一篇论文:

Complex Embeddings for Simple Link Prediction
然后发现,有个博客很好的说了这个事,我就转过来以后学习

博客:论文浅尝 | Complex Embeddings for Simple Link Prediction

在这里插入图片描述

论文链接:[Complex Embeddings for Simple Link Pred](http://proceedings.mlr.press/v48/trouillon16.pdf)
在统计关系学习里,链接预测问题是自动理解大规模知识库结构的核心。为了更好得把握知识库二元关系中的对称和非对称关系,本文提出了基于复数的表示方法 ComplEx。

一些研究工作将链接预测看作是三维二元张量补全的问题,张量的每一个slice表示知识库中关于一种关系的临接矩阵。典型的做法是对表示知识库的张量进行低秩分解,用分解得到的矩阵的每一行表示知识库中的一个实体或者一种关系。最后对于一个给定的三元组 r(s,o)(注:即主语 s 和宾语 o 具有关系 r),这个三元组的 score 可以通过对于 s,r,o 的表示向量之间的多线性(multi-linear)乘积计算得到。以往工作的问题在于不能很好地处理非对称关系,因为实数向量之间的点积计算是具有交换性的,即如果实数表示下的 r(s,o) 成立,那么 r(o,s) 也必然成立,但在知识库中非对称关系的比例远多于对称关系的比例。所以本文提出了一个基于复数表示的方法,因为复数之间的埃尔米特乘积(Hermitian dot product)是不具有交换性的,具体做法如下:

每个实体和关系都用一个复数向量表示,每个三元组的 score function 定义如下:

在这里插入图片描述

Re(x) 表示取 x 的实部,Im(x) 表示取 x 的虚部,三元组 (s,r,o) 的 score 计算过程为关系 r 的表示向量和主语 s 的表示向量以及宾语 o 的表示向量的共轭向量的乘积,并保留最后结果的实部。最终 (s,r,o) 为真的概率通过下式得到:

在这里插入图片描述

以下是 ComplEx 在对称关系和非对称关系的实验结果:

在这里插入图片描述

从左上的图中可以看出,Complex 和 DistMult 都可以较好地捕捉对称关系的语义信息并做出正确的预测,从右上的图中可以看出 Complex 对于非对称关系语义的捕捉以及预测效果明显优于其他模型。也验证了模型用复数表示的设计思想。

下图是在 WN18 和 FB15 上的链接预测的实验结果:

在这里插入图片描述

模型简洁的 ComplEx 在两个数据集上都取得了不错的效果,明显好于当时表现优异的 HolE。

本文模型设计背后的数学思想是比较值得借鉴的地方。

### Knowledge Graph Link Prediction Frameworks for Retrieval and Reading Knowledge graph link prediction involves predicting missing links or relationships between entities within a knowledge graph. For this purpose, several frameworks have been developed to enhance both retrieval and reading capabilities. #### 1. TransE Model TransE is one of the foundational models used in knowledge graph embedding methods. It represents each entity and relation as vectors in low-dimensional space where the score function measures how well a triplet $(h,r,t)$ holds by computing $f_r(h,t)=||\mathbf{e}_h+\mathbf{r}-\mathbf{e}_t||_2$[^1]. This model assumes that relations can be translated from head entities to tail entities through vector addition operations. #### 2. Convolutional Knowledge Graph Embeddings (ConvE) ConvE extends traditional embeddings like TransE by incorporating convolution layers over subject-predicate pairs before applying fully connected layers followed by reshaping into two-dimensional matrices. The scoring mechanism uses these transformed representations alongside object embeddings via element-wise multiplication and subsequent summation across all dimensions[^2]. ```python import torch.nn.functional as F from torch import nn class ConvE(nn.Module): def __init__(self, num_entities, num_relations, embedding_dim=200): super(ConvE, self).__init__() self.entity_embeddings = nn.Embedding(num_entities, embedding_dim) self.relation_embeddings = nn.Embedding(num_relations, embedding_dim) def forward(self, sub, rel): e_s = self.entity_embeddings(sub).view(-1, 1, 10, 20) # Example reshape r = self.relation_embeddings(rel).view(-1, 1, 10, 20) # Example reshape stacked_inputs = torch.cat([e_s, r], dim=-1) x = F.relu(stacked_inputs) return x ``` #### 3. ComplEx Model ComplEx addresses limitations found in earlier approaches such as inability to handle symmetric/antisymmetric properties effectively. By introducing complex-valued embeddings instead of real numbers only, it allows modeling asymmetric interactions more accurately while maintaining computational efficiency similar to simpler models[^3]. For applications requiring advanced reasoning tasks beyond simple triplets, architectures combining neural networks with symbolic logic offer promising solutions not covered directly here but worth exploring further based on specific requirements.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值