Cross-domain small sample relation extraction method and device for learning fine-grained general knowledge

Through the dual-channel general knowledge learning module and the relationship comparison learning module, the problem of knowledge application and class boundary blur in cross-domain small sample relationship extraction is solved, high-quality general knowledge learning and fine-grained relationship distinction are achieved, and the efficiency of relationship extraction is improved. accuracy and robustness.

CN118674036AActive Publication Date: 2024-09-20INSTITUTE OF INFORMATION ENGINEERING CHINESE ACADEMY OF SCIENCES

Patent Information

Application Number
CN202410728857.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-06
Publication Date
2024-09-20
Estimated Expiration
2044-06-06

AI Technical Summary

Technical Problem

There are two main problems with existing relationship extraction technology in cross-domain small sample scenarios: first, when learning knowledge directly from the source domain and applying it to the target domain, a large amount of unique knowledge of the source domain is introduced, weakening the role of general knowledge; second, General knowledge learning is based on the entire relationship extraction task rather than targeting each type of relationship, resulting in fuzzy class boundaries and difficulty in distinguishing similar relationships in the target domain.

Method used

A dual-channel general knowledge learning module is adopted, including explicit general knowledge learning and implicit general knowledge learning, to capture shallow general knowledge through convolution operations, and to eliminate relevant differences within and between fields through implicit knowledge learning. At the same time, a relationship comparison learning module based on Dropout is designed to refine coarse-grained general knowledge into fine-grained public knowledge and improve the model's relationship extraction capabilities in the target domain.

Benefits of technology

It effectively captures and utilizes cross-domain general knowledge, reduces dependence on unique knowledge in the source domain, improves the performance and accuracy of relationship extraction in the target domain, and can more accurately distinguish similar relationships in the target domain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118674036A
    Figure CN118674036A
Patent Text Reader

Abstract

The invention relates to a cross-domain small sample relation extraction method and device for learning fine-grained general knowledge. The method comprises the steps that data preprocessing is conducted, wherein a semantic prompt template is spliced to the tail of each sentence in a data set; a cross-domain small sample relation extraction model is constructed, the cross-domain small sample relation extraction model comprises a feature extraction network, a dual-channel general knowledge learning network, a relation comparison learning network and a relation classification network, and the dual-channel general knowledge learning network comprises an implicit general knowledge learning network and an explicit general knowledge learning network; training a cross-domain small sample relation extraction model through a loss function, a relation comparison learning loss function and a relation classification loss function of an implicit general knowledge learning network by utilizing the training set, and obtaining an optimal model by utilizing the verification set; and extracting the relationship in the sentence of the target domain by using the optimal model. According to the method, cross-domain general knowledge can be accurately captured and utilized, dependence on unique knowledge of the source domain is reduced, and the relation extraction performance in the target domain is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a method and device for extracting cross-domain small sample relations for learning fine-grained general knowledge, and belongs to the field of artificial intelligence natural language processing. Background Art

[0002] In recent years, with the rapid development of the Internet and information technology, a large amount of unstructured text data such as news, research papers, blogs, forums and social media has emerged. As an important carrier of knowledge, these text data contain rich information. However, in the face of such a huge amount of data, how to efficiently extract the information we need from it has become an urgent need. Relation extraction technology came into being, and its main goal is to identify and extract the relationship between two specified entities in the text. Through this technology, we can discover the potential connections between things and various concepts, thereby promoting the rapid growth of human knowledge.

