| With the explosion of Internet information,how to extract specific factual information from natural language texts has become the focus of research in the field of natural language processing.Relationship extraction is an important task in natural language processing.Its purpose is to predict the semantic relationship between entity pairs in sentences and provide support for building a complete knowledge network.In this paper,the existing methods of supervised relationship extraction and distant supervision relationship extraction are improved to improve their accuracy.In relation extraction,attention is often used as a method of information extraction and integration.Attention is a network structure that simulates people’s attention.It can integrate multiple information to better represent sentences.In this paper,the attention problem in relationship extraction task is studied,and a bidirectional information enhancement attention model is designed and implemented.The specific methods are as follows:The traditional attention model uses softmax function to normalize the attention matrix.However,softmax function has two problems: on the one hand,with the increase of sentence length,softmax will assign many weights to invalid information,which reduces the weight assigned by the model to important positions,resulting in insufficient extraction of important information and affecting the performance of the model;On the other hand,the inherent characteristics of the softmax function determine that all the values output by the function are positive,and the weights of the attention weight matrix generated by the softmax function are also positive,so negative weights cannot be generated.When calculating the correlation between two conflicting words,softmax function can not accurately express the relationship between two words,that is,softmax can only set the correlation coefficient between two words with opposite meanings to zero,which weakens the degree of conflict between two words.In order to solve the above problems,this paper introduces a hard attention mechanism based on the original attention model to strengthen the extraction of important information,and adds negative weight information to the attention matrix to enhance the extraction ability of conflict information.In addition,the attention model assumes that there is no difference in word spacing between all words in a sentence.Although the existing methods add position vector to assist in extracting position information in the process of text coding,because the length of position vector is generally short,it is difficult for the model to pay attention to the influence of position information in point multiplication operation.At the same time,the position vector can not accurately represent the relative position information between words,that is,the sensitivity of two words should be related to the distance between them.The closer the distance,the stronger the sensitivity.In order to solve the above defects,this paper proposes a method to enhance the position sensitivity of the model by adding distance weight information.In this paper,the existing attention model is improved by the above two methods,and the improved attention matrix is named bidirectional information enhancement attention mechanism.By applying two-way information to enhance the attention matrix,this paper experiments on the supervised relationship extraction dataset semeval 2010 task8 and the distant supervision relationship extraction dataset nyt10 respectively.The experimental results show that the bidirectional information enhancement attention model can improve the information extraction ability of the existing models. |