Knowledge graph construction method based on function word enhanced small sample relation extraction
By introducing a function word enhanced attention network in small sample relationship extraction, capturing the grammatical structure difference information of function words, the problem of poor inverse relationship classification performance caused by the neglect of function words in the prior art is solved, and more efficient relationship extraction and generalization capabilities are achieved.
Patent Information
- Application Number
- CN202210433696.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-24
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2042-04-24
AI Technical Summary
The prior art is difficult to effectively utilize the grammatical structure differences in function word expression in small sample relationship extraction, resulting in poor performance in inverse relationship classification.
The attention network based on function word enhancement is adopted, and the structural difference information of function word expression is captured through the function word attention module, and combined it with the relational representation at the real word level to generate a more comprehensive relational representation.
The performance of small sample relationship extraction is improved, especially in the inverse relationship classification, and the generalization ability of the model and the utilization efficiency of a small amount of labeled data are enhanced.
Smart Images

Figure CN115062156B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of natural language processing, and in particular relates to a knowledge graph construction method based on function word enhanced small sample relationship extraction. Background Art
[0002] The knowledge graph is designed to describe various entities or concepts and their relationships in the real world. It forms a huge semantic network graph, where nodes represent entities or concepts and edges represent various semantic relationships between entities. With the development and application of artificial intelligence technology, knowledge graph, as one of the key technologies, has been widely used in intelligent search, intelligent question and answer, personalized recommendation, content distribution and other fields.
[0003] Currently, most knowledge graphs for general fields are constructed using unstructured data (e.g., text). The main steps are as follows: (1) entity extraction, which refers to the automatic identification of named entities from unstructured text data; (2) relationship extraction, which refers to the extraction of semantic relationships between specified entities from unstructured text data; (3) knowledge fusion, which refers to linking entities, relationships, etc. identified from unstructured text data to their corresponding entries in the general knowledge graph; (4) knowledge reasoning, which refers to automatically inferring missing relationship values based on the existing knowledge graph, further mining implicit knowledge, and thus enriching and expanding the knowledge graph.
[0004] With the continuous development of big data, massive amounts of information are presented to information users in the form of pure raw text. How to use natural language processing and data mining related technologies to help users obtain valuable information is an urgent need in contemporary computer research technology. Information extraction technology came into being. The main purpose of information extraction is to extract specified entities, relationships and other factual information from natural language text. The relationship extraction task is an important subtask of information extraction. The general form is to determine whether there is a relationship between the entities and what type of relationship exists given a text and two entities mentioned in the text. Relationship extraction is not only used in the construction of knowledge graphs, but is also widely used in information retrieval, question-answering systems, genetic disease relationship mining and other fields.
[0005] The relationship extraction method based on supervised learning has achieved good results, which requires sufficient and fully labeled training data. However, in many application fields (such as medical and financial fields), it is very difficult to collect sufficient data for training relationship classification models, and it is difficult to transfer to other fields. Therefore, it is necessary to study how to improve the performance of relationship extraction using a small amount of labeled or even unlabeled data.
[0006] One solution is the remote supervision method. The basic idea is to obtain a large amount of data by aligning the knowledge base. At the same time, it is assumed that if two entities have a certain relationship in the knowledge base, then the sentence containing these two entities can show this relationship to some extent. The target entity in the sentence is heuristically aligned with the entity in the knowledge base to achieve the purpose of automatically labeling the sentence. However, the defect of this idea is that the relationship implied by the same entity pair in different sentences may be different, and the use of remote supervision methods will produce noisy data; the knowledge base in many fields is not perfect, and most of the entity pairs and relationships have a long-tail distribution. The data obtained by this method that can be used for training is still insufficient, and it still cannot fundamentally solve the long-tail problem of sample distribution. Another solution is how to learn with only a small number of training samples and make the model have good generalization ability, that is, small sample learning.
[0007] At present, there are two main perspectives for learning small-sample relation extraction: one is to start from the sentence level, considering that different sentences under the same relation have different contributions to relation representation, and select more informative relation representations in different sentences by designing a sentence-level attention mechanism, and remove the influence of noise during training. The sentence-level method considers the relationship between instances from a global perspective, but ignores the difference in the importance distribution of words under different relation categories when encoding instances, thereby losing fine-grained discriminative features and having a negative impact on relation representation. The other is to start from the word level, considering that different words in the same sentence have different contributions to relation representation, and select semantically richer content words as contextual learning relations (e.g., nouns, verbs) in the sentence by designing a word-level attention mechanism. The word-level method additionally considers the difference changes within the instance, reducing the features lost by the model when encoding sentences, but the existing methods mainly focus on the differences between content words that express semantics and ignore the differences between function words.
[0008] Existing methods use semantic-level attention to capture content words as context, while ignoring function words (e.g. prepositions) that can express differences in syntactic structure. Function words are also a very important part of relation extraction, especially for the extraction of inverse relations. Inverse relations are a kind of fine-grained relations that are prevalent in small-sample relation extraction, characterized by similar semantics and different grammatical structures. According to statistics, inverse relations account for 21.25% and 18.45% of the general few-sample relation datasets FewRel1.0 and FewRel2.0, respectively. In the prior art, a semantic-level attention mechanism is used to focus on content words that express semantics, while function words that express grammatical structures are mostly ignored, which significantly reduces the performance of inverse relation classification. Figure 1The figure shows an example of a few-sample inverse relation extraction task, where the relation set contains inverse relations "participant" and "participantof". Their key semantic content word "participation" is the same, and the difference between them lies mainly in the function words (of and his). Therefore, it is also important to pay attention to function words in small-sample relation extraction. The function word-enhanced attention network can well capture the structural difference information expressed by function words and obtain more auxiliary information about the relationship, thereby making up for the problem of insufficient sample data and facilitating category classification. Summary of the invention
[0009] In view of the above-mentioned defects in the prior art, the present invention aims to propose a knowledge graph construction method based on function word enhanced small sample relationship extraction. Starting from how to capture the grammatical structure differences expressed by function words, the function word enhanced attention network is introduced into small sample relationship extraction to realize the knowledge graph construction.
[0010] The present invention is implemented by the following technical solutions:
[0011] A method for constructing a knowledge graph based on function word enhanced small sample relationship extraction, the method comprising the following steps:
[0012] Step 1: Obtain unstructured text data and perform entity extraction. The specific description is as follows:
[0013] Step 1.1: The original unstructured text is the relational data set. According to the relational categories, M relational category data are extracted from the relational data set to form a training set D. train , the remaining relational category data constitute the test set D val ; Training set D train Contains M categories, each category contains N instances, each instance is x i =(s i ,h i ,t i ), x i is the i-th instance, s i For unstructured sentences, h i For i The head entity in t i For i The tail entity in the training set D train Randomly select M1 categories from the , and randomly select N1 instances from each category to construct the support set D suppport , D suppport The jth element in r j For instance x j The corresponding y jRelation category label; randomly select N2 instances from the remaining N-N1 samples of each category to construct the query set D query , D query The kth element in is denoted as r k For instance x k The corresponding relationship category description, y k For instance x k The corresponding relationship category label;
[0014] Step 1.2: Use the text encoder Bert model to encode the instances in the training set and generate context embedding vectors: That is, for each instance x i =(s i ,h i ,t i ), s i ={w1,w2,...,w l} is an example sentence s i From l words w k Composition; Sentences i As the input of the text encoder, the generated context embedding vector is denoted as S i ={w1,w2,...,w l}, where each word d is the dimension of the word vector; for each relationship description r i ={w'1,w'2,...,w' k ,...,w' l}, w' k Describe the relationship r i The kth word in the equation, l is the relationship description r i The total number of words in r i As the input of the text encoder, each instance x generated i The context embedding vector is denoted as R i ={w'1,w'2,...,w' l}, where each word
[0015] Step 2: embed the sentence context into vector S i and the relation description context embedding vector R i Input the content word level attention module to generate the content word level relationship representation. The specific process is described as follows:
[0016] Step 2.1, calculate a content word attention vector The expression is as follows:
[0017] α i =softmax(S i*u w +sum(S i (R i ) T ) / d)
[0018] Among them, the memory unit is a trainable parameter, S i *u w For the sentence S i Select words with keyword features from S i With R i Transpose multiplication means that from sentence S i Select the one with the current relationship description R i Semantically similar words, sum(·) is an operator that sums all elements in each row of the matrix, and finally the two are added and input into the softmax layer to get S i The importance of each content word in
[0019] Step 2.2, S i Each word in α i Weighted summation to form a relationship at the content word level The expression is as follows:
[0020]
[0021] Step 3: Input the sentence context embedding vector S i , learn a component prior matrix The element C i,j For sentence s i Medium i With w j The probability of belonging to the same component uses the component prior matrix to strengthen the attention of the function words adjacent to the key content words in order to learn the subsequent function word relationship representation. The specific description is as follows:
[0022] Step 3.1, calculate s i The probability that two adjacent words belong to the same component is expressed as follows:
[0023]
[0024] Among them, s n,n+1 w n and right neighbor w n+1 The probability of belonging to the same component, [·] n is the nth row of the matrix;
[0025] For word w n and right neighbor w n+1 The probability of belonging to the same component n,n+1 With the word wn and left neighbor w n-1 The probability of belonging to the same component n,n+1 Using the softmax function, we get w n and w n+1 The probability p of belonging to the same component n,n+1 With w n and w n-1 The probability p of belonging to the same component n,n-1 , the expression is as follows:
[0026] p n,n+1 ,p n,n-1 =softmax(s n,n+1 ,s n,n-1 )
[0027] Then we get w n With w n+1 The probability of connection a n , the expression is as follows:
[0028]
[0029] Step 3.3, from sentence s i Medium i With w j All the words between the corresponding a n Calculate the element C i,j , the expression is as follows:
[0030]
[0031] Step 4: embed the sentence context into vector S i Input the BILSTM model and obtain the function word level relationship representation through the function word attention module; the specific process is as follows:
[0032] Step 4.1, the calculation of the importance distribution of common function words is as follows:
[0033] β general =softmax(ES i u w )
[0034] in, is a vector of all 1s, ES i u w To reduce the sentence S i Zhong and u w The importance of relevant content words, increase w The importance of irrelevant function words is input into the softmax layer to obtain the general distribution of function word importance.
[0035] Step 4.2: Calculate the importance of function words in specific sentences The expression is as follows:
[0036] I i =max(α i )
[0037]
[0038] Among them, I i is the index of the maximum weight, max(·) is the index of obtaining the maximum value of a matrix, and C is the component prior matrix;
[0039] Step 4.3, using two types of attention weights β general With β constituent Generate function word level relationships The expression is as follows:
[0040] β i =β general +β constituent
[0041]
[0042] Step 4.4: Set the importance of common function words β general and the importance of function words in specific sentences β constituent Add together to get Then S i Each word in β i Weighted summation to form a relational representation at the function word level
[0043] Step 5: The relationship between the content level obtained in step 2 Relationship with the function word level obtained in step 4 Concatenate to get phrase-level relation representation [;] is concatenated by column; then, by averaging the support set D suppport N1 sentences of the same category in generate the prototype representation of the current relation category
[0044] Step 6: Use the dot product similarity between the test sample and the prototype representation of the relationship category obtained in step 5 to make category predictions. The prediction result is the extracted relationship type:
[0045] For the test samples * , s * ·p i is the dot product of the test sample and the prototype representation of the i-th relation category, and the prototype representation p of the current relation category with the highest result i The corresponding relationship is the extracted relationship type.
[0046] Compared with the prior art, the beneficial effects and advantages of the present invention are:
[0047] It can avoid the time-consuming and labor-intensive process of manual labeling, and can quickly complete the relationship extraction task in a specific field through a small amount of labeled data in the specific field. At the same time, it can have good generalization performance for unseen fields and achieve fast and accurate relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 This is a sample diagram of the few-shot inverse relation extraction task, involving two relations, each with only one supporting instance;
[0049] Figure 2 It is a schematic diagram of the overall process of the knowledge graph construction method based on function word enhanced small sample relationship extraction of the present invention;
[0050] Figure 3 Flowchart of the small sample relation extraction process for function word enhancement;
[0051] Figure 4 This is the accuracy curve of some relations in the FewRel1.0 validation set;
[0052] Figure 5 This is a curve chart showing the change of model accuracy with learning rate;
[0053] Figure 6 This is a curve graph showing the change of model accuracy with the number of iterations. DETAILED DESCRIPTION
[0054] The specific implementation modes of the present invention will be described in detail below with reference to the accompanying drawings.
[0055] like Figure 2 As shown in FIG. 1 , it is a flow chart of the knowledge graph construction method based on function word enhanced small sample relationship extraction of the present invention. Figure 3 The following is a detailed flowchart of the small sample relation extraction for function word enhancement. Figure 2 , Figure 3 The specific implementation modes of the present invention are described in detail.
[0056] The embodiment of the present invention provides a knowledge graph construction method based on function word enhanced small sample relationship extraction, and the specific steps are as follows:
[0057] Step 1: Obtain unstructured text data and perform entity extraction. The specific description is as follows:
[0058] Step 1.1: The original unstructured text is the relational data set, and the relational data set uses the data set FewRel1.0. According to the relation category, M relation category data are extracted from the relational data set to form a training set Dtrain , the remaining relational category data constitute the test set D val Training set D train Contains M categories, each category contains N instances, each instance is x i =(s i ,h i ,t i ), where x i is the i-th instance, s i For unstructured sentences, h i For i The head entity in t i For i The tail entity in the training set D train Randomly select M1 categories from the , and randomly select N1 instances from each category to construct the support set D suppport , D suppport The jth element in is denoted as r j For instance x j The corresponding relationship category description is instance x j The corresponding y j Relation category label; randomly select N2 instances from the remaining N-N1 samples of each category to construct the query set D query , D query The kth element in is denoted as r k For instance x k The corresponding relationship category description, y k For instance x k The corresponding relationship category label;
[0059] Step 1.2, use the text encoder to encode the instances in the training set and generate context embedding vectors:
[0060] For each instance x i =(s i ,h i ,t i ), s i ={w1,w2,...,w l} is an example sentence s i From l words w k Composition; Sentences i As the input of the text encoder, the generated context embedding vector is denoted as S i ={w1,w2,...,w l}, where each word d is the dimension of the word vector; for each relationship description r i ={w'1,w'2,...,w' k,...,w' l}, w' k Describe the relationship r i The kth word in the equation, l is the relationship description r i The total number of words in r i As the input of the text encoder, each instance x generated i The context embedding vector is denoted as R i ={w'1,w'2,...,w' l}, where each word
[0061] Step 2: embed the sentence context into vector S i and the relation description context embedding vector R i Input the content word level attention module to generate the content word level relationship representation. The specific process is described as follows:
[0062] Step 2.1, calculate a content word attention vector The expression is as follows:
[0063] α i =softmax(S i *u w +sum(S i (R i ) T ) / d)
[0064] Among them, the memory unit is a trainable parameter, S i *u w For the sentence S i Select words with keyword features from S i With R i Transpose multiplication means that from sentence S i Select the one with the current relationship description R i Semantically similar words, sum(·) is an operator that sums all elements in each row of the matrix, and finally the two are added and input into the softmax layer to get S i The importance of each content word in
[0065] Step 2.2, S i Each word in α i Weighted summation is performed to form a relational representation at the content word level:
[0066]
[0067] Step 3: Input the sentence context embedding vector S i , learn a component prior matrix The element C i,j For sentence s i Medium i With w j The probability of belonging to the same component is used to strengthen the attention of the function words adjacent to the key content words, so as to facilitate the subsequent learning of the function word relationship representation. The specific description is as follows:
[0068] Step 3.1, calculate s i The probability that two adjacent words belong to the same component is expressed as follows:
[0069]
[0070] Among them, s n,n+1 w n and right neighbor w n+1 The probability of belonging to the same component, [·] n is the nth row of the matrix.
[0071] Step 3.2, for word w n and right neighbor w n+1 The probability of belonging to the same component n,n+1 With the word w n and left neighbor w n-1 The probability of belonging to the same component n,n+1 Using the softmax function, we get w n and w n+1 The probability p of belonging to the same component n,n+1 With w n and w n-1 The probability p of belonging to the same component n,n-1 , the expression is as follows:
[0072] p n,n+1 ,p n,n-1 =softmax(s n,n+1 ,s n,n-1 )
[0073] Then we get w n With w n+1 The probability of connection a n , the expression is as follows:
[0074]
[0075] Step 3.3, Element C i,j The calculation is based on the sentence s i Medium i With w j All the words between the corresponding a n The calculation results are:
[0076]
[0077] Step 4: Input the sentence context embedding vector S i , the function word level relational representation is obtained through the function word attention module. In this step, the attention module includes learning the importance distribution of general function words and the importance distribution of function words in specific sentences, and linearly combines the importance of general function words and the importance of function words in specific sentences to generate the relational representation at the function word level. The specific process is as follows:
[0078] Step 4.1, the calculation of the importance distribution of common function words is as follows:
[0079] β general =softmax(ES i u w )
[0080] in, is a vector of all 1s, ES i u w To reduce the sentence S i Zhong and u w The importance of relevant content words, increase w The importance of irrelevant function words is input into the softmax layer to obtain the general distribution of function word importance.
[0081] Calculate the importance of function words in a specific sentence. The expression is as follows:
[0082] I i =max(α i )
[0083]
[0084] Step 4.2, from α i Find the index I with the maximum weight i , max(·) is the index to obtain the maximum value of a matrix, and according to the index, the corresponding row is found from the component prior matrix C calculated in the third step.
[0085] Step 4.3, using two types of attention weights β general With β constituent Generate function word level relation representation:
[0086] β i =β general +β constituent
[0087]
[0088] Step 4.4: Set the importance of common function words β generaland the importance of function words in specific sentences β constituent Add together to get Then S i Each word in β i Weighted summation to form a relational representation at the function word level
[0089] Step 5: Add the And the fourth step Concatenate to get phrase-level relation representation [;] is concatenated by column; then, by averaging the support set D suppport The prototype of the current relation category generated by N1 sentences of the same category in
[0090] Step 6: Use the dot product similarity between the test sample and the prototype representation of the relationship category obtained in step 5 to make category predictions. The prediction result is the extracted relationship type:
[0091] For the test samples * , s * ·p i is the dot product of the test sample and the prototype representation of the i-th relation category, and the prototype representation p of the current relation category with the highest result i The corresponding relationship is the extracted relationship type.
[0092] Figure 4 This is a graph of the accuracy of some relations in the FewRel1.0 validation set. In the graph, P25 means "mother", P40 means "child", P59 means "constellation", P140 means "religion", P177 means "crosses", P361 means "part of", P364 means "original language of film or TV show", P527 means "haspart", P641 means "sport", and P1923 means "participating team".
[0093] In summary, the process of the knowledge graph construction method based on function word enhanced small sample relationship extraction of the present invention is summarized as follows:
[0094] 1. Automatically identify entities with specific meanings from unstructured text data. Specific description: ① Take each word in the unstructured text data as the input of the BERT pre-trained model, transfer a large amount of semantic information through encoding, and output the corresponding context word embedding vector; ② Take the following word embedding vector and the randomly initialized state transition probability matrix as the input of the BILSTM model, and output the respective scores of all labels of each word in the text, that is, the emission probability matrix; ③ Take the emission probability matrix and the state transition probability matrix as the input of the CRF model, and select the label sequence with the highest prediction score as the best answer output. The above process is defined as the BERT-BILSTM-CRF technology;
[0095] Second, extract the semantic relationship between the specified entities. This step is the key innovation of the present invention. The specific process of this step includes: inputting the acquired unstructured text data and the two named entities extracted in step 1 into the trained small sample relationship extraction model based on function word enhancement, finding the similarity scores with all relationship categories from the model output and selecting the relationship category with the highest score as the relationship between the two entities;
[0096] 3. Entity linking, that is, linking the extracted entity and relationship data to the corresponding entries in the knowledge graph: after identifying the entity, relationship and other references from the acquired unstructured text data, the entity and relationship are logically attributed through link disambiguation technology. This embodiment specifically adopts space vector technology, and the entity after updating the small sample relationship extraction model enhanced by function words is calculated. The cosine similarity of the feature vector between the entity and the candidate entity set is calculated, and the cosine similarity between the entity description and the candidate entity description is calculated. The two cosine similarities are added and the candidate entity with the highest similarity is selected as the target entity for the link. At this time, the knowledge graph has a prototype.
[0097] Fourth, knowledge reasoning, automatically infer the missing relationship values based on the existing knowledge graph: This step is to automatically infer the missing relationship values between nodes based on the existing knowledge graph, further explore the implicit knowledge, and thus enrich the expanded knowledge graph. This embodiment uses the neural network-based reasoning model Path-RNN to find the connection path between the two entities from the knowledge graph constructed in step three, and vectorize the entity and connection relationship of each node on the path and input it into Path-RNN. The final vector of the entire path is the hidden state output by the last unit of Path-RNN. The vector of the path is calculated with the cosine similarity of the candidate relationship set, and the one with the highest similarity is the new relationship between the current entity pair.
[0098] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Those skilled in the art may make various modifications, equivalent substitutions or variations without departing from the spirit and scope of the present invention, and all modifications, equivalent substitutions or variations made within the spirit and principles of the present application fall within the protection scope of the present invention as defined by the appended claims.
Claims
1. A knowledge graph construction method based on function word enhanced small sample relationship extraction, characterized in that: The method comprises the following steps: Step 1: Obtain unstructured text data and perform entity extraction. The specific description is as follows: Step 1.1: The original unstructured text is the relational data set. M relational category data are extracted from the relational data set according to the relation category to form a training set D. train , the remaining relational category data constitute the test set D val ; Training set D train Contains M categories, each category contains N instances, each instance is x i =(s i ,h i ,t i ), x i is the i-th instance, s i For unstructured sentences, h i For i The head entity in t i For i The tail entity in the training set D train Randomly select M1 categories from the , and randomly select N1 instances from each category to construct the support set D suppport , D suppport The jth element in is denoted as r j For instance x j The corresponding y j Relation category label; randomly select N2 instances from the remaining N-N1 samples of each category to construct the query set D query , D query The kth element in is denoted as r k For instance x k The corresponding relationship category description, y k For instance x k The corresponding relationship category label; Step 1.2: Use the text encoder Bert model to encode the instances in the training set and generate context embedding vectors: That is, for each instance x i =(s i ,h i ,t i ), s i ={w1,w2,...,w l } is an example sentence s i From l words w k Composition; Sentences i As the input of the text encoder, the generated context embedding vector is denoted as S i ={w1,w2,...,w l }, where each word d is the dimension of the word vector; for each relationship description r i ={w'1,w'2,...,w' k ,...,w' l }, w' k Describe the relationship r i The kth word in the equation, l is the relationship description r i The total number of words in r i As the input of the text encoder, each instance x generated i The context embedding vector is denoted as R i ={w'1,w'2,...,w' l }, where each word Step 2: embed the sentence context into vector S i and the relation description context embedding vector R i Input the content word level attention module to generate the content word level relationship representation. The specific process is described as follows: Step 2.1, calculate a content word attention vector The expression is as follows: a i =softmax(S i *u w +sum(S i (R i ) T ) / d) Among them, the memory unit is a trainable parameter, S i *u w For the sentence S i Select words with keyword features from S i With R i Transpose multiplication means that from sentence S i Select the one with the current relationship description R i Semantically similar words, sum(·) is an operator that sums all elements in each row of the matrix, and finally the two are added and input into the softmax layer to get S i The importance of each content word in Step 2.2, S i Each word in α i Weighted summation to form a relationship at the content word level The expression is as follows: Step 3: Input the sentence context embedding vector S i , learn a component prior matrix The element C i,j For sentence s i Medium i With w j The probability of belonging to the same component uses the component prior matrix to strengthen the attention of the function words adjacent to the key content words in order to learn the subsequent function word relationship representation. The specific description is as follows: Step 3.1, calculate s i The probability that two adjacent words belong to the same component is expressed as follows: Among them, s n,n+1 w n and right neighbor w n+1 The possibility of belonging to the same component, [·] n is the nth row of the matrix; Step 3.2, for word w n and right neighbor w n+1 The probability of belonging to the same component n,n+1 With the word w n and left neighbor w n-1 The probability of belonging to the same component n,n+1 Using the softmax function, we get w n and w n+1 The probability p of belonging to the same component n,n+1 With w n and w n-1 The probability p of belonging to the same component n,n-1 , the expression is as follows: p n,n+1 ,p n,n-1 =softmax(s n,n+1 ,s n,n-1 ) Then we get w n With w n+1 The probability of connection a n , the expression is as follows: Step 3.3, from sentence s i Medium i With w j All the words between the corresponding a n Calculate the element C i,j , the expression is as follows: Step 4: embed the sentence context into vector S i Input the BILSTM model and obtain the function word level relationship representation through the function word attention module; the specific process is as follows: Step 4.1, the calculation of the importance distribution of common function words is as follows: β general =softmax(ES i u w ) in, is a vector of all 1s, ES i u w To reduce the sentence S i Zhong and u w The importance of relevant content words, increase w The importance of irrelevant function words is input into the softmax layer to obtain the general distribution of function word importance. Step 4.2: Calculate the importance of function words in specific sentences The expression is as follows: I i =max(α i ) Among them, I i is the index of the maximum weight, max(·) is the index of obtaining the maximum value of a matrix, and C is the component prior matrix; Step 4.3, using two types of attention weights β general With β constituent Generate function word level relationships The expression is as follows: β i =β general +β constituent Step 4.4: Set the importance of common function words β general and the importance of function words in specific sentences β constituent Add together to get Then S i Each word in β i Weighted summation to form a relational representation at the function word level Step 5: The content word level relationship obtained in step 2 Relationship with the function word level obtained in step 4 Concatenate to get phrase-level relation representation [;] is concatenated by column; then, by averaging the support set D suppport N1 sentences of the same category in generate the prototype representation of the current relation category Step 6: Use the dot product similarity between the test sample and the prototype representation of the relationship category obtained in step 5 to make category predictions. The prediction result is the extracted relationship type: For the test samples * , s * ·p i is the dot product of the test sample and the prototype representation of the i-th relation category, and the prototype representation p of the current relation category with the highest result i The corresponding relationship is the extracted relationship type.
Citation Information
Patent Citations
Small sample intention recognition method and device, equipment and storage medium
CN113723111A
Knowledge graph entity link prediction method based on small sample learning
CN114153985A