[0003] Traditional relation extraction techniques mainly rely on data-driven methods. This means that we need to train the model on a large amount of labeled training data so that it can learn the meaning of various relations. However, there is a significant problem with this approach: it relies heavily on labeled data. In reality, since data labeling is time-consuming and laborious, it is often difficult to obtain enough labeled data to train the model. Therefore, traditional models are often unable to effectively complete the relationship extraction task due to insufficient learned knowledge. Especially in some special fields that require high expertise (such as medicine, finance, etc.), it is more difficult to obtain labeled data. Therefore, in order to solve this problem, small sample relationship extraction technology has gradually attracted attention. One method is how to learn knowledge from existing general fields with relatively more labeled data and generalize it to new categories in these professional fields, which has become an important research direction. However, the language features between different fields are often very different, which causes the model trained on the source domain (i.e., the general domain) to encounter difficulties in understanding the relations in the target domain (i.e., the professional domain), thereby affecting the performance of relationship extraction. Therefore, how to effectively use the relationship instances in the source domain to extract the relations in the target domain has become an urgent problem to be solved. Domain adaptive small sample relation extraction has become an important research direction.

[0004] In recent years, with the development of deep learning technology, various cross-domain small sample relation extraction methods based on meta-learning have made certain breakthroughs. It enables the model to learn cross-task meta-knowledge in multiple relation extraction tasks sampled from large-scale datasets (source domain) and apply it in the target domain. Prototype network is an effective algorithm based on meta-learning. It takes the class center of samples of the same type as the prototype of the relationship and classifies the samples to be predicted into the prototype with the most similar distance to it. In order to improve the quality of relation prototypes, some works learn a large amount of prior knowledge through pre-training, which can help understand the meaning of the relationship. However, prior knowledge is not directly related to the relationship, which can only provide limited help for relation extraction. Therefore, some works directly use the descriptive information of the relationship to learn high-quality prototypes.

[0005] Although existing works have achieved some success, the performance of the methods is still limited by two problems. First, existing works learn knowledge from the source domain and directly apply this knowledge to the target domain for relation extraction. However, this approach introduces a large amount of unique knowledge from the source domain, which is ineffective for extracting relations in the target domain and weakens the role of general knowledge, which limits the model's ability to extract relations in the target domain. Second, general knowledge is learned based on a set of relation extraction tasks rather than based on each type of relation, which leads to a lack of clarity in the class boundaries of relations. Therefore, this coarse-grained general knowledge makes the model unable to effectively distinguish similar relations in the target domain. Summary of the invention

[0006] Existing methods face two major problems in relation extraction. First, when learning knowledge directly from the source domain and applying it to the target domain, due to the differences between the source and target domains, a large amount of unique knowledge in the source domain is introduced, which is not only unhelpful for relation extraction in the target domain, but also weakens the role of general knowledge. Second, existing general knowledge learning is based on the entire relation extraction task rather than for each type of relation, resulting in blurred class boundaries of relations and limited ability of the model to distinguish similar relations in the target domain.

[0007] In order to solve these problems, the present invention proposes a fine-grained general knowledge learning method. The core of this method is to accurately capture and utilize cross-domain general knowledge through a dual-channel general knowledge learning module. The module includes two parts: explicit general knowledge learning and implicit general knowledge learning. Explicit knowledge learning captures shallow general knowledge, such as shared grammatical structures or entity semantics, from the knowledge representation of the source domain and the target domain through convolution operations. Implicit knowledge learning further eliminates the relevant differences in knowledge within and between domains, and establishes deeper cross-domain knowledge associations. In addition, in order to effectively distinguish similar relationships in the target domain, the present invention also designs a relational contrast learning module based on Dropout (relational contrast learning module based on feature discarding). This module refines the originally coarse-grained general knowledge into fine-grained public knowledge by learning the subtle differences between relationship prototypes. In this way, the model can more accurately use these fine-grained knowledge to distinguish similar relationships in the target domain.

[0008] The cross-domain small sample relationship extraction method for learning fine-grained general knowledge proposed in the present invention first focuses on learning the general knowledge between domains through the knowledge guidance model of the target domain in the dual-channel general knowledge learning module. The method uses the BERT pre-trained language model as a feature extractor. In the dual-channel general knowledge learning module, rich syntactic and semantic features are first extracted from the sentence in order to learn more general knowledge from it. Feature extraction uses a prompt template that can learn context to extract rich semantic and syntactic features from the sentence. The dual-channel general knowledge learning module considers both the source domain knowledge and the target domain knowledge to fully learn the general knowledge between domains. It learns shallow general knowledge between domains through explicit knowledge learning. At the same time, through implicit general knowledge learning, the implicit general knowledge between domains is further mined. The above method can fully learn the general knowledge between domains, thereby effectively guiding the relationship extraction of the target domain.

