计算机工程与应用 ›› 2025, Vol. 61 ›› Issue (8): 126-134.DOI: 10.3778/j.issn.1002-8331.2311-0403

• 模式识别与人工智能 • 上一篇    下一篇

基于深度编码与知识增强的句子匹配方法

姜克鑫,赵亚慧,崔荣一,陈科   

  1. 1.广东外语外贸大学南国商学院 计算机学院,广州 510545
    2.延边大学 工学院,吉林 延吉 133002
    3.南京审计大学 计算机学院,南京 210000
  • 出版日期:2025-04-15 发布日期:2025-04-15

Sentence Matching Method Based on Deep Coding and Knowledge Enhancement

JIANG Kexin, ZHAO Yahui, CUI Rongyi, CHEN Ke   

  1. 1.School of Computer Science, South China Business College of Guangdong University of Foreign Studies, Guangzhou  510545, China
    2.School of Engineering, Yanbian University, Yanji, Jilin 133002, China
    3.School of Computer Science, Nanjing Audit University, Nanjing 210000, China
  • Online:2025-04-15 Published:2025-04-15

摘要: 自然语言句子匹配是比较两个句子并识别它们之间关系的任务。针对现有模型泛化能力弱和缺少外部知识等问题,提出了一种基于深度编码与知识增强的句子匹配方法。从两个部分引入知识,即从Wiktionary提取文本的单词定义以及从知识图谱提取文本三元组信息作为外部知识; 为了提取深层次语义信息,分别对文本和知识进行编码,在文本编码模块首先在编码单个句子的过程中,参照了另一个句子的信息,同时将三元组的信息加入其中;采用启发式的融合算法,将文本信息和知识进行融合,使用门控机制过滤引入知识产生的噪声;在交互过程中,使用双向注意力机制获取深层语义信息,并使用前馈神经网络输出。在SNLI、SciTail、SICK、Quora数据集上的准确率分别为91.0%、92.8%、87.6%、91.3%,准确率较多个模型均有所提升,验证了模型的有效性。

关键词: 自然语言句子匹配, 注意力机制, 知识增强, 启发式融合

Abstract: Natural language sentence matching is a task that compares two sentences and identifies their relationship. Addressing issues such as weak generalization capability of existing models and lack of external knowledge, this paper presents a method for sentence matching enhanced by deep encoding and knowledge. Firstly, knowledge is introduced from two sources: word definitions extracted from Wiktionary and triplet information from knowledge graphs, serving as external knowledge. Secondly, to extract deep semantic information, texts and knowledge are encoded separately. In the text encoding module, information from one sentence is referenced during the encoding of another, integrating triplet information in the process. Subsequently, a heuristic fusion algorithm is employed to merge text information and knowledge, employing a gating mechanism to filter noise generated by the introduced knowledge. Finally, in the interaction process, a bidirectional attention mechanism is used to capture deep semantic information, with a feedforward neural network producing the output. The model demonstrates its effectiveness with accuracy rates of 91.0%, 92.8%, 87.6% and 91.3% on the SNLI, SciTail, SICK, and Quora datasets, respectively, showing improvements over several models.

Key words: natural language sentence matching, attention mechanism, knowledge enhancement, heuristic fusion