A relationship extraction method and device
By integrating information from multiple source knowledge bases into the target domain through transfer learning, the problem of high human resource costs caused by insufficient initial data is solved, and efficient and accurate relational data prediction is achieved.
Patent Information
- Application Number
- CN202310801353.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-30
- Publication Date
- 2026-05-15
- Estimated Expiration
- 2043-06-30
AI Technical Summary
Existing relation extraction techniques require costly manual annotation when the initial data is insufficient, resulting in high labor costs and a time-consuming and labor-intensive annotation process. Furthermore, unsupervised methods lack accuracy and cannot adapt to complex scenarios.
By employing transfer learning, information is transferred from knowledge bases of multiple source domains to the target domain. Multiple classification models are used to predict relational data in the target domain, reducing the need for professional annotation manpower. Transfer learning is used to integrate knowledge bases of source domains into the target domain for relational data prediction.
It reduces the manpower required for professional annotation of initial data, improves the accuracy and efficiency of relational data prediction, and adapts to data scenarios in different fields.
Smart Images

Figure CN116842952B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of deep learning technology, and in particular to a relation extraction method and apparatus. Background Technology
[0002] Current relation extraction techniques mostly employ supervised deep learning. Classified by model structure, they can be divided into pipeline models, which separate entity recognition from relation extraction, and joint models, which combine the two processes. Both types of models require extensive manual annotation of relation data in the initial preparation phase, which is not only costly but also time-consuming and labor-intensive. Furthermore, many scenarios involve different domains, and engineers often encounter data from unfamiliar domains, making the annotation process even more challenging. From a technical perspective, a lack of labeled data can lead to low accuracy in relation extraction using supervised deep learning methods, and severe scarcity of labeled data can render supervised deep learning models unusable.
[0003] Besides supervised relation extraction techniques, there are also unsupervised relation extraction techniques, such as Open Information Extraction (Open Information Extraction). Open Information Extraction relies on general constraints and heuristics to traverse a corpus to obtain different types of relations in text. While this allows for obtaining desired relation data without human intervention, the lack of data to train the model, relying solely on predefined rules, makes it difficult to accurately adapt to the current data context. Therefore, the accuracy reduction caused by unsupervised methods is significant. Furthermore, because semantic rules are predefined rather than changing based on input, Open Information Extraction cannot accurately cover the semantic structure of all input data, leading to inaccurate relation extraction boundaries (e.g., inaccurate subject-verb segmentation in complex clauses). Consequently, relations obtained through Open Information Extraction are less normative than those obtained under supervised methods (e.g., the predicate is not a verb or the subject contains a verb).
[0004] In addition, there are other methods that can alleviate the problems of supervised relation extraction techniques to some extent, such as weak supervision and distant supervision machine training. Weak supervision aims to reduce the difficulty of data acquisition by selecting a small number of seed triples as starting data and using weak labels to provide supervisory signals, mapping input data to stronger labels. Weak supervision can reduce the amount of labeled training data needed by reducing the user's reliance on domain-specific knowledge. However, it still has relatively high requirements for the selection of starting data, requiring a certain quantity and sufficient discrimination. It still requires professional human intervention; a lack of professional human involvement, resulting in insufficient or poorly discriminative starting data, will lead to low accuracy in models trained using weak supervision. Distant supervision aims to search for all knowledge in an existing knowledge base and automatically label the data using existing knowledge to obtain a large amount of labeled data to support the training process. The disadvantage of distant supervision is that it requires a knowledge base directly related to the target domain as a prerequisite. If the target domain is broad, covering multiple unrelated domains, this condition is often difficult to meet. Summary of the Invention
[0005] This invention provides a relation extraction method and apparatus to address the problem of high labor costs caused by the reliance on costly manual annotation when there is insufficient initial data.
[0006] In a first aspect, embodiments of the present invention provide a relation extraction method, including:
[0007] First data is obtained from a corpus corresponding to a first target domain. The first data includes a first entity set and a first text feature. The first data is mapped to first vector data through a bag-of-words model. The first vector data includes a first entity vector corresponding to the first entity set and a first text vector corresponding to the first text feature.
[0008] The first vector data is input into M classification models respectively to obtain M prediction results; each prediction result includes the predicted probability of the entity relationship between each first entity pair in the first entity set as N candidate relations respectively. The M classification models correspond to M source knowledge bases. Each classification model is trained on an initial model based on the sample vector data of the corresponding source knowledge base. The sample vector data includes a second entity vector with a second relation vector label and a second text vector. M and N are both positive integers.
[0009] Based on the M prediction results, the final relationship of each first entity pair in the first entity set is determined from the N candidate relationships.
[0010] In the above technical solution, transfer learning is used as a relation extraction method to transfer knowledge from the source domain to the target domain and integrate information from multiple source domains to predict relation data in the first target domain, which can reduce the required professional annotation manpower.
[0011] Optionally, determining the final relationship of each first entity pair in the first entity set based on the M prediction results includes: for each first entity pair in the first entity set, performing the following steps: for each candidate relationship among the N candidate relationships, determining M predicted probabilities of the entity relationship of the first entity pair as the candidate relationship from the M prediction results; determining the risk value corresponding to the entity relationship of the first entity pair as the candidate relationship based on the determined M prediction probabilities; and determining the final relationship of the first entity pair from the N candidate relationships based on the N risk values corresponding to the entity relationships of the first entity pair as the N candidate relationships. This technical solution provides a convenient way to determine the final relationship of each first entity pair based on M prediction results corresponding to M classification models.
[0012] Optionally, determining the final relationship of the first entity pair from the N candidate relationships based on the N risk values corresponding to the N candidate relationships, according to the entity relationships of the first entity pair, includes: determining the candidate relationship corresponding to the smallest risk value among the N candidate relationships as the final relationship of the first entity pair. Through this technical solution, for a first entity pair, if the entity relationship of the first entity pair is the candidate relationship corresponding to the smallest risk value among the N candidate relationships, it indicates that the entity relationship of the first entity pair is most likely to be this candidate relationship, thus obtaining a more accurate prediction result.
[0013] Optionally, before inputting the first vector data into M classification models to obtain M prediction results, the method further includes: for each of the L source knowledge bases, performing a significance evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain; where L is an integer greater than or equal to M; and determining the M source knowledge bases from the L source knowledge bases based on their contribution to the first target domain. This technical solution allows for the selection of source knowledge bases with high relevance to the first target domain, and then using the classification models corresponding to these highly relevant source knowledge bases to predict relational data in the first target domain, thereby improving the accuracy of the relational data prediction results for the first target domain.
[0014] Optionally, the step of performing a saliency evaluation on each of the L source knowledge bases and the first target domain to obtain the contribution of each source knowledge base to the first target domain includes: for each of the L source knowledge bases, performing the following steps: determining the domain relevance score between the source knowledge base and the corpus corresponding to the first target domain; determining the KL divergence between a first conditional probability distribution and a second conditional probability distribution, where the first conditional probability distribution is the probability distribution of predicting the vector representation of the first entity set through the classification model corresponding to the source knowledge base, and the second conditional probability distribution is the probability distribution of predicting the vector representation of the relationship between entities through the classification model corresponding to the source knowledge base; and determining the contribution of the source knowledge base to the first target domain based on the relevance score and the KL divergence. This technical solution provides a convenient way to determine the contribution of each source knowledge base to the first target domain.
[0015] Optionally, after determining the final relation of each first entity pair in the first entity set from the N candidate relations based on the M prediction results, the method further includes: inputting the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain a first relation vector corresponding to the final relation of each first entity pair in the first entity set; using the first entity vector, the first text vector, and the first relation vector as inputs to the initial model, and training the initial model with the minimum loss function of the initial model as the optimization objective, to obtain a classification model corresponding to the first target domain; the classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relations in the second target domain, where K is a positive integer. Through this technical solution, after each generation of a knowledge base for a target domain, the knowledge within it can be added to the training process as new input for the next task. This knowledge base for the target domain can be used together with existing source knowledge bases as a source knowledge base for predicting relation data in the next target domain. In this way, the source knowledge base accumulates continuously with each use, and this continuous knowledge transfer process makes the relation prediction results for new knowledge more reliable.
[0016] Optionally, after determining the final relation of each first entity pair in the first entity set from the N candidate relations based on the M prediction results, the method further includes: inputting the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain a first relation vector corresponding to the final relation of each first entity pair in the first entity set; for each of the M source knowledge bases, determining a first concept matrix corresponding to each source knowledge base based on a first input matrix composed of a second text vector, a second relation vector, and a second text vector; and determining a second concept corresponding to the target domain based on a second input matrix composed of the first entity vector, the first text vector, and the first relation vector. The M first concept matrices and second concept matrices corresponding to the M source knowledge bases are merged to obtain a general concept matrix. Update values for the first entity vector, first text vector, and first relation vector are obtained based on the differences between these matrices and the general concept matrix. These updated values are used as input to the initial model, and the initial model is trained with the minimum loss function as the optimization objective to obtain a classification model corresponding to the first target domain. The classification model corresponding to the first target domain is used together with the classification models corresponding to the K source domains to predict relationships in the second target domain, where K is a positive integer. This technical solution achieves two objectives. First, by using incremental learning, the information representation within the knowledge base of a new domain is adjusted incrementally, thereby significantly reducing the correlation between information and improving the accuracy of information representation in the new knowledge base. Second, after each generation of a knowledge base for a target domain, the knowledge within it can be added to the training process as new input for the next task. This target domain knowledge base can be used together with existing source knowledge bases as a source knowledge base for predicting relational data in the next target domain. In this way, the source of the knowledge base accumulates continuously with each use, and through this continuous knowledge transfer process, the relational prediction results for new knowledge become more reliable.
[0017] Secondly, embodiments of the present invention also provide a relation extraction apparatus, comprising:
[0018] The acquisition unit is used to acquire first data from a corpus corresponding to a first target domain, wherein the first data includes a first entity set and a first text feature.
[0019] The processing unit is configured to map the first data into first vector data through a bag-of-words model, the first vector data including a first entity vector corresponding to the first entity set and a first text vector corresponding to the first text feature; input the first vector data into M classification models respectively to obtain M prediction results; and determine the final relationship of each first entity pair in the first entity set from N candidate relationships based on the M prediction results; wherein each prediction result includes the predicted probability of the inter-entity relationship of each first entity pair in the first entity set as a prediction of the N candidate relationships, the M classification models correspond to M source knowledge bases, each classification model is obtained by training an initial model based on sample vector data of the corresponding source knowledge base, the sample vector data includes a second entity vector with a second relationship vector label and a second text vector, and M and N are both positive integers.
[0020] Optionally, the processing unit is specifically configured to: for each first entity pair in the first entity set, perform the following: for each candidate relation among the N candidate relations, determine from the M prediction results the M predicted probabilities that the inter-entity relationship of the first entity pair is the candidate relation; determine the risk value corresponding to the inter-entity relationship of the first entity pair as the candidate relation based on the determined M prediction probabilities; and determine the final relation of the first entity pair from the N candidate relations based on the N risk values corresponding to the N candidate relations, where the inter-entity relationship of the first entity pair is the same as the inter-entity relationship of the first entity pair.
[0021] Optionally, the processing unit is specifically configured to: determine the candidate relationship corresponding to the smallest risk value among the N candidate relationships as the final relationship of the first entity pair, based on the N risk values corresponding to the entity relationships of the first entity pair.
[0022] Optionally, the processing unit is specifically configured to: for each of the L source knowledge bases, perform a saliency evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain; where L is an integer greater than or equal to M; and determine the M source knowledge bases from the L source knowledge bases based on the contribution of the L source knowledge bases to the first target domain.
[0023] Optionally, the processing unit is specifically configured to: perform a saliency evaluation on each of the L source knowledge bases and the first target domain to obtain the contribution of each source knowledge base to the first target domain, including: for each of the L source knowledge bases, performing: determining the domain relevance score between the source knowledge base and the corpus corresponding to the first target domain; determining the KL divergence between a first conditional probability distribution and a second conditional probability distribution, wherein the first conditional probability distribution is the probability distribution of predicting the vector representation of the first entity set through the classification model corresponding to the source knowledge base, and the second conditional probability distribution is the probability distribution of predicting the vector representation of the relationship between entities through the classification model corresponding to the source knowledge base; and determining the contribution of the source knowledge base to the first target domain based on the relevance score and the KL divergence.
[0024] Optionally, the processing unit is further configured to: input the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain a first relation vector corresponding to the final relation of each first entity pair in the first entity set; use the first entity vector, the first text vector, and the first relation vector as input to the initial model, and train the initial model with the minimum loss function of the initial model as the optimization objective to obtain a classification model corresponding to the first target domain; the classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relations in the second target domain, where K is a positive integer.
[0025] Optionally, the processing unit is further configured to: input the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain the first relation vector corresponding to the final relation of each first entity pair in the first entity set; for each of the M source knowledge bases, determine the first concept matrix corresponding to each source knowledge base based on the second text vector, the second relation vector, and the first input matrix composed of the second text vector; determine the second concept matrix corresponding to the target domain based on the second input matrix composed of the first entity vector, the first text vector, and the first relation vector; and input the M first concept matrices corresponding to the M source knowledge bases into the first relation vector. The first entity vector and the second concept matrix are merged to obtain a general concept matrix. Update values for the first entity vector, the first text vector, and the first relationship vector are obtained based on the differences between these vectors and the general concept matrix. These updated values are used as input to the initial model, and the initial model is trained with the minimum loss function as the optimization objective to obtain a classification model corresponding to the first target domain. This classification model, along with classification models corresponding to K source domains, is used to predict relationships in the second target domain, where K is a positive integer.
[0026] Thirdly, embodiments of the present invention provide a computing device, comprising:
[0027] Memory, used to store program instructions;
[0028] The processor is used to call program instructions stored in the memory and extract them according to the obtained program execution relationship.
[0029] Fourthly, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions for causing a computer to perform a relation extraction method. Attached Figure Description
[0030] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0031] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention.
[0032] Figure 2A schematic diagram illustrating the training process of the classification model provided in an embodiment of the present invention;
[0033] Figure 3 This is a schematic diagram of the bag-of-words model provided in an embodiment of the present invention;
[0034] Figure 4 A flowchart illustrating a relation extraction method provided in an embodiment of the present invention;
[0035] Figure 5 This is a schematic diagram of a relation extraction device provided in an embodiment of the present invention. Detailed Implementation
[0036] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this invention, and not all embodiments. Based on the embodiments of this invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this invention.
[0037] Figure 1 This is a schematic diagram of the device structure of the hardware operating environment involved in the embodiments of the present invention.
[0038] like Figure 1 As shown, the device 100 may include a processor 110, a memory 120, a network interface 130, a user interface 140, and a communication bus 150. The communication bus 150 is used to enable communication between these components.
[0039] The processor 110 is the control center of the device 100. It connects various parts of the device 100 through various interfaces and lines. By running or executing software programs and / or modules stored in the memory 120, and by calling data stored in the memory 120, it performs various functions of the device 100 and processes data. Optionally, the processor 110 may include one or more processing units.
[0040] The memory 120 can be used to store software programs and modules. The processor 110 executes various functional applications and data processing by running the software programs and modules stored in the memory 120. The memory 120 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function, etc.; the data storage area may store data such as the original image, watermarked image, and carrier image of the hidden watermarked image. In addition, the memory 120 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0041] Optionally, the network interface 130 may include a standard wired interface or a wireless interface (such as a Wi-Fi interface). In this embodiment of the invention, the network interface 130 is mainly used to connect to the backend server and communicate with the backend server for data.
[0042] User interface 140 may include a display screen and an input unit such as a keyboard. Optionally, user interface 140 may also include a standard wired interface or a wireless interface. In this embodiment of the invention, user interface 140 can be used to connect to a backend server and communicate with the backend server; user interface 140 can also be used to connect to a client (user terminal) and communicate with the client.
[0043] The processor 110 can be used to call a program stored in the memory 120 for executing a relation extraction method, and to perform the operations described in the following embodiments of the relation extraction method.
[0044] It should be noted that the above Figure 1 The structure shown is merely an example and does not constitute a limitation on the device. It may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0045] The terminology involved in this invention will be explained below.
[0046] Relation extraction technology aims to identify the relationship between entities as subjects and objects by specifying entity content, and to find the relationship between subjects and objects from unstructured or semi-structured data, and represent it as an entity-relation triple of (subject, relation, object).
[0047] Transfer learning aims to apply solutions to existing problem domains to other different but related problem domains. By transferring knowledge to existing knowledge, if successful, it can avoid expensive data labeling, save significant human resources, and greatly increase learning efficiency.
[0048] Incremental learning technology aims to update existing solution models so that they can increase their ability to recognize new target knowledge without losing the original knowledge they have acquired. This allows for continuous iteration in an incremental manner, significantly reducing the cost of training models.
[0049] This application addresses the problem of high labor costs associated with relying on costly manual annotation to meet the initial data requirements of relation extraction techniques when initial data is insufficient. It provides a relation extraction scheme that utilizes transfer learning to transfer knowledge from the source domain to the target domain, integrating information from multiple source domains to predict relation data in the target domain, thus reducing the required professional annotation manpower. For example, for one or more known entity pairs in the target domain, multiple classification models are trained using data from multiple source knowledge bases to predict the entity relationships between each entity pair. Taking the entity pair <wind power generation, wind turbine> as an example, the entity relationship between <wind power generation, wind turbine> is <use>. It should be understood that in this application's embodiments, the knowledge base of the source domain is referred to as the source knowledge base, with one source domain corresponding to one source knowledge base, which will not be elaborated further below.
[0050] The relationship extraction method provided in the embodiments of this application will be described in detail below.
[0051] In this embodiment, classification models can be trained separately based on multiple existing source knowledge bases, and then entity relationship prediction can be performed on the target domain using the trained classification models.
[0052] For example, the existing multiple source knowledge bases are represented as S1, S2, S3, S4…S n Each source knowledge base includes: a knowledge relation triple <entity1, relation, entity2>, which encompasses entities and relations between entities within the domain; and basic corpus related to the domain (e.g., papers). The corpus includes textual data containing professional knowledge, such as papers and patents within the target domain.
[0053] The unstructured corpus of the target domain is represented as C * The corpus includes textual data containing professional knowledge, such as papers and patents in the target field.
[0054] The following example uses a source knowledge base to illustrate the process of training a classification model using data from that source knowledge base. Figure 2 As shown, the process of training a classification model includes the following steps:
[0055] Step 201: Obtain the first sample data from the source knowledge base.
[0056] First, extract the entity set and the list of relationships between entities from the source knowledge base. For example, taking the source knowledge base as the wind energy domain as an example, extract wind energy-related entities (such as wind power generation, wind turbines, etc.) from the source knowledge base of the wind energy domain to form an entity set, and obtain the relationships between entities in the entity set, such as <wind power generation, usage, wind turbine>.
[0057] Then, using natural language processing libraries such as NLTK and Jieba, which offer stable and accurate results, the corpus in the source knowledge base is processed through word segmentation, part-of-speech tagging, and other operations to transform it into standardized input. For example, the input "wind turbine generator converts wind energy into mechanical work" is transformed into "wind turbine generator / will / wind energy / convert / mechanical work". For English input, additional part-of-speech tagging is performed to restore variations of words like "asked" back to their original form "ask".
[0058] Next, textual features are extracted from the corpus in the source knowledge base as input. The specific semantic features to be extracted are as follows:
[0059] (1) The head token of entity mention;
[0060] (2) Bag-of-words representation of each entity (or relation);
[0061] (3) Words between two entities e and e′;
[0062] (4) The combination of head words e and e′;
[0063] (5) Part-of-speech (POS) tag of words between two entity mentions;
[0064] (6) Left / right 3-word window of each entity (or relation) mentions;
[0065] (7) Entity Order: Whether e is before e';
[0066] (8) Entity distance: the number of words between e and e';
[0067] (9) Unigrams before and after each entity (or relation).
[0068] Except for feature (2), each of the above other features can be obtained by basic methods. For example, the词性 of the words between two entities can be obtained through a词性 tagging library, and the number of words between two entities can be directly calculated, etc. For how to obtain feature (2), please refer to the relevant description in the following text.
[0069] After the above process, three different types of data can be obtained: entities, relations between entities, and text features. Taking the wind energy field as an example, the three types of data that can be obtained from the source knowledge base S1 in the wind energy field include:
[0070] (1) Entities, that is, professional noun terms with actual meanings in this field, such as wind power generation, wind speed, wind shear index, etc.
[0071] (2) Relations between entities, that is, relation phrases describing the connections between the above entities, such as use, based on, include, etc.
[0072] (3) Text features, that is, text semantic features obtained from the text context describing the relations between entities. For example, in the corpus data in the wind energy field: "The wake effect imposes significant aerodynamic interactions between wind turbines, so advanced wind power control considering wake dynamics is very important for wind energy grid connection", the extracted text features are as follows:
[0073] For the entity pair, extract the first words of each entity, that is, "wake" and "advanced".
[0074] For the entity pair, extract the combination of the first words of each entity, that is, "wake advanced".
[0075] Extract the words between entities, that is, the words between "wake dynamics" and "advanced wind power control", which is "of" here.
[0076] Extract the number of words between entities, that is, the number of words between "wake dynamics" and "advanced wind power control", which is 1 here.
[0077] Extract the词性 of the words between entities, that is, the词性 of the words between "wake dynamics" and "advanced wind power control", which is a particle here.
[0078] For the context word extraction with a window of 3 for entities (or relations), that is, extract the three words before and after "wake dynamics", "advanced wind power control", and "consider", which are "effect so consider" and "is very important for wind energy grid connection" here.
[0079] The order between entities, i.e. whether entity 1 appears before entity 2, is yes in this case.
[0080] The result of extracting unary word segmentation from the context of an entity (or relation) is: "Wake / flow / effect / applied / significant / aerodynamic / dynamic / interaction / between / wind / turbine / machines, / so / considered".
[0081] For ease of description, the source knowledge base is denoted by S, and the target domain knowledge base is denoted by *.
[0082] The above process yields entity e from the source knowledge base. s Relationships between entities s and text features f s After obtaining the data, the first sample data corresponding to the source knowledge base is finally obtained, including the entity set E. s Entity Relationship Set Text feature set F S Based on a similar process described above, entity e in the target domain can be obtained. t Relationships between entities t and text features f t The data is used to ultimately obtain the knowledge base data for the target domain, including the entity set E. * Entity Relationship Set Text feature set F * .in:
[0083] Entity set e s ∈E s ,e t ∈E * ;
[0084] Relationship between entities
[0085] Text feature f s ∈F S ,f t ∈F * .
[0086] After obtaining the first sample data, the model can learn the vector representation of the input data. For example, the bag-of-words model of deep learning can be used to generate vector forms of three types of data: entity set, entity relationship and text feature.
[0087] Step 202: Input the first sample data into the bag-of-words model to obtain the sample vector data corresponding to the source knowledge base.
[0088] To transform the three types of data into vector form, we first perform simple word embedding, converting the entity set data and relation data into word vectors. Then, we learn the entities (V) using the bag-of-words model. e ) and relation (V) y The vector representation of ), such as Figure 3 As shown, Figure 3 L e and L r Let these represent the loss functions of the two bag-of-words models, respectively. The co-occurrence frequency of entities in the corpus and text features is represented by the loss function. Let t represent the co-occurrence frequency of relations with text features in the corpus, and t represent the context window size. The illustration shows that for entity e, its vector is calculated from the set of text features f with a window size of t and the co-occurrence frequency of features with the entity (the same applies to entity relation y). Here, entities and relations will have two different losses, but they are not separated during the learning process. Instead, they are combined into a single loss for simultaneous learning, which can make the vector representation more accurate, as shown in the following formula (1):
[0089]
[0090] Through continuous updates V e V f V y To reduce loss, learning continues until a local optimum is reached, i.e., L reaches its minimum value, at which point learning stops. Through this bag-of-words model, we obtain the vector representation V of the entities corresponding to the respective entities in the source knowledge base. e Vector representation of relationships between entities V y and the vector representation of text features V f In this embodiment, representation learning can be performed on each source knowledge base separately, thereby transforming the source knowledge base data into sample vector data, including entity vectors. relation vector Feature vector It should be understood that the bag-of-words model can also be used to transform corpus data into entity vectors. relation vector Feature vector
[0091] Step 203: Train the initial model using the sample vector data to obtain the classification model corresponding to the source knowledge base.
[0092] In this embodiment of the application, entity vectors can be used. relation vector Feature vector As input to the initial model, the initial model is trained with the minimum loss function of the initial model as the optimization objective, and the classification model corresponding to the source knowledge base is obtained.
[0093] In this embodiment of the application, for example, there are L existing source knowledge bases. Each source knowledge base can be trained based on the sample vector data corresponding to each source knowledge base to obtain a classification model. Therefore, L source knowledge bases can yield L classification models, where L is a positive integer.
[0094] Based on the above description Figure 4 The present invention provides an exemplary flow of a relation extraction method, which can be executed by a relation extraction device located at, for example, [location omitted]. Figure 1 The device 100 shown can also be the same device 100.
[0095] like Figure 4 As shown, the specific steps of this relation extraction method include the following:
[0096] Step 401: Obtain first data from the corpus corresponding to the first target domain. The first data includes a first entity set and first text features.
[0097] Here, the specific implementation of obtaining the first data from the corpus corresponding to the first target domain can be found in the relevant description of obtaining the first sample data in step 201 above, and will not be repeated here.
[0098] Step 402: Map the first data to first vector data through the bag-of-words model. The first vector data includes the first entity vector corresponding to the first entity set and the first text vector corresponding to the first text feature.
[0099] Here, the specific implementation of step 402 can be referred to the relevant description of obtaining the sample vector data corresponding to the source knowledge base in step 202 above, and will not be repeated here.
[0100] Step 403: Input the first vector data into M classification models respectively to obtain M prediction results.
[0101] In step 403, the M classification models correspond to M source knowledge bases. Taking source knowledge bases S1, S2, and S3 as examples, source knowledge base S1 corresponds to classification model 1, source knowledge base S2 corresponds to classification model 2, and source knowledge base S3 corresponds to classification model 3. Each classification model is obtained by training an initial model using sample vector data from the corresponding source knowledge base. The sample vector data includes a second entity vector with a second relation vector label and a second text vector, where M is a positive integer. For example, the sample vector data of source knowledge base S1 includes a second entity vector with a second relation vector label and a second text vector. Entity vector of the label and eigenvectors Classification model 1 is based on a relation vector. Entity vector of the label and eigenvectors The initial model is trained to obtain the data. For example, the sample vector data of the source knowledge base S2 includes relation vectors. Entity vector of the label and eigenvectors Classification model 1 is based on a relation vector. Entity vector of the label and eigenvectors The initial model was trained to obtain the result.
[0102] In the M prediction results, each prediction result includes the predicted probability of the entity relationship between each first entity pair in the first entity set being one of N candidate relations, where N is a positive integer. For example, taking the source knowledge base S1 as an example, the first entity set corresponding to the source knowledge base S1 includes first entity pair 1, first entity pair 2, first entity pair 3, and N candidate relations being candidate relation 1 and candidate relation 2, respectively. The prediction results corresponding to the source knowledge base S1 include the probability that first entity pair 1 is candidate relation 1, the probability that first entity pair 1 is candidate relation 2, the probability that first entity pair 2 is candidate relation 1, the probability that first entity pair 2 is candidate relation 2, the probability that first entity pair 3 is candidate relation 1, and the probability that first entity pair 3 is candidate relation 2.
[0103] In this embodiment of the application, for example, there are L existing source knowledge bases, where L is a positive integer greater than or equal to M. Before step 403 above, the existing L source knowledge bases may not be filtered. That is, all L source knowledge bases are used to predict the relationships between entities in the first target domain, i.e., M equals L in step 403.
[0104] Optionally, before step 403 above, the L source knowledge bases are screened. For example, a saliency evaluation is performed on each of the L source knowledge bases and the first target domain to obtain the contribution of each source knowledge base to the first target domain. Then, M source knowledge bases with high contribution are selected from the L source knowledge bases to predict the relationships between entities in the first target domain. In this case, M is less than L, for example, L is 5 and M is 3, that is, 3 source knowledge bases with high contribution to the first target domain are selected from 5 source knowledge bases. Then, the classification models trained by these 3 source knowledge bases with high contribution to the first target domain are used to predict the relationship data in the first target domain.
[0105] The significance assessment can include the following two aspects:
[0106] Firstly, the assessment of domain relevance.
[0107] (1) Domain relevance assessment, for example, for each of the L source knowledge bases, determining the domain relevance score between each source knowledge base and the corpus corresponding to the first target domain. Let L be the L source knowledge bases, including source knowledge base S1, source knowledge base S2, source knowledge base S3, and source knowledge base S4, and the corpus corresponding to the first target domain be S... * Taking 1 as an example, determine S1, S2, S3, S4 and S respectively. * The domain relevance score between 1 and 4 can be used to determine the domain relevance scores of the four domains.
[0108] For a source knowledge base S i It is said that the source knowledge base S is judged. i With Corpus S * The correlation can be discovered by finding the correlation in the corpus S * The entity list in the corpus S, and the judgment of the corpus S * The entity list in the source knowledge base S i The information relevance is used to obtain a domain relevance score for evaluation. This domain relevance score can be expressed by the following formula (1):
[0109]
[0110] Among them, E * For corpus S * The entity set in the middle, Source knowledge base S i The set of entities in.
[0111] The second aspect is the assessment of discriminative ability.
[0112] Discriminative ability is the ability to determine the relational data between the source domain and the primary target domain of the reasoning. In traditional reasoning processes, this is generally done according to y t (relation)->f t ->x t The process of (input) involves labeling the relationships in the first target domain to entities within the first target domain by analyzing the features of the text in the first target domain. This application changes this process, making it y t ->y s ->f s ->f t ->x tThe process, which generates relation labels for entities in the first target domain by comparing the correlation between the source domain relations and the first target domain relations, and comparing the correlation between the source domain text features and the first target domain text features, is adapted to the characteristics of transfer learning. When "given the first target domain relations, the probability p(f) of the source domain text features being observed..." s |y t ")" and "the probability p(f) of source domain text features being observed given a first target domain entity". s |x t The more dissimilar the pairs of target entities are, the greater the risk in labeling the relationships between them. Based on this concept, the relevant calculation formula is as follows:
[0113] The formula for standard KL divergence refers to the information loss when the distribution p(x) is used to approximate q(x), as shown in formula (3):
[0114]
[0115] Based on the definition of KL divergence, the capability φ of a single knowledge base is related to the KL divergence D. KL Negative correlation, meaning the smaller the information loss when approximating information, the stronger the knowledge base's capabilities. As shown in formula (4), F refers to the feature set, and ∝ represents positive correlation. Because the right half is negative, φ and the KL divergence D... KL Negative correlation.
[0116]
[0117] Formula (5) for calculating the discriminative power Φ of a single knowledge base:
[0118]
[0119] In this embodiment, the KL divergence between a first conditional probability distribution P and a second conditional probability distribution Q can be determined. The first conditional probability distribution P is the probability distribution of the vector representation of the first entity set predicted by the classification model corresponding to the source knowledge base, and the second conditional probability distribution Q is the probability distribution of the vector representation of the relationship between entities predicted by the classification model corresponding to the source knowledge base. Then, based on the KL divergence, the discriminative ability of the source knowledge base for the first target domain can be determined.
[0120] The following will illustrate this with specific examples.
[0121] For example, using a source knowledge base in the field of electrical energy as the relevant knowledge base S i And obtained text features in the field of electric energy. Then, when going to the corpus S related to predicting wind energy... t The data in (x)t =<Wake Dynamics, Advanced Wind Power Control>,…;y t When using [using, based on, including, ...], the KL divergence formula will be used as the primary evaluation method. Specifically, it is done through S... i The representation models respectively calculate x t The conditional probability distribution of the representation and y t The conditional probability distribution of the representation Then calculate the KL divergence between the two, D = D KL (P||Q). In the formula for KL divergence, a larger KL divergence indicates a greater approximation loss between the two distributions, while a smaller divergence indicates more similar information. Based on this standard, the source knowledge base's ability to judge knowledge in the first target domain requires closer approximation of the two information, meaning it is negatively correlated with KL divergence. Furthermore, the source knowledge base's ability to discriminate knowledge in the first target domain, Φ, depends on providing the distribution with the lowest KL divergence (x...). t ,y t The sum of the KL divergences of (x). In the example above, this is expressed as calculating (x) t =<Wake Dynamics, Advanced Wind Power Control>, y t =Considering the data, the source knowledge base yields the lowest KL divergence, and this KL divergence will be used as part of the discriminative power of the source knowledge base. For all x t Find the corresponding y t And summing all the KL divergences, we get the evaluation capability Φ of the power energy knowledge base for the wind energy field.
[0122] After determining the relevance score and KL divergence, the contribution of each source knowledge base to the first target domain can be determined based on the relevance score and discriminative ability. Then, based on the contributions of the L source knowledge bases to the first target domain, M source knowledge bases are determined from the L source knowledge bases.
[0123] For example, the saliency of each knowledge base to the target corpus can be integrated in a weighted manner, and the risk of using each knowledge base can be derived. For example, the following formula (6) can be used to calculate the saliency of each knowledge base from all possible sets. Find the set with the maximum weighted significance.
[0124]
[0125] Taking the use of knowledge bases from multiple source domains (electricity, nuclear energy, solar energy) to predict the inter-entity relationships in the target domain (wind energy) as an example, the contribution of each source knowledge base is derived from the two criteria in (3) (domain relevance, discriminative ability), specifically C=α1σ(S′,S* )+α2Φ(S′,S * (α1 and α2 are hyperparameters that can be adjusted as needed.) Thus, the capabilities of a single source knowledge base have been derived. However, since there are multiple source knowledge bases, we still need to select the set of source knowledge bases that contribute the most to the target domain. Therefore, we select the multiple source knowledge bases with the highest contributions to form a source knowledge base set. In the example above, the solar energy knowledge base was excluded due to its low contribution, resulting in the following set of source knowledge bases:
[0126] After obtaining the source knowledge base set, entity pairs x are predicted using the domain-specific model. t The corresponding relation y t For example, by using the following formula (7), in the set... For x t Given label y t Knowledge base collection
[0127]
[0128] Because there are multiple source knowledge bases, multiple relations can be combined into a relation set Y for the same entity pair. For example, for the same entity pair <wake dynamics, advanced wind power control>, the two source knowledge bases, electrical energy and solar energy, may predict different relations <consider, contain>.
[0129] Step 404: Based on the M prediction results, determine the final relationship of each first entity pair in the first entity set from the N candidate relationships.
[0130] In one possible implementation, for each first entity pair in the first entity set, the following steps are performed: For each of the N candidate relations, determine M predicted probabilities from M prediction results that the inter-entity relationship of the first entity pair is a candidate relation; based on the determined M predicted probabilities, determine the risk value corresponding to the inter-entity relationship of the first entity pair as a candidate relation; then, based on the N risk values corresponding to the N candidate relations for the inter-entity relationships of the first entity pair, determine the final relation of the first entity pair from the N candidate relations. For example, based on the N risk values corresponding to the inter-entity relationships of the first entity pair for the N candidate relations, determine the candidate relation corresponding to the smallest risk value among the N risk values as the final relation of the first entity pair.
[0131] For example, using knowledge base collections For entity pair x t Given the relation label y t The risk coefficient is calculated using the following formula (8):
[0132]
[0133] The relationship with the minimum risk coefficient is selected as the result using the following formula (9):
[0134]
[0135] The following example illustrates the specific process of the final relationship of the first entity pair.
[0136] Taking M source knowledge bases as source knowledge base S1, source knowledge base S2, and source knowledge base S3, with source knowledge base S1 corresponding to classification model 1, source knowledge base S2 corresponding to classification model 2, and source knowledge base S3 corresponding to classification model 3, and N candidate relations as candidate relation 1 and candidate relation 2, this paper illustrates the process of determining the final relation of each first entity pair in the first entity set corresponding to the target domain.
[0137] The first entity set corresponding to the target domain includes first entity pair 1 and first entity pair 2. The prediction results output by classification model 1 include: the probability that first entity pair 1 is candidate relation 1 (P11), the probability that first entity pair 1 is candidate relation 2 (P12), the probability that first entity pair 2 is candidate relation 1 (P13), and the probability that first entity pair 2 is candidate relation 2 (P14). The prediction results output by classification model 2 include: the probability that first entity pair 1 is candidate relation 1 (P21), the probability that first entity pair 1 is candidate relation 2 (P22), the probability that first entity pair 2 is candidate relation 1 (P23), and the probability that first entity pair 2 is candidate relation 2 (P24). The prediction results output by classification model 3 include: the probability that first entity pair 1 is candidate relation 1 (P31), the probability that first entity pair 1 is candidate relation 2 (P32), the probability that first entity pair 2 is candidate relation 1 (P33), and the probability that first entity pair 2 is candidate relation 2 (P34).
[0138] For the first entity pair 1, the weighted probability of determining the first entity pair 1 as candidate relation 1 is the sum of P11, P21, and P31, denoted as P. 11 The risk value of the first entity pair 1 as candidate relation 1 is 1 and P 11 The difference; the weighted probability of determining the first entity pair 1 as candidate relation 2 is the sum of P12, P22, and P32, denoted as P. 12 The risk value of the first entity pair 1 as candidate relation 2 is 1 and P. 12 The difference; then from (1-P 11 ) and (1 and P 12 The minimum risk value is determined in (1 and P). 12 If the minimum value is found, then it will be combined with (1 and P). 12The candidate relation 2 corresponding to the first entity pair 1 is determined as the final relation. The final relation of the first entity pair 2 is obtained in the same way.
[0139] For example, in the wind energy domain, the first entity pair 1 is <wake dynamics, advanced wind power control>. The classification models corresponding to the source knowledge bases in the power energy domain and the solar energy domain might predict different relationships, such as <consider, include>. Then, the weighted sum of the probabilities that the classification models corresponding to the source knowledge bases in the power energy and solar energy domains predict a "consider" relationship is calculated. Subtracting the weighted sum from the total probability 1 yields the prediction risk of the "consider" relationship, for example, 0.2. Similarly, the weighted sum of the probabilities that the classification models corresponding to the source knowledge bases in the power energy and solar energy domains predict a "include" relationship is calculated. Subtracting the weighted sum from the total probability 1 yields the prediction risk of the "include" relationship, for example, 0.8. Since the former has a lower prediction risk, the final relationship for the entity pair <wake dynamics, advanced wind power control> is determined to be "consider". Through this embodiment, for a first entity pair, the inter-entity relationship of the first entity pair is the candidate relationship corresponding to the smallest risk value among N candidate relationships, indicating that the inter-entity relationship of the first entity pair is most likely to be this candidate relationship, thereby obtaining a more accurate prediction result.
[0140] In this embodiment of the invention, each time the invention is used to predict the relationship in the first target domain through the source target knowledge base, the predicted knowledge in the first target domain can be integrated into a new knowledge base, which is used to provide a new relevant knowledge base for subsequent new first target domains. For the newly generated knowledge base in the first target domain, the corresponding knowledge base data includes a first entity set, first text features, and the final relationship of each first entity pair in the first entity set, which is mapped to a vector representation using a bag-of-words model.
[0141] For example, after step 404 above, the final relations of each first entity pair in the first entity set are input into the bag-of-words model to obtain the first relation vectors corresponding to the final relations of each first entity pair in the first entity set. Then, the vector data corresponding to the knowledge base data of the first target domain can be obtained by combining the first vector data from step 402 above.
[0142] In this application embodiment, obtaining the vector data corresponding to the knowledge base data of the first target domain can be implemented in a variety of possible ways.
[0143] In one implementation method, the first entity vector, the first text vector, and the first relation vector can be used as vector data corresponding to the knowledge base data of the first target domain. For example, denoted as V ei V fi Vyi .
[0144] In this first implementation, the first entity vector, the first text vector, and the first relation vector are used as inputs to the initial model. The initial model is trained with the minimum loss function as the optimization objective to obtain a classification model corresponding to the first target domain. The classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict the relationship of the second vector data corresponding to the second target domain, where K is a positive integer.
[0145] The specific implementation of obtaining the second vector data corresponding to the second target domain can be found in the relevant descriptions of steps 401 and 402 above, and will not be repeated here. The second vector data includes the third entity vector corresponding to the second entity set and the third text vector corresponding to the second text feature.
[0146] For example, given four existing source knowledge bases, S1, S2, S3, and S4, and considering the knowledge base for the first target domain as another source knowledge base, denoted as S5, we can then evaluate the saliency of each of S1, S2, S3, S4, and S5 relative to the second target domain, obtaining the contribution of each source knowledge base to the first target domain. Based on the contributions of S1, S2, S3, S4, and S5 to the first target domain, we select M source knowledge bases with high contributions to the second target domain. We then input the second vector data (i.e., the third entity vector and the third text vector) corresponding to the second target domain into M classification models corresponding to the M source knowledge bases with high contributions to the second target domain, obtaining M prediction results. Finally, based on the M prediction results, we determine the final relation for each pair of second entities in the second entity set from N candidate relations.
[0147] Subsequently, the knowledge predicted within the second target domain can be integrated into a new knowledge base to provide new relevant knowledge for the subsequent entry into the third target domain. This process continues; after each target domain knowledge base is generated, the knowledge within it can be added to the training process as new input for the next task. This target domain knowledge base can be used together with existing source knowledge bases as a source knowledge base to predict relational data for the next target domain. In this way, the source knowledge base accumulates with each use, continuously expanding its size. This ongoing knowledge transfer process makes the relational prediction results for new knowledge more reliable.
[0148] Since the relational data of the knowledge base corresponding to the first target domain is predicted by M classification models, knowledge in related domains of the first target domain is associated, leading to information coupling problems. Therefore, this application provides the following second implementation method to adjust the second vector data corresponding to the first target domain to improve the accuracy of vector representation.
[0149] Implementation method two involves extracting common features from the source domain's knowledge base through incremental learning updates, and then removing these common features in the target domain. This fully utilizes the data from the source domain to quickly and accurately modify and supplement the vector representation, thereby increasing the accuracy and independence of the text features in the target domain. The following describes the process of adjusting the vector data (i.e., the first entity vector, the first text vector, and the first relation vector) corresponding to the knowledge base data in the first target domain. This adjustment process includes the following steps:
[0150] Step 1: For each of the M source knowledge bases, determine the first concept matrix corresponding to each source knowledge base based on the second text vector, the second relation vector, and the first input matrix composed of the second text vector.
[0151] Taking M source knowledge bases, including S1, S2, S3, and S4, as an example, this paper introduces the concept of concept matrix. First, the first probability matrix of a source knowledge base is calculated. For example, the process of calculating the first probability matrix C0 of S1 is as follows:
[0152] A concept matrix is a matrix that calculates common semantic features, showcasing the common features shared by texts in a corpus. Based on this concept, the concept matrix needs to satisfy the following two points: (1) Preserve the original features of the input as much as possible. (2) Based on (1), minimize the number of matrix elements to maintain the most concise and basic expression. Based on the above concepts, the concept matrix C needs to minimize the loss function shown in the following formula (10):
[0153]
[0154] Among them, X * ={x i} i∈{1,…,n} It is the data input matrix, α is an optional but definite hyperparameter, and F is the norm representation. The right side of equation (10) includes two parts, the first part This ensures that the concept matrix C replicates the input as much as possible, thereby achieving the purpose mentioned in (1) above. The second part... It is a regularization penalty that limits the size of matrix elements to achieve the purpose of (2).
[0155] The solution to the above formula (10) is as follows:
[0156]
[0157] Where, X = {x i} i∈{1,…,n} X is the data input matrix, i.e., the corresponding V. e V f V y F is the F-norm, n is the amount of data, α is an optional but definite hyperparameter, and I is the identity matrix corresponding to the dimension of the data input X.
[0158] After calculating the first probability matrix C0 for the source knowledge base S1, the same calculation process is performed sequentially for the other knowledge bases S2, S3, and S4 to obtain the first concept matrices C0 for S2, S3, and S4, respectively. i .
[0159] Step 2: Determine the second concept matrix corresponding to the first target domain based on the second input matrix composed of the first entity vector, the first text vector, and the first relation vector.
[0160] In step two, based on the same calculation process as the first probability matrix C0 obtained from the source knowledge base S1, the second concept matrix corresponding to the knowledge base S5 of the first target domain is calculated.
[0161] Step 3: Merge the M first concept matrices and second concept matrices corresponding to the M source knowledge bases to obtain the general concept matrix.
[0162] The process of merging the two concept matrices is described below.
[0163] Since the concept matrix satisfies most of the Boolean principles, let the two concept matrices be C... i and C j For example, where i and j are positive integers, let's introduce C. i and C j For the merging process, please refer to the following formulas (11) to (13):
[0164]
[0165] C i ∧C j ∶=(C i -1 +C j -1 -I) -1 Formula (12)
[0166]
[0167] in, For logical NOT operation, I is ANDed with C. i C j An identity matrix of the same dimension, C i ∧C j For logical C i and C j The intersection of C i ∨C j For logical C i and C j The union of .
[0168] In this embodiment of the application, any two probability matrices can be combined based on the above formula according to the following formula (14).
[0169] C←C i ∨C j Formula (14)
[0170] For example, the process of merging the first concept matrix C0, C1, C2, C3 and the second concept matrix C4 includes: merging C0 and C1 with i as 0 and j as 1 according to formulas (11) to (14) to obtain the merged result C. 01 Then, with i as 0 or 1 and j as 2, C is merged according to formulas (11) to (14). 01 C and C2 get C 02 Then, with i as 0 or 2 and j as 3, continue to merge C according to formulas (11) to (14). 02 C and C3 get C 03 Then, with i as 0 or 3 and j as 4, continue to merge C according to formulas (11) to (14). 03 The general concept matrix C is obtained from C4. A It should be understood that this application does not restrict the merging order of C0, C1, C2, C3, and C4. Any two concept matrices can be merged first, and then the merged result can be merged with any of the remaining concept matrices, until all concept matrices are merged to obtain concept matrix C. A .
[0171] Step 4: Based on the differences between the first entity vector, the first text vector, and the first relation vector and the general concept matrix, obtain the updated values of the first entity vector, the first text vector, and the first relation vector.
[0172] Continuing with the example above, the first entity vector, the first text vector, and the first relation vector are respectively V ei V fi V yi Subtract the general concept matrix C respectively A In order to remove the general features of the knowledge base, the updated value V of the vector data corresponding to the first target domain is finally obtained.e V f V y .
[0173] Taking the prediction of relational data in the wind energy sector as an example, knowledge bases for electricity and solar energy are used as relevant source knowledge bases. After completing the prediction of relational data in the wind energy sector, the initial vector data of the knowledge base corresponding to the wind energy sector is obtained: V ei V fi V yi Next, the construction of the wind energy knowledge base requires calculating the concept matrix C for the knowledge bases of electricity and solar energy respectively. 电能 C 太阳能 And the knowledge base of wind energy, including the data calculation concept matrix C. 风能 Then C 电能 C 太阳能 , and C 风能 The data is then fused to generate a general concept matrix C that incorporates the common features of all the data. 通用 Finally, the initial target domain V... ei V fi V yi Subtract the general concept matrix C respectively 通用 This process removes common semantic features from previous knowledge bases, reduces the correlation between the new target domain and related previous knowledge bases, and obtains the final V. e V f V y .
[0174] In this second implementation, the updated values of the first entity vector, the first text vector, and the first relation vector are used as inputs to the initial model. The initial model is trained with the minimum loss function as the optimization objective, resulting in a classification model corresponding to the first target domain. This classification model, along with classification models corresponding to K source domains, is used to predict the relationship between the second vector data corresponding to the second target domain, where K is a positive integer. The specific implementation of predicting the relationship between the second vector data corresponding to the second target domain using the classification model corresponding to the first target domain and the classification models corresponding to the K source domains can be found in the relevant description in the first implementation, and will not be repeated here.
[0175] Through the above-described second implementation method, incremental learning technology is used to adjust the information representation within the knowledge base of the new domain in an incremental manner, thereby significantly reducing the correlation between information and improving the accuracy of information expression in the new knowledge base. Furthermore, after each generation of a knowledge base for a target domain, the knowledge within it can be added to the training process as new input for the next task. This knowledge base for the target domain can be used together with the existing source knowledge base as a source knowledge base to predict the relational data of the next target domain. In this way, the source of the source knowledge base will accumulate continuously with the number of uses, and through this continuous knowledge transfer process, the relational prediction results for new knowledge will become more reliable.
[0176] Based on the same technological concept Figure 5 An exemplary embodiment of the present invention provides a relation extraction apparatus that can execute the process of a relation extraction method.
[0177] like Figure 5 As shown, the relationship extraction device includes:
[0178] The acquisition unit 501 is used to acquire first data from a corpus corresponding to the first target domain, wherein the first data includes a first entity set and first text features;
[0179] Processing unit 502 is configured to map the first data into first vector data through a bag-of-words model, the first vector data including a first entity vector corresponding to the first entity set and a first text vector corresponding to the first text feature; input the first vector data into M classification models respectively to obtain M prediction results; and determine the final relationship of each first entity pair in the first entity set from the N candidate relationships based on the M prediction results; wherein each prediction result includes the predicted probability of the entity relationship between each first entity pair in the first entity set as the N candidate relationships, the M classification models correspond to M source knowledge bases, each classification model is trained on an initial model based on sample vector data of the corresponding source knowledge base, the sample vector data includes a second entity vector with a second relationship vector label and a second text vector, and M and N are both positive integers.
[0180] Optionally, the processing unit 502 is specifically configured to: for each first entity pair in the first entity set, perform the following: for each candidate relation among the N candidate relations, determine from the M prediction results the M predicted probabilities that the inter-entity relationship of the first entity pair is the candidate relation; determine the risk value corresponding to the candidate relation based on the determined M prediction probabilities; and determine the final relation of the first entity pair from the N candidate relations based on the N risk values corresponding to the N candidate relations, where the inter-entity relationship of the first entity pair is the same as the inter-entity relationship of the first entity pair.
[0181] Optionally, the processing unit 502 is specifically configured to: determine the candidate relationship corresponding to the smallest risk value among the N candidate relationships as the final relationship of the first entity pair, based on the N risk values corresponding to the entity relationships of the first entity pair.
[0182] Optionally, the processing unit 502 is specifically configured to: for each of the L source knowledge bases, perform a saliency evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain; where L is an integer greater than or equal to M; and determine the M source knowledge bases from the L source knowledge bases based on the contribution of the L source knowledge bases to the first target domain.
[0183] Optionally, the processing unit 502 is specifically used for: for each of the L source knowledge bases, performing a saliency evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain, including: for each of the L source knowledge bases, performing: determining the domain relevance score between the source knowledge base and the corpus corresponding to the first target domain; determining the KL divergence between a first conditional probability distribution and a second conditional probability distribution, wherein the first conditional probability distribution is the probability distribution of predicting the vector representation of the first entity set through the classification model corresponding to the source knowledge base, and the second conditional probability distribution is the probability distribution of predicting the vector representation of the relationship between entities through the classification model corresponding to the source knowledge base; and determining the contribution of the source knowledge base to the first target domain based on the relevance score and the KL divergence.
[0184] Optionally, the processing unit 502 is further configured to: input the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain a first relation vector corresponding to the final relation of each first entity pair in the first entity set; use the first entity vector, the first text vector, and the first relation vector as input to the initial model, and train the initial model with the minimum loss function of the initial model as the optimization objective to obtain a classification model corresponding to the first target domain; the classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relations in the second target domain, where K is a positive integer.
[0185] Optionally, the processing unit 502 is further configured to: input the final relation of each first entity pair in the first entity set into the bag-of-words model to obtain the first relation vector corresponding to the final relation of each first entity pair in the first entity set; for each of the M source knowledge bases, determine the first concept matrix corresponding to each source knowledge base based on the first input matrix composed of the second text vector, the second relation vector, and the second text vector; determine the second concept matrix corresponding to the target domain based on the second input matrix composed of the first entity vector, the first text vector, and the first relation vector; and input the M first concepts corresponding to the M source knowledge bases into the first relation vector. The matrix and the second concept matrix are merged to obtain a general concept matrix; the updated values of the first entity vector, the first text vector, and the first relation vector are obtained based on the differences between the first entity vector, the first text vector, and the first relation vector and the general concept matrix, respectively; the updated values of the first entity vector, the first text vector, and the first relation vector are used as inputs to the initial model, and the initial model is trained with the minimum loss function of the initial model as the optimization objective to obtain a classification model corresponding to the first target domain; the classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relationships in the second target domain, where K is a positive integer.
[0186] Based on the same technical concept, embodiments of the present invention provide a computing device, including:
[0187] Memory, used to store program instructions;
[0188] The processor is used to call program instructions stored in the memory and execute the data anomaly detection method according to the obtained program.
[0189] Based on the same technical concept, embodiments of the present invention provide a computer-readable storage medium storing computer-executable instructions for causing a computer to execute a data anomaly detection method.
[0190] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0191] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0192] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0193] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0194] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0195] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this application and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A relation extraction method, characterized in that, include: First data is obtained from a corpus corresponding to the first target domain, the first data including a first entity set and first text features; The first data is mapped to first vector data through the bag-of-words model. The first vector data includes the first entity vector corresponding to the first entity set and the first text vector corresponding to the first text feature. The first vector data is input into M classification models respectively to obtain M prediction results; each prediction result includes the predicted probability of the entity relationship between each first entity pair in the first entity set as N candidate relations respectively. The M classification models correspond to M source knowledge bases. Each classification model is trained on an initial model based on the sample vector data of the corresponding source knowledge base. The sample vector data includes a second entity vector with a second relation vector label and a second text vector. M and N are both positive integers. Based on the M prediction results, the final relationship of each first entity pair in the first entity set is determined from the N candidate relationships. Specifically, this includes: for each first entity pair in the first entity set, performing the following steps: for each candidate relationship in the N candidate relationships, determining the entity relationship of the first entity pair as M predicted probabilities of the candidate relationship from the M prediction results; determining the entity relationship of the first entity pair as the risk value corresponding to the candidate relationship based on the determined M predicted probabilities; and determining the final relationship of the first entity pair from the N candidate relationships based on the N risk values corresponding to the N candidate relationships for the entity relationship of the first entity pair. Before inputting the first vector data into M classification models to obtain M prediction results, the method further includes: for each of the L source knowledge bases, performing a significance evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain; where L is an integer greater than or equal to M; and determining the M source knowledge bases from the L source knowledge bases based on the contribution of the L source knowledge bases to the first target domain.
2. The method as described in claim 1, characterized in that, The step of determining the final relationship of the first entity pair from the N candidate relationships based on the N risk values corresponding to the N candidate relationships of the first entity pair includes: Based on the N risk values corresponding to the N candidate relationships of the first entity pair, the candidate relationship corresponding to the smallest risk value among the N risk values is determined as the final relationship of the first entity pair.
3. The method as described in claim 1, characterized in that, For each of the L source knowledge bases, a saliency evaluation is performed on each source knowledge base in relation to the first target domain to obtain the contribution of each source knowledge base to the first target domain, including: For each of the L source knowledge bases, execute: Determine the domain relevance score between the source knowledge base and the corpus corresponding to the first target domain; Determine the KL divergence between the first conditional probability distribution and the second conditional probability distribution, wherein the first conditional probability distribution is the probability distribution of the vector representation of the first entity set predicted by the classification model corresponding to the source knowledge base, and the second conditional probability distribution is the probability distribution of the vector representation of the relationship between entities predicted by the classification model corresponding to the source knowledge base. The contribution of the source knowledge base to the first target domain is determined based on the domain relevance score and the KL divergence.
4. The method as described in claim 1, characterized in that, After determining the final relationship of each first entity pair in the first entity set from the N candidate relationships based on the M prediction results, the method further includes: The final relation of each first entity pair in the first entity set is input into the bag-of-words model to obtain the first relation vector corresponding to the final relation of each first entity pair in the first entity set. The first entity vector, the first text vector, and the first relation vector are used as inputs to the initial model. The initial model is trained with the minimum loss function of the initial model as the optimization objective to obtain a classification model corresponding to the first target domain. The classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relations in the second target domain, where K is a positive integer.
5. The method as described in claim 1, characterized in that, After determining the final relationship of each first entity pair in the first entity set from the N candidate relationships based on the M prediction results, the method further includes: The final relation of each first entity pair in the first entity set is input into the bag-of-words model to obtain the first relation vector corresponding to the final relation of each first entity pair in the first entity set. For each of the M source knowledge bases, a first concept matrix corresponding to each source knowledge base is determined based on the second text vector, the second relation vector, and the first input matrix composed of the second text vectors corresponding to each source knowledge base. Based on the second input matrix composed of the first entity vector, the first text vector, and the first relation vector, determine the second concept matrix corresponding to the target domain; The M first concept matrices and the M second concept matrices corresponding to the M source knowledge bases are merged to obtain a general concept matrix; The updated values of the first entity vector, the first text vector, and the first relation vector are obtained based on the differences between the first entity vector, the first text vector, and the first relation vector and the general concept matrix, respectively. The updated values of the first entity vector, the first text vector, and the first relation vector are used as inputs to the initial model. The initial model is trained with the minimum loss function of the initial model as the optimization objective to obtain a classification model corresponding to the first target domain. The classification model corresponding to the first target domain is used together with the classification models corresponding to K source domains to predict relations in the second target domain, where K is a positive integer.
6. A relation extraction device, characterized in that, include: The acquisition unit is used to acquire first data from a corpus corresponding to a first target domain, wherein the first data includes a first entity set and a first text feature. The processing unit is configured to map the first data into first vector data using a bag-of-words model, the first vector data including first entity vectors corresponding to the first entity set and first text vectors corresponding to the first text features; input the first vector data into M classification models respectively to obtain M prediction results; and determine the final relation of each first entity pair in the first entity set from N candidate relations based on the M prediction results; wherein each prediction result includes the predicted probability of the inter-entity relation of each first entity pair in the first entity set as a corresponding N candidate relations, the M classification models correspond to M source knowledge bases, and each classification model is trained on an initial model based on sample vector data from the corresponding source knowledge base, the sample vector data including vectors with second relation labels. The second entity vector and the second text vector, where M and N are both positive integers; wherein, based on the M prediction results, the final relationship of each first entity pair in the first entity set is determined from the N candidate relationships, specifically including: for each first entity pair in the first entity set, performing: for each candidate relationship in the N candidate relationships, determining the entity relationship of the first entity pair as the M prediction probabilities of the candidate relationship from the M prediction results; determining the entity relationship of the first entity pair as the risk value corresponding to the candidate relationship based on the determined M prediction probabilities; and determining the final relationship of the first entity pair from the N candidate relationships based on the N risk values corresponding to the N candidate relationships respectively for the entity relationship of the first entity pair. The processing unit is further configured to: for each of the L source knowledge bases, perform a saliency evaluation on each source knowledge base and the first target domain to obtain the contribution of each source knowledge base to the first target domain; where L is an integer greater than or equal to M; and determine the M source knowledge bases from the L source knowledge bases based on the contribution of the L source knowledge bases to the first target domain.
7. A computing device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the method according to any one of claims 1 to 5.