[0009] In addition, in order to effectively distinguish similar relations in the target domain, the present invention designs a contrastive learning module based on dropout. By using dropout to generate contrast samples with smooth feature changes, the subtle differences between different relationship prototypes can be learned, thereby obtaining fine-grained common knowledge. Finally, the method uses a general training method to obtain a relationship classification loss function training model to extract various categories of relations.

[0010] The technical solution adopted by the present invention is as follows:

[0011] A cross-domain small sample relationship extraction method for learning fine-grained general knowledge includes the following steps:

[0012] Perform data preprocessing, including concatenating the semantic hint template at the end of each sentence in the dataset;

[0013] Constructing a cross-domain small sample relationship extraction model, wherein the cross-domain small sample relationship extraction model includes a feature extraction network, a dual-channel general knowledge learning network, a relationship comparison learning network, and a relationship classification network, wherein the dual-channel general knowledge learning network includes an implicit general knowledge learning network and an explicit general knowledge learning network;

[0014] Using the training set in the data set, the cross-domain small sample relationship extraction model is trained through the loss function of the implicit general knowledge learning network, the relationship contrast learning loss function and the relationship classification loss function, and the optimal model is obtained using the validation set;

[0015] The optimal model is used to extract relations in sentences of the target domain.

[0016] Furthermore, the data preprocessing also includes: using virtual tags to emphasize the role of entities in relationship extraction, and adding virtual tags before and after the head entity and the tail entity respectively; the virtual tags use undefined tags reserved in BERT.

[0017] Furthermore, the processing of the dual-channel general knowledge learning network includes: the explicit general knowledge learning network uses convolution to capture shallow common knowledge from the knowledge representation of the source domain and the target domain. For example, the grammar or entity semantics shared by the two domains are captured. The implicit general knowledge learning network establishes the association of implicit knowledge between domains by eliminating the relevant differences between knowledge within the domain and knowledge between domains. This further learns the implicit common knowledge between domains.

[0018] Furthermore, in order to effectively distinguish similar relations in the target domain, the present invention designs a relation contrastive learning network based on dropout, which transforms the coarse-grained common knowledge in the relation prototypes into fine-grained common knowledge by learning the local subtle differences between the relation prototypes.

[0019] Furthermore, the relationship classification network uses the class center of the relationship representation of the same type of relationship as the relationship prototype, and classifies the relationship to be predicted into the relationship prototype that is most similar to it, wherein a parameter-free metric function is used to measure the similarity.

[0020] Furthermore, the loss function of the implicit general knowledge learning network enables the model to strengthen the association of implicit public knowledge between domains by eliminating the correlation difference of data distribution between domains, thereby effectively using this knowledge to guide the relationship extraction of the target domain; the loss function of the implicit general knowledge learning network is expressed as follows:

[0021] L P =|P S -P ST

[0022] Among them, P Sis the mean value of the correlation coefficients between different relation prototypes in the source domain, P ST is the mean of the correlation coefficients of different relationship prototypes between the source domain and the target domain.

[0023] Furthermore, the Dropout-based relation contrastive learning loss function enables the model to learn fine-grained general relation knowledge, thereby effectively distinguishing similar relations in the target domain; the relation contrastive learning loss function is expressed as follows:

[0024]

[0025] Among them, p i For the i-th type of relation prototype in the support set, p i ' represents the i-th type of relationship prototype in the support set after Dropout, τ1 is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and N represents the total number of relationship prototypes.

