计算机与现代化 ›› 2021, Vol. 0 ›› Issue (11): 12-16.

• 人工智能 • 上一篇    下一篇

基于BERT与图像自注意力机制的文本匹配模型

  

  1. (西安邮电大学计算机学院,陕西西安710121)
  • 出版日期:2021-12-13 发布日期:2021-12-13
  • 作者简介:宋爽(1994—),男,陕西西安人,硕士研究生,研究方向:自然语言处理,E-mail: 1361220086@qq.com; 陆鑫达(1996—),男,陕西西安人,硕士研究生,研究方向:人工智能,E-mail: 464933396@qq.com。

Text Matching Model Based on BERT and Self-attention Mechanism of Image

  1. (School of Computer Science and Technology, Xi’an University of Posts and Telecommunications, Xi’an 710121, China)
  • Online:2021-12-13 Published:2021-12-13

摘要: 为了提高文本匹配的准确率,针对BERT(Bidirectional Encoder Representations from Transformers)模型和MatchPyramid模型在文本匹配中存在的局限性,提出一种基于BERT与图像自注意力机制的文本匹配模型。首先,利用BERT模型将一对文本编码为单词级别的特征向量。其次,根据词向量构建2段文本之间的词与词相似性的匹配矩阵,并将其视为单通道的图像表示。然后,通过图像的自注意力机制生成匹配矩阵的自注意力特征矩阵。最后,将匹配矩阵与自注意力特征矩阵连接为多通道,利用卷积神经网络捕获图像中的文本匹配信号,并将匹配信号与BERT模型输出的[CLS]编码向量连接后,输入全连接层得到2段文本的相似度。实验结果表明,该模型在WikiQA数据集上相比于BERT模型、MatchPyramid模型和其他文本匹配模型,可以有效地提高MAP和MRR衡量指标,验证了该模型的有效性。

关键词: 匹配矩阵, 图像自注意力机制, 特征融合, 文本匹配, BERT模型

Abstract: In order to improve the accuracy of text matching, a text matching model based on BERT(Bidirectional Encoder Representations from Transformers) and self-attention mechanism of image is proposed to overcome the limitations of BERT model and MatchPyramid model in text matching. Firstly, a pair of text is encoded into word-level feature vectors by using the BERT model. Secondly, the matching matrix of word to word similarity between two texts is constructed according to the word vector, which is regarded as a single channel image representation. Then the self-attention feature matrix of the matching matrix is generated by the self-attention mechanism of image. Finally, the matching matrix and the self-attention feature matrix are connected into multi-channel to capture the text matching signals in the image by the convolutional neural network. After the matching signal is connected with the coding vector called [CLS] which is yielded by the BERT model, the similarity of the two texts is obtained by inputting the fully connected neural layer. The experimental results show that the model can effectively improve the MAP and MRR metrics compared with BERT model, MatchPyramid model and other text matching models on WikiQA dataset, and the effectiveness of the model is verified.

Key words: matching matrix, self-attention mechanism of image, feature fusion, text matching, BERT model