Transformers have achieved remarkable performance in widespread fields, including natural language processing, computer vision and graph mining. However, vanilla Transformer architectures have not yielded promising improvements in the Knowledge Graph (KG) representations, where the translational distance paradigm dominates this area. Note that vanilla Transformer architectures struggle to capture the intrinsically heterogeneous structural and semantic information of knowledge graphs. To this end, we propose a new variant of Transformer for knowledge graph representations dubbed Relphormer. Specifically, we introduce Triple2Seq which can dynamically sample contextualized sub-graph sequences as the input to alleviate the heterogeneity issue. We propose a novel structure-enhanced self-attention mechanism to encode the relational information and keep the semantic information within entities and relations. Moreover, we utilize masked knowledge modeling for general knowledge graph representation learning, which can be applied to various KG-based tasks including knowledge graph completion, question answering, and recommendation. Experimental results on six datasets show that Relphormer can obtain better performance compared with baselines. Code is available in https://github.com/zjunlp/Relphormer.
翻译:摘要:Transformer在自然语言处理、计算机视觉和图挖掘等广泛领域取得了显著性能。然而,标准Transformer架构在知识图谱表示领域尚未展现出令人满意的改进,该领域目前以平移距离范式为主导。值得注意的是,标准Transformer架构难以捕捉知识图谱中固有的异构结构和语义信息。为此,我们提出了一种新的Transformer变体用于知识图谱表示,称为Relphormer。具体而言,我们引入了Triple2Seq,该方法能够动态采样上下文子图序列作为输入,以缓解异构性问题。我们提出了一种新颖的结构增强自注意力机制,用于编码关系信息并保持实体和关系中的语义信息。此外,我们利用掩码知识建模进行通用知识图谱表示学习,可应用于多种基于知识图谱的任务,包括知识图谱补全、问答和推荐。在六个数据集上的实验结果表明,Relphormer相比基线模型能够获得更优的性能。代码可在https://github.com/zjunlp/Relphormer获取。