[0026] Furthermore, the relationship classification loss function enables the model to extract relationships of different categories, classify the samples in the query set into a certain category prototype in the support set in a task consisting of a set of sampled data, and train the model on multiple sets of repeatedly sampled tasks; the relationship classification loss function is expressed as follows:

[0027]

[0028] Among them, q j is the jth sample in the query set, p q It indicates the relation prototype category to which the sample belongs, τ2 is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and G represents the total number of samples to be classified.

[0029] A cross-domain small sample relationship extraction device for learning fine-grained general knowledge, comprising:

[0030] A data preprocessing module is used to perform data preprocessing, including splicing the semantic hint template at the end of each sentence in the data set;

[0031] A model building module, used to build a cross-domain small sample relationship extraction model, wherein the cross-domain small sample relationship extraction model includes a feature extraction network, a dual-channel general knowledge learning network, a relationship comparison learning network, and a relationship classification network, wherein the dual-channel general knowledge learning network includes an implicit general knowledge learning network and an explicit general knowledge learning network;

[0032] A model training module is used to train the cross-domain small sample relationship extraction model by using the training set in the data set through the implicit knowledge learning network loss function, the relationship contrast learning loss function and the relationship classification loss function, and obtain the optimal model by using the validation set;

[0033] The relation extraction module is used to extract the relations in the sentences of the target domain using the optimal model.

[0034] The key points of the present invention include:

[0035] 1) This method proposes dual-channel general knowledge learning and relation contrastive learning to integrate the learning of inter-domain general knowledge and the fine-graining of general knowledge into one model. This can learn high-quality general knowledge and effectively avoid the model from confusing semantic similarity relationships, making the model more effective in generalizing from general fields to specific professional fields.

[0036] 2) The cross-domain small sample relation extraction framework proposed in this method contains two modules. The dual-channel general knowledge learning module learns implicit and explicit general knowledge between domains. The explicit general knowledge learning network mainly captures shallow common knowledge in the source and target domains through convolution operations. Convolution operations can effectively extract local features from text data, which may include shared grammatical structures, entity semantics, etc. These shallow common knowledge provide the model with a preliminary understanding of the text data in the two domains, laying the foundation for subsequent relation extraction tasks. The implicit general knowledge learning network goes further and aims to eliminate the relevant differences in knowledge within and between domains, thereby establishing deep knowledge associations across domains. Since the source and target domains may have differences in language features, domain knowledge, etc., directly applying the knowledge of the source domain to the target domain may result in performance degradation. Therefore, the implicit general knowledge learning network eliminates these differences through a series of complex operations, such as feature transformation and domain adaptation, so as to learn more general and cross-domain knowledge. The role of the relation contrastive learning network is to refine the original coarse-grained general knowledge into fine-grained public knowledge. In the task of relation extraction, similar relations are often difficult to distinguish, which is also a problem with existing methods. The relation contrastive learning network introduces a dropout mechanism, which enables the model to pay attention to the subtle differences between relation prototypes during training. In this way, the model can learn a more refined relation representation, thereby more accurately distinguishing similar relations in the target domain.

[0037] 3) This method proposes three loss functions that interact with each other and influence each other, including: implicit general knowledge learning network loss function, relation contrast loss function and relation classification loss function.

[0038] Compared with the prior art, the present invention has the following positive effects:

[0039] 1. In order to solve the problem that existing methods directly introduce a large amount of source domain-specific knowledge when learning and applying knowledge to the target domain, this method adopts a dual-channel general knowledge learning module. This module includes two parts: explicit general knowledge learning and implicit general knowledge learning. Explicit knowledge learning captures shallow general knowledge through convolution operations, while implicit knowledge learning further eliminates the relevant differences in knowledge within and between domains and establishes cross-domain knowledge associations. Such a design enables the model to more accurately capture and utilize cross-domain general knowledge, thereby reducing dependence on source domain-specific knowledge and improving relationship extraction performance in the target domain.

[0040] 2. Aiming at the problem that the existing methods learn general knowledge in a coarse-grained manner, which leads to blurred boundary of relationship classes and difficulty in distinguishing similar relationships in the target domain, the present invention designs a contrastive learning module based on dropout. This module refines the coarse-grained general knowledge into fine-grained public knowledge by learning the subtle differences between relationship prototypes. This enables the model to more accurately use this fine-grained knowledge to distinguish similar relationships in the target domain, thus improving the accuracy and robustness of relationship extraction. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 It is a schematic flow diagram of the method of the present invention;

[0042] Figure 2 It is a schematic diagram of the framework structure proposed by the method of the present invention. DETAILED DESCRIPTION

[0043] In order to better express the cross-domain small sample relationship extraction method for learning fine-grained general knowledge proposed in the present invention, the present invention is further described below in conjunction with the accompanying drawings and specific implementation methods.

[0044] Figure 1 This is an overall flow chart of a cross-domain small sample relationship extraction method for learning fine-grained general knowledge of the present invention, including four parts: data preprocessing, initialization model framework, model training, and relationship extraction.

[0045] Step 1. Data preprocessing: The manually designed entity semantic hint template is spliced ​​at the end of each sentence in the dataset.

[0046] Step 2. Initialize the model framework. Figure 2 It is a model framework designed in the present invention, which includes a feature extraction network, implicit and explicit general knowledge learning networks, a relation contrast learning network and a relation classification network.

[0047] Step 3. Model training. The present invention trains the model through the loss function of the implicit general knowledge learning network, the relation contrast learning loss function and the relation classification loss function. When the total loss function converges on the validation set and the optimal effect is achieved in the validation set, the parameters of the model are saved as the optimal model. During the validation and testing process, the method only inputs data into the feature extraction network to extract contextual relationship information.

[0048] Step 4. Extract relations. Using the optimal model obtained in step 3, the test set data is used as the input model. The relations in each sentence are obtained by the feature extraction network. Then the similarity between the relation to be classified and the given relation category is calculated through the metric function, and its category is determined as the most similar relation category.

[0049] According to the solution provided by the present invention, the specific steps of a cross-domain small sample relationship extraction method for learning fine-grained general knowledge in one embodiment of the present invention are as follows:

[0050] Step 1. Data preprocessing. Since this method requires a semantic hint template to guide the model to give the semantics of the entity and then learn the relationship knowledge between entities, the present invention designs a semantic hint template and adds it to each piece of data. Secondly, the present invention uses the undefined tags inside BERT as virtual tags to emphasize the role of entities in relationship extraction, and adds them before and after the head entity and the tail entity respectively.

[0051] Step 2. Initialize the model framework. This method uses metric learning as the basic model framework, which is one of the most popular meta-learning-based frameworks. This method uses the BERT pre-trained language model as the feature encoder. The input of the model is mainly divided into three parts: support set, query set, and target set. The ultimate goal of the model is to classify the query set into a certain relationship category in the support set. This method includes:

[0052] First, the sampled support set, query set, and target set data are input into the feature encoder to obtain the relation feature encoding.

[0053] Then, the explicit and implicit universal relationship knowledge between domains is learned through a dual-channel universal knowledge learning module. The learning of explicit universal knowledge is completed by extracting shallow universal knowledge from data of two domains simultaneously through a convolutional neural network, and the implicit universal knowledge learning is completed by narrowing the difference in feature distribution of data between domains to highlight implicit universal knowledge.

[0054] For the relation contrastive learning part, the relation contrastive learning network uses the dropout mechanism to allow the model to pay more attention to the subtle differences between relations during training. In this way, the model can learn more accurate relation representations and thus more effectively distinguish similar relations in the target domain.

[0055] Finally, the relationship classification is performed. This method takes the class center of the relationship representation of the same type of relationship as the prototype of the relationship, and classifies the relationship to be predicted into the most similar relationship prototype. For the measurement of similarity, a parameter-free metric function is used, such as cosine similarity. This process is completed through the classification loss function.

[0056] Step 3. Model training: This method completes model training by optimizing three loss functions.

[0057] The first loss function is the loss function of the implicit general knowledge learning network. This loss function starts from the perspective of correlation and reduces the difference in data feature distribution between domains by reducing the correlation difference between domain data. The difference in correlation is measured by two correlation values, namely the mean correlation between different relationship prototypes in the source domain and the mean correlation between different relationships between the source domain and the target domain. The correlation is calculated using the Person correlation coefficient. After eliminating the difference between the two correlation coefficients, the model is no longer disturbed by the unique knowledge in the domain, and the implicit general knowledge begins to gradually receive the attention of the model.

[0058] The second loss function is the relation contrastive learning loss function. By using the dropout mechanism, the model obtains contrast samples with smooth feature changes, and then captures the subtle features of the relationship and the subtle differences between the relationships through relation contrastive learning. In this way, the model can learn more accurate relationship representations and thus more effectively distinguish similar relationships in the target domain.

[0059] The second loss function is the relation classification loss function. The model classifies the samples in the query set into the relation prototype that is most similar to it by the nearest prototype method, so as to train the model to extract different types of relations.

[0060] The method combines the three loss functions into a total model loss function by assigning different weights. The present invention is on a validation set. When the total loss function converges and reaches the optimal effect in the validation set, the parameters of the model are saved as the optimal model.

[0061] Step 4. Extract relations. Using the optimal model obtained in step 3, the test set data is used as the input model. Then the similarity between the relation to be classified and the given relation category is calculated through the metric function, and its category is determined as the most similar relation category.

[0062] For example, in step 1, a sentence with a semantic hint template added is: "[E1] Newton [\E1] served as the president of [E2] the Royal Society [\E2]. Newton means [M1], the Royal Society means [M2]". The first half of the sentence is a sentence in a dataset, where [E1], [\E1], [E2], [\E2] represent undefined virtual tags used to emphasize the role of entities in the relationship. The second half of the sentence is a semantic hint template, where [M1] and [M2] represent the semantics of the head entity and the tail entity, respectively.

[0063] For example, in step 2, the convolutional neural network in the explicit general knowledge learning network is composed of multiple convolutional layers, activation layers, and Dropout layers. Each convolutional layer extracts the input features by convolution operation between the convolution kernel and the input, the activation layer uses the activation function to increase the nonlinear expression ability of the model, and the Dropout layer can alleviate the overfitting problem caused by lack of samples to a certain extent.

[0064] Exemplarily, in step 3, the loss function of the implicit general knowledge learning network is expressed as:

[0065] L P =|P S -P ST

[0066] Among them, P S is the mean value of the correlation coefficients between different prototypes in the source domain, P ST is the mean of the correlation coefficients of different relationship prototypes between the source domain and the target domain.

[0067] Exemplarily, in step 3, the relation ratio learning loss function is expressed as:

[0068]

[0069] Among them, p i For the i-th type of relation prototype in the support set, p i ' represents the i-th type of relationship prototype in the support set after Dropout, τ1 is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and N represents the total number of relationship prototypes.

[0070] Exemplarily, in step 3, the relation classification loss function is expressed as follows:

[0071]

[0072] Among them, q j is the jth sample in the query set, pq It indicates the relation prototype category to which the sample belongs, τ is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and G represents the total number of samples to be classified.

[0073] Exemplarily, in step 3, the total loss function of the model is expressed as follows:

[0074] L=λ1L P +λ2L C +λ3L FS

[0075] Among them, λ1, λ2 and λ3 are the weights of the loss of the implicit general knowledge learning network, the relation contrastive learning loss and the relation classification loss respectively. The three weights are manually determined according to the effect of the model in the validation set.

[0076] Table 1 is the comparative experimental data of the present invention and the existing method.

[0077] Table 1

[0078]

[0079]

[0080] The above experimental results prove that the present invention (FCKL) is superior to the existing methods in various tasks, especially in tasks where each relation category has only one sample, the advantages of the present invention are more significant.

[0081] The cross-domain small sample relationship extraction method of the present invention can realize cross-domain relationship extraction between different fields, wherein the different fields can specifically be: general field and medical field, general field and financial field, etc.

[0082] For example, for situations spanning general fields and medical fields, the method of the present invention can be used to extract cross-domain relationships such as diseases and symptoms, drugs and side effects, and then the cross-domain relationship extraction results can be used to construct a medical knowledge graph to achieve specific functions such as intelligent diagnosis and drug recommendations.

[0083] For another example, for situations spanning general fields and financial fields, the method of the present invention can be used to extract cross-domain relationships such as companies and stocks, names and positions, and the cross-domain relationship extraction results can then be used for financial data analysis to achieve specific functions such as risk assessment and investment decision support.

[0084] Another embodiment of the present invention provides a cross-domain small sample relationship extraction device for learning fine-grained general knowledge, which includes:

[0085] A data preprocessing module is used to perform data preprocessing, including splicing the semantic hint template at the end of each sentence in the data set;

[0086] A model building module, used to build a cross-domain small sample relationship extraction model, wherein the cross-domain small sample relationship extraction model includes a feature extraction network, a dual-channel general knowledge learning network, a relationship comparison learning network, and a relationship classification network, wherein the dual-channel general knowledge learning network includes an implicit general knowledge learning network and an explicit general knowledge learning network;

[0087] A model training module is used to use the training set in the data set to train the cross-domain small sample relationship extraction model through an implicit general knowledge learning network loss function, a relationship contrast learning loss function, and a relationship classification loss function, and to obtain the optimal model using a validation set;

[0088] The relation extraction module is used to extract the relations in the sentences of the target domain using the optimal model.

[0089] The specific implementation process of each module refers to the above description of the method of the present invention.

[0090] Another embodiment of the present invention provides a computer device (computer, server, smart phone, etc.), which includes a memory and a processor, the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program includes instructions for executing each step in the method of the present invention.

[0091] Another embodiment of the present invention provides a computer-readable storage medium (such as ROM / RAM, magnetic disk, optical disk), wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the steps of the method of the present invention are implemented.

[0092] Although the specific contents, implementation algorithms and drawings of the present invention are disclosed for the purpose of illustration, the purpose is to help understand the contents of the present invention and implement them accordingly, it can be understood by those skilled in the art that various substitutions, changes and modifications are possible without departing from the spirit and scope of the present invention and the appended claims. The present invention should not be limited to the contents disclosed in the best embodiment of this specification and the drawings, and the scope of protection claimed by the present invention shall be subject to the scope defined in the claims.

Claims

1. A cross-domain small sample relationship extraction method for learning fine-grained general knowledge, It is characterized in that The following steps are involved: Perform data preprocessing, including concatenating the semantic hint template at the end of each sentence in the dataset; Constructing a cross-domain small sample relationship extraction model, wherein the cross-domain small sample relationship extraction model includes a feature extraction network, a dual-channel general knowledge learning network, a relationship comparison learning network, and a relationship classification network, wherein the dual-channel general knowledge learning network includes an implicit general knowledge learning network and an explicit general knowledge learning network; Using the training set in the data set, the cross-domain small sample relationship extraction model is trained through the loss function of the implicit general knowledge learning network, the relationship contrast learning loss function and the relationship classification loss function, and the optimal model is obtained using the validation set; The optimal model is used to extract relations in sentences of the target domain.

2. The method according to claim 1, It is characterized in that The data preprocessing also includes: using virtual tags to emphasize the role of entities in relationship extraction, and adding virtual tags before and after the head entity and the tail entity respectively; the virtual tags use undefined tags reserved in BERT.

3. The method according to claim 1, It is characterized in that The processing process of the dual-channel general knowledge learning network includes: the explicit general knowledge learning network uses convolution to capture shallow common knowledge from the knowledge representation of the source domain and the target domain; the implicit general knowledge learning network establishes the association of implicit knowledge between domains by eliminating the relevant differences between knowledge within the domain and knowledge between domains.

4. The method according to claim 1, It is characterized in that The relation contrastive learning network is a dropout-based relation contrastive learning network, which converts the coarse-grained public knowledge in the relation prototypes into fine-grained public knowledge by learning the local subtle differences between the relation prototypes; the relation classification network uses the class center of the relation representation of the same type of relationship as the relation prototype, and classifies the relationship to be predicted into the relation prototype that is most similar to it, wherein a parameter-free metric function is used to measure the similarity.

5. The method according to claim 1, It is characterized in that The loss function of the implicit general knowledge learning network eliminates the correlation differences in data distribution between domains, allowing the model to strengthen the association of implicit public knowledge between domains, thereby effectively using this knowledge to guide the relationship extraction of the target domain; the loss function of the implicit general knowledge learning network is expressed as follows: L P =|P S -P ST | Among them, P S is the mean value of the correlation coefficients between different relation prototypes in the source domain, P ST is the mean of the correlation coefficients of different relationship prototypes between the source domain and the target domain.

6. The method according to claim 1, It is characterized in that The relation contrastive learning loss function enables the model to learn fine-grained general relation knowledge, thereby effectively distinguishing similar relations in the target domain; the relation contrastive learning loss function is expressed as follows: Among them, p i For the i-th type of relation prototype in the support set, p i ' represents the i-th relationship prototype in the support set after Dropout, τ 1 is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and N represents the total number of relationship prototypes.

7. The method according to claim 1, It is characterized in that The relationship classification loss function enables the model to extract relationships of different categories, classify the samples in the query set into a certain category prototype in the support set in a task consisting of a set of sampled data, and train the model on multiple sets of tasks that are repeatedly sampled; the relationship classification loss function is expressed as follows: Among them, q j is the jth sample in the query set, p q Indicates the relation prototype category to which the sample belongs, τ 2 is the temperature parameter used to control the smoothness of the similarity, d represents the standardized cosine similarity distance function, and G represents the total number of samples to be classified.

8. A cross-domain small sample relationship extraction device for learning fine-grained general knowledge, It is characterized in that include: A data preprocessing module is used to perform data preprocessing, including splicing the semantic hint template at the end of each sentence in the data set; A model building module, used to build a cross-domain small sample relationship extraction model, wherein the cross-domain small sample relationship extraction model includes a feature extraction network, a dual-channel general knowledge learning network, a relationship comparison learning network, and a relationship classification network, wherein the dual-channel general knowledge learning network includes an implicit general knowledge learning network and an explicit general knowledge learning network; A model training module is used to train the cross-domain small sample relationship extraction model by using the training set in the data set through the implicit knowledge learning network loss function, the relationship contrast learning loss function and the relationship classification loss function, and obtain the optimal model by using the validation set; The relation extraction module is used to extract the relations in the sentences of the target domain using the optimal model.

9. A computer device, It is characterized in that The method comprises a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a computer, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • Small sample relation classification method based on graph neural network

    CN116401591A

  • Cross-domain small sample relation extraction method and system based on enhanced contrast learning fine tuning

    CN116561308A

  • Cross-domain small sample relation extraction method and device for learning discriminative semantics and multi-view context

    CN117852523A

Cited By

  • Method and device for extracting few-sample relation based on multi-knowledge enhanced prototype network

    CN120068874A

  • Few-Shot Relation Extraction Method and Device Based on Multi-Knowledge Enhanced Prototype Network

    CN120068874B

  • Distributed education terminal collaborative learning and resource sharing system construction method

    CN120852105A

  • Double-channel adaptive continuous learning method and device for small sample industrial scene

    CN121390178A