Methods, electronic devices, and storage media for constructing knowledge graphs

By employing a semi-supervised method based on reinforcement learning, and utilizing feature vector sets and proxy filtering, the problem of relying on manual annotation in traditional methods is solved, achieving efficient and low-cost entity and relation extraction, and constructing a highly accurate knowledge graph.

CN115344703BActive Publication Date: 2025-11-14BEIJING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210722648.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-20
Publication Date
2025-11-14
Estimated Expiration
2042-06-20

AI Technical Summary

Technical Problem

Traditional pipelined methods rely heavily on manual annotation for entity and relation extraction, and the results of entity extraction affect relation extraction, leading to high costs and low accuracy.

Method used

A semi-supervised method using reinforcement learning is adopted. By acquiring target text, a set of feature vectors is created. Reinforcement learning agents are used to filter candidate instances and construct a knowledge graph, reducing manual annotation and improving the accuracy of entity and relation extraction.

Benefits of technology

With minimal annotation, the accuracy of entity and relation extraction is improved, costs are reduced, and the constructed knowledge graph exhibits high accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115344703B_ABST
    Figure CN115344703B_ABST
Patent Text Reader

Abstract

This application provides a method, electronic device, and storage medium for constructing a knowledge graph. The method includes: acquiring target text, the target text including annotated entities; creating a first feature vector set based on the target text; obtaining at least one first candidate instance set based on the first feature vector set; filtering the first candidate instance set using a reinforcement learning agent to obtain at least one target instance; creating a second feature vector set using the at least one target instance; obtaining at least one second candidate instance set based on the second feature vector set; and constructing a knowledge graph based on the at least one second candidate instance set. This application enables the low-cost and accurate construction of a knowledge graph with minimal manual annotation of unknown text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data mining, and more particularly to a method, electronic device, and storage medium for constructing knowledge graphs. Background Technology

[0002] Entity and relation extraction is a crucial part and key step in constructing knowledge graphs in natural language processing. Traditional pipelined methods first extract entities and then identify the relationships between entity pairs. This approach relies on large amounts of manually annotated corpora, and the relation extraction process is affected by the results of entity extraction. Therefore, how to improve the accuracy of both entity and relation extraction while avoiding extensive manual annotation is a problem that needs to be solved in this field. Summary of the Invention

[0003] In view of this, the purpose of this application is to propose a method, electronic device and storage medium for constructing knowledge graphs.

[0004] As one aspect of this application, a method for constructing a knowledge graph is provided, comprising:

[0005] Obtain the target text, which includes the annotated entities;

[0006] Based on the target text, a first feature vector set is created;

[0007] Based on the first set of feature vectors, at least one set of first candidate instances is obtained;

[0008] The first candidate instance set is filtered using a reinforcement learning agent to obtain at least one target instance;

[0009] Using the at least one target instance, a second set of feature vectors is created;

[0010] Based on the second set of feature vectors, at least one set of second candidate instances is obtained;

[0011] A knowledge graph is constructed based on the at least one set of second candidate instances.

[0012] Optionally, creating the first feature vector set includes:

[0013] Obtain a sample set of the target text, the sample set including the annotated partial entities;

[0014] Create a first sub-feature vector set, comprising a set of triples formed by scanning the target text for each labeled head entity based on the semantic textual information of the labeled entity itself and the context; and

[0015] Create a second sub-feature vector set, comprising a set of triples formed by scanning the target text for each labeled tail entity based on the semantic textual information of the labeled entity itself and the context; and

[0016] Create a third sub-feature vector set, which includes a set of quintuples formed by scanning the target text for each pair of labeled head and tail entities based on the semantic text information of the labeled entities themselves and the context, as well as the semantic text information between the head and tail entities.

[0017] Optionally, obtaining at least one first candidate instance set based on the first feature vector set includes:

[0018] Clustering algorithm is used to cluster the first feature vector set to generate multiple vector sets formed by aggregating multiple first feature vectors as extraction pattern p;

[0019] Based on the target text, create a pre-selected set of instance vectors;

[0020] Calculate the cosine similarity between the preselected instance vector and the extraction pattern p;

[0021] If more than half of the first feature vectors in the extraction pattern p formed by aggregating multiple first feature vectors have a cosine similarity to the pre-selected instance vectors that is higher than the threshold τsim,

[0022] The corresponding pre-selected instance vector is then denoted as the first candidate instance that can be obtained by matching the extraction pattern p.

[0023] Optionally, creating a preselected set of instance vectors based on the target text includes:

[0024] Scan the target text and extract all word segments or word pairs from the target text;

[0025] Create a first sub-preselected vector set, comprising a set of triples formed by each word segment based on the semantic textual information of the segment itself and its context; and

[0026] Create a second sub-preselected vector set, comprising a set of quintuples formed by each pair of word segments, based on the semantic text information of the word segment itself and its context, as well as the semantic text information between the word segments.

[0027] Optionally, creating a second feature vector set using the at least one target instance includes:

[0028] A state vector is constructed based on the extraction pattern p, and the state vector consists of the confidence scores of all the first candidate instances.

[0029] The agent randomly selects the first candidate instance based on the state vector and calculates the reward value of the selected first candidate instance according to the reward function;

[0030] The filtered first candidate instances are merged into the first feature vector to form a second feature vector set;

[0031] The agent selection strategy will be optimized based on the reward value.

[0032] Optionally, the confidence score of the first candidate instance includes:

[0033] The formula for calculating the confidence score of candidate instances is as follows:

[0034]

[0035] Sim p (i, p) = max {Sim (i, t) | t∈p}

[0036] Where ξ is the set of extraction patterns p that can match candidate instance i, Sim(i,t) is the similarity calculated using cosine distance, Conf ρ (p) represents the pattern confidence of the extraction pattern p.

[0037] Optionally, the pattern confidence of the extracted pattern p includes:

[0038] For the head entity, the formula for calculating the confidence score of extraction mode p is as follows:

[0039]

[0040] Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|;

[0041] For tail entities, the extraction mode p is calculated using the following formula:

[0042]

[0043] Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|;

[0044] For entity pairs containing both a head entity and a tail entity, the pattern confidence p is calculated using the following formula:

[0045]

[0046] Where |P| is the number of first candidate instances obtained by matching extraction pattern p that appear in the sample set, |PU| is the number of first candidate instances obtained by matching extraction pattern p where the head entity appears in the head entity sample set and the tail entity appears in the tail entity sample set, |NU| is the number of first candidate instances obtained by matching extraction pattern p where the tail entity appears in the head entity sample set and the head entity appears in the tail entity sample set, |U| is the number of first candidate instances obtained by matching extraction pattern p where the head and tail entities are opposite to the head and tail entities in the sample set, |N| is the number of instances that do not belong to any of the above cases, and W nu W is the weight of |NU|. n W represents the weights of |N|. u The weights of |U|.

[0047] Optionally, calculating the reward value of the filtered first candidate instance according to the reward function includes:

[0048] R tota1 =λ1r QUALITY +λ2r QUANTITY

[0049]

[0050]

[0051] Where |S| is the number of first candidate instances that the agent decides to add to the first feature vector, and |C| is the number of first candidate instances found in the current round.

[0052] As a second aspect of this application, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, can implement the knowledge graph construction method provided in this application.

[0053] As a third aspect of this application, a non-transitory computer-readable storage medium is provided, the non-transitory computer-readable storage medium storing computer instructions for causing the computer to execute the above-described knowledge graph construction method provided in this application.

[0054] As can be seen from the above, the method, electronic device, and storage medium for constructing knowledge graphs provided in this application can jointly extract entities and relations with a small amount of annotation, and the knowledge graph constructed based on its semi-supervised learning extraction has high accuracy. Attached Figure Description

[0055] To more clearly illustrate the technical solutions in this application or related technologies, the drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1A This is a schematic diagram illustrating a method for constructing a knowledge graph provided in an embodiment of this application.

[0057] Figure 1B This is a schematic diagram of a method for forming a first candidate instance set provided in an embodiment of this application.

[0058] Figure 1C This is a schematic diagram illustrating a method for forming a second feature vector set according to an embodiment of this application.

[0059] Figure 2A This is a schematic diagram of a method for training a neural network model provided in an embodiment of this application.

[0060] Figure 2B This is a schematic diagram of another method for training a neural network model provided in an embodiment of this application.

[0061] Figure 3 This is a schematic diagram of an electronic device structure for constructing a knowledge graph, provided as an embodiment of this application. Detailed Implementation

[0062] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with specific embodiments and the accompanying drawings.

[0063] It should be noted that, unless otherwise defined, the technical or scientific terms used in the embodiments of this application should have the ordinary meaning understood by those skilled in the art to which this application pertains. The terms "first," "second," and similar terms used in the embodiments of this application do not indicate any order, quantity, or importance, but are merely used to distinguish different components. Terms such as "comprising" or "including" mean that the element or object preceding the word encompasses the elements or objects listed following the word and their equivalents, without excluding other elements or objects.

[0064] Knowledge graphs are composed of triples in the form of <head entity, relation, tail entity>, which can organize knowledge from massive amounts of data in a graph-like manner, providing data support for many downstream intelligent applications, such as web search and answering. Therefore, the construction of knowledge graphs has always been a topic of widespread interest in academia and industry. Entity and relation extraction, which aims to extract entities and the relationships between entities from unstructured text, has received widespread attention from researchers both domestically and internationally as an important part of knowledge graph construction.

[0065] This problem has traditionally been viewed as two separate subtasks: Named Entity Recognition (NER) and Relation Extraction (RE). A major limitation of this pipelined approach is error propagation between NER and RE, and the possibility that useful information from one task may not be utilized by the other (e.g., identifying the "establish" relationship might help the NER module detect the types of two entities, namely "person" and "organization," and vice versa). Unlike pipelined approaches, joint extraction uses a joint model to detect both entities and their relationships simultaneously. Joint learning methods can effectively integrate information from entities and relationships, thus achieving better performance in both subtasks.

[0066] Another important limitation of pipelined methods is that all work relies on a large amount of manually annotated corpus, which is too costly.

[0067] Therefore, this application proposes a semi-supervised joint entity and relation extraction method based on reinforcement learning, and constructs a knowledge graph based on the extraction results. This method can effectively improve the accuracy of entity and relation extraction and does not require a large amount of manual annotation, thus saving costs.

[0068] Figure 1A The illustration shows a schematic diagram of a method for constructing a knowledge graph provided in an embodiment of this application.

[0069] In some embodiments, the method for constructing a knowledge graph as shown in Figure 1 includes:

[0070] S10: Obtain the target text, which includes the annotated partial entities;

[0071] S20: Based on the target text, create a first feature vector set;

[0072] S30: Based on the first feature vector set, obtain at least one first candidate instance set;

[0073] S40: Use a reinforcement learning agent to filter the first candidate instance set to obtain at least one target instance;

[0074] S50: Using the at least one target instance, create a second feature vector set;

[0075] S60: Based on the second feature vector set, at least one second candidate instance set is obtained;

[0076] S70: Construct a knowledge graph based on the at least one set of second candidate instances.

[0077] In some embodiments, the target text can be any unknown text, and the annotated partial entities can include the header entity SEED. h Tail entity SEED t and the entity pairs SEED used to describe their relationship r After obtaining a small amount of labeled target text, the text is filtered to construct a knowledge graph.

[0078] It is understood that the above process may further include using a reinforcement learning agent to filter the second candidate instance set to obtain at least one target instance, creating a third feature vector based on the target instance, and obtaining at least one third candidate instance set based on the third feature vector. This process can be repeated iteratively to obtain the Nth candidate instance set, thereby constructing a knowledge graph. Therefore, this application enables low-cost construction of a knowledge graph based on a small amount of annotation.

[0079] In some embodiments, creating the first feature vector set S20 includes:

[0080] Obtain a sample set of the target text, the sample set including the annotated partial entities SEED. h SEED t and SEED r ;

[0081] Create a first sub-feature vector set, comprising triplets formed by each labeled head entity e1 and the target text based on the semantic text information of the labeled entity itself and the context.<BEF,e1,AFT> The set of e1∈SEED hBEF represents the text preceding entity e1, and AFT represents the text following entity e1; and

[0082] Create a second sub-feature vector set, comprising triplets formed by each labeled tail entity e2, and scan the target text based on the semantic text information of the labeled entity itself and the context.<BEF,e2,AFT> The set of e2∈SEED t BEF represents the text preceding entity e2, and AFT represents the text following entity e2; and

[0083] Create a third sub-feature vector set, comprising a quintuple formed by scanning the target text based on the semantic text information of the labeled entities themselves and their context, as well as the semantic text information between the head and tail entities.<BEF,e1 BET,e2,AFT> A set of (e1,e2)∈SEED r BEF is the text preceding entity e1, BET is the text between e1 and e2, and AFT is the text following entity e2.

[0084] Figure 1B A schematic diagram of a method for forming a first candidate instance set provided by an embodiment of this application is shown.

[0085] In some embodiments, obtaining at least one first candidate instance set based on the first feature vector set includes:

[0086] S301: Cluster the first feature vector set using a clustering algorithm to generate multiple vector sets formed by aggregating multiple first feature vectors as extraction pattern p;

[0087] S302: Based on the target text, create a pre-selected set of instance vectors;

[0088] S303: Calculate the cosine similarity between the pre-selected instance vector and the extraction pattern p;

[0089] S304: If more than half of the first feature vectors in the extraction pattern p formed by aggregating multiple first feature vectors have a cosine similarity with the pre-selected instance vectors higher than the threshold τ. sim ,

[0090] S305: Then the corresponding pre-selected instance vector is recorded as the first candidate instance that can be obtained by matching the extraction pattern p.

[0091] In some embodiments, the clustering algorithm can be a one-pass algorithm based on vector cosine similarity. Using a one-pass algorithm based on vector cosine similarity to cluster the first feature vector can reduce the number of computations and save costs. Furthermore, when calculating the cosine similarity between the extracted pattern p and the pre-selected instance vectors, a threshold τ is set. sim It can be 0.7.

[0092] In some embodiments, S302: Creating a preselected set of instance vectors based on the target text includes:

[0093] Scan the target text and extract all word segments or word pair tokens from the target text;

[0094] Create a first sub-preselected vector set, consisting of triples formed by each token based on its segmentation and the semantic text information of the context.<BEF,token,AFT> The set, where BEF is the text preceding the token and AFT is the text following the token; and

[0095] Create a second sub-preselected vector set, comprising a quintuple formed by each pair of segmented tokens, based on the semantic text information of the segment itself and its context, as well as the semantic text information between the segmented pairs.<BEF,token1,BET,token2,AFT> The set of texts, BEF is the text preceding token1, BET is the text between token1 and token2, and AFT is the text following token2.

[0096] In some embodiments, when calculating the cosine similarity between the extraction pattern p and the preselected instance vector, the cosine similarity between the first sub-preselected vector and the first sub-feature vector and the second sub-feature vector is calculated, and the cosine similarity between the second sub-preselected vector and the third sub-feature vector is calculated.

[0097] Figure 1C A schematic diagram of a method for forming a second feature vector set provided in an embodiment of this application is shown.

[0098] In some embodiments, creating a second feature vector set using the at least one target instance includes:

[0099] S501: Construct a state vector based on the extraction pattern p, the state vector comprising the confidence scores of all the first candidate instances;

[0100] S502: The agent randomly selects the first candidate instance based on the state vector, and calculates the reward value of the selected first candidate instance according to the reward function;

[0101] S503: The filtered first candidate instance is merged into the first feature vector to form a second feature vector set;

[0102] S504: The agent selection strategy will be optimized based on the reward value.

[0103] In some embodiments, S40: The agent uses reinforcement learning to filter the first candidate instance set to obtain at least one target instance. The process of the agent filtering the first candidate instance can be a random filtering based on a random policy. When creating a second feature vector for a target instance, the agent filters the first candidate instance based on a policy network obtained by pre-tuning the neural network.

[0104] In some embodiments, for calculating the candidate instance confidence Conf in S501 i The formula for (i) can be:

[0105]

[0106] Sim p (i, p) = max {Sim (i, t) | t∈p}

[0107] Where ξ is the set of extraction patterns p that can match candidate instance i, Sim(i,t) is the similarity calculated using cosine distance, Conf ρ (p) represents the pattern confidence of the extraction pattern p.

[0108] In some embodiments, the pattern confidence of extracted pattern p can be:

[0109] For the head entity, the formula for calculating the confidence score of extraction mode p is as follows:

[0110]

[0111] Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|;

[0112] For tail entities, the extraction mode p is calculated using the following formula:

[0113]

[0114] Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|;

[0115] For entity pairs containing both a head entity and a tail entity, the pattern confidence p is calculated using the following formula:

[0116]

[0117] Where |P| is the number of first candidate instances obtained by matching extraction pattern p that appear in the sample set, |PU| is the number of first candidate instances obtained by matching extraction pattern p where the head entity appears in the head entity sample set and the tail entity appears in the tail entity sample set, |NU| is the number of first candidate instances obtained by matching extraction pattern p where the tail entity appears in the head entity sample set and the head entity appears in the tail entity sample set, |U| is the number of first candidate instances obtained by matching extraction pattern p where the head and tail entities are opposite to the head and tail entities in the sample set, |N| is the number of instances that do not belong to any of the above cases, and W nu W is the weight of |NU|. n W represents the weights of |N|. u The weights of |U|.

[0118] In some embodiments, the reward value R for the candidate instance is calculated in S502. total The reward function can be:

[0119] R total =λ1r QUALITY +λ2r QUANTITY

[0120]

[0121]

[0122] Where |S| is the number of first candidate instances that the agent decides to add to the first feature vector, and |C| is the number of first candidate instances found in the current round.

[0123] In some embodiments, the process of merging the filtered first candidate instances into the first feature vector to form a second feature vector set in step S503 can be modeled as a Markov decision process (MDP). A Markov decision process is represented by a quintuple.<S,A,γ,P,R> Where S is a continuous state space, and A = {a1, a2, ..., a...} n} is the set of all possible actions, P(S) t+1 =s′|S t =s,A t =a) is the transition probability matrix, and R(s,a) is the reward function for each (s,a) pair. The network settings for state, action, reward, and policy in this application are as follows:

[0124] State: The state consists of candidate instances extracted in the current iteration round. The size of the state space is the maximum number of candidate instances that can be extracted, max_candidate. The state vector consists of the confidence score of each candidate instance.

[0125] Action: Given all candidate instances, the agent selects one to add to the feature vector based on the current state. The size of the operation space is the maximum number of candidate instances, `max_candidate`. Each dimension corresponds to one candidate instance, with a value of 1 or 0. 1 indicates that the candidate instance is added to the feature vector as the target instance, and 0 indicates that it is not added.

[0126] Reward: The reward function encourages reinforcement learning agents to select candidate instances that do not deviate from the semantics of the sample set, while also encouraging the introduction of as diverse semantic information as possible.

[0127] Policy Network: Utilizes a fully connected neural network to process the policy function π. θ (a t ,s t The parameterization maps the state vector s to a probability distribution of all possible actions. The neural network consists of two hidden layers, each followed by a non-linear activation function (ReLU), and the output layer is normalized using the softmax function.

[0128] In some embodiments, in step S504, the agent's screening strategy is based on the reward value R. total The optimization can be performed by updating the parameters θ of the policy network using the Monte Carlo policy gradient (REINFORCEMENT) to maximize the expected cumulative return. The approximate gradient used to update the policy network can be:

[0129]

[0130] The parameter θ is optimized using the Adam optimizer.

[0131] It is understandable that before jointly extracting entity relationships, the neural network will be trained to form a neural network model. After the training is completed, when jointly extracting entity relationships to generate a knowledge graph, it is not necessary to continue to optimize the screening strategy based on the reward value.

[0132] Figure 2A A schematic diagram of a method for training a neural network model provided in an embodiment of this application is shown.

[0133] like Figure 2A As shown, the bootstrap-based entity and relation iterative extraction consists of three sub-bootstrap processes, which extract the head entity (BHE), tail entity (BTE), and relation (BRE), respectively. The training process of the neural network model is an iterative seeding process. The reinforcement learning agent receives the joint extraction state `state1` from the bootstrap-based method. The agent selects an action `action1` based on `state1` and adds the selected new seed to the seed set. This process is repeated multiple times for iteration, and the final reward value is calculated. The neural network model parameters are then updated based on the reward value.

[0134] Figure 2B This illustration shows a schematic diagram of yet another method for training a neural network model provided in an embodiment of this application.

[0135] In some embodiments, the steps of training a neural network based on bootstrap, such as Figure 2B As shown, it includes:

[0136] S1: Obtain a small number of representative seed sets, which can be entity or relation tuples, wherein the relation types have been manually labeled;

[0137] S2: Train a supervised model by combining the labeled tuples with the corpus;

[0138] S3: Use the trained supervised model to predict the corpus that has not been labeled with entities or relations to obtain a new set of entity or relation tuples;

[0139] S4: Filter the relation tuples, select new labeled corpora to input into the supervised model, and further train and correct the supervised model;

[0140] S5: Repeat this phase until a stopping condition is met, which can be a manually defined number of iterations or running until no new entity or relation tuples are generated.

[0141] Using the above method, a neural network model for joint entity relation extraction can be trained. This model can perform joint entity relation extraction on target text with only a small number of samples, thereby constructing a knowledge graph.

[0142] The following section examines the ROTATE neural network model in conjunction with the experimental process.

[0143] 1. Use the public dataset AFP_APW to verify the effectiveness of the proposed model. This dataset contains three types of entities: "PERSON (PER)", "ORGANIZATION (ORG)", and "LOCATION (LOC)" and four types of relations: "founded", "affiliation", "headquarter", and "acquire", and set the model parameters.

[0144] 2. Evaluate the model to determine its recognition ability, and evaluate its overall performance by calculating accuracy and recall.

[0145] Accuracy is defined as:

[0146]

[0147] This represents the proportion of all samples that are judged as positive but are actually positive.

[0148] Recall rate is defined as:

[0149]

[0150] This represents the proportion of predicted positive examples out of all actual positive examples.

[0151] Ideally, both precision and recall should be high, but in reality, they are contradictory. Typically, a balance can be found between them; therefore, a new metric, the F1 score, is defined to consider both precision and recall.

[0152]

[0153] 3. Experimental results show that the model has a more balanced accuracy and recall.

[0154] Table 1 Entity Extraction Results

[0155]

[0156] Table 2 Relation Extraction Results

[0157]

[0158] As can be seen from the table above, the ROTATE model to be protected in this application has significantly improved accuracy and precision compared to the conventional ROTATE# model without proxy selection.

[0159] Based on the same technical concept, corresponding to the methods of any of the above embodiments, this application also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the knowledge graph construction method described in any of the above embodiments.

[0160] Figure 3 This embodiment illustrates a more specific hardware structure of an electronic device, which may include a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. The processor 1010, memory 1020, input / output interface 1030, and communication interface 1040 are interconnected internally via the bus 1050.

[0161] The processor 1010 can be implemented using a general-purpose CPU (Central Processing Unit), microprocessor, application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0162] The memory 1020 can be implemented in the form of ROM (Read Only Memory), RAM (Random Access Memory), static storage device, dynamic storage device, etc. The memory 1020 can store the operating system and other applications. When the technical solutions provided in the embodiments of this specification are implemented by software or firmware, the relevant program code is stored in the memory 1020 and is called and executed by the processor 1010.

[0163] The input / output interface 1030 is used to connect input / output modules to realize information input and output. Input / output modules can be configured as components within the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Input devices may include keyboards, mice, touchscreens, microphones, various sensors, etc., while output devices may include displays, speakers, vibrators, indicator lights, etc.

[0164] The communication interface 1040 is used to connect a communication module (not shown in the figure) to enable communication between this device and other devices. The communication module can communicate via wired means (such as USB, Ethernet cable, etc.) or wireless means (such as mobile network, WIFI, Bluetooth, etc.).

[0165] Bus 1050 includes a pathway for transmitting information between various components of the device, such as processor 1010, memory 1020, input / output interface 1030, and communication interface 1040.

[0166] It should be noted that although the above-described device only shows the processor 1010, memory 1020, input / output interface 1030, communication interface 1040, and bus 1050, in specific implementations, the device may also include other components necessary for normal operation. Furthermore, those skilled in the art will understand that the above-described device may only include the components necessary for implementing the embodiments of this specification, and not necessarily all the components shown in the figures.

[0167] The electronic devices described above are used to implement the corresponding knowledge graph construction methods in any of the foregoing embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0168] Based on the same technical concept, corresponding to the methods of any of the above embodiments, this application also provides a non-transitory computer-readable storage medium that stores computer instructions for causing the computer to execute the knowledge graph construction method as described in any of the above embodiments.

[0169] The computer-readable medium of this embodiment includes permanent and non-permanent, removable and non-removable media, and information storage can be implemented by any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transfer medium that can be used to store information accessible by a computing device.

[0170] The computer instructions stored in the storage medium of the above embodiments are used to cause the computer to execute the knowledge graph construction method as described in any of the above embodiments, and have the beneficial effects of the corresponding method embodiments, which will not be repeated here.

[0171] Those skilled in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of this application (including the claims) is limited to these examples; within the framework of this application, the technical features of the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations of different aspects of the embodiments of this application as described above, which are not provided in the details for the sake of brevity.

[0172] Additionally, to simplify the description and discussion, and to avoid obscuring the embodiments of this application, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Furthermore, the apparatus may be shown in block diagram form to avoid obscuring the embodiments of this application, and this also takes into account the fact that the details of the implementation of these block diagram apparatuses are highly dependent on the platform on which the embodiments of this application will be implemented (i.e., these details should be fully understood by those skilled in the art). While specific details (e.g., circuits) have been set forth to describe exemplary embodiments of this application, it will be apparent to those skilled in the art that the embodiments of this application can be implemented without these specific details or with variations thereof. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0173] Although this application has been described in conjunction with specific embodiments thereof, many substitutions, modifications, and variations of these embodiments will be apparent to those skilled in the art from the foregoing description. For example, other memory architectures (e.g., dynamic RAM (DRAM)) may be used with the embodiments discussed.

[0174] The embodiments of this application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the embodiments of this application should be included within the protection scope of this application.

Claims

1. A method for constructing a knowledge graph, characterized in that, include: Obtain the target text, which includes the annotated entities; Based on the target text, a first feature vector set is created; Based on the first set of feature vectors, at least one set of first candidate instances is obtained; The first candidate instance set is filtered using a reinforcement learning agent to obtain at least one target instance; Using the at least one target instance, a second set of feature vectors is created; Based on the second set of feature vectors, at least one set of second candidate instances is obtained; Based on the at least one set of second candidate instances, a knowledge graph is constructed; The step of obtaining at least one first candidate instance set based on the first feature vector set includes: Clustering algorithm is used to cluster the first feature vector set to generate multiple vector sets formed by aggregating multiple first feature vectors as extraction pattern p; Based on the target text, create a pre-selected set of instance vectors; Calculate the cosine similarity between the preselected instance vector and the extraction pattern p; If more than half of the first feature vectors in the extraction pattern p formed by aggregating multiple first feature vectors have a cosine similarity to the pre-selected instance vectors higher than the threshold τ. sim , The corresponding pre-selected instance vector is then denoted as the first candidate instance that can be obtained by matching the extraction pattern p; Creating the second feature vector set using the at least one target instance includes: A state vector is constructed based on the extraction pattern p, and the state vector consists of the confidence scores of all the first candidate instances. The agent randomly selects the first candidate instance based on the state vector and calculates the reward value of the selected first candidate instance according to the reward function; The filtered first candidate instances are merged into the first feature vector to form a second feature vector set; The agent selection strategy will be optimized based on the reward value.

2. The method for constructing a knowledge graph according to claim 1, characterized in that, The creation of the first feature vector set includes: Obtain a sample set of the target text, the sample set including the annotated partial entities; Create a first sub-feature vector set, comprising a set of triples formed by scanning the target text for each labeled head entity based on the semantic textual information of the labeled entity itself and the context; and Create a second sub-feature vector set, comprising a set of triples formed by scanning the target text for each labeled tail entity based on the semantic textual information of the labeled entity itself and the context; and Create a third sub-feature vector set, which includes a set of quintuples formed by scanning the target text for each pair of labeled head and tail entities based on the semantic text information of the labeled entities themselves and the context, as well as the semantic text information between the head and tail entities.

3. The method for constructing a knowledge graph according to claim 1, characterized in that, The process of creating a preselected set of instance vectors based on the target text includes: Scan the target text and extract all word segments or word pairs from the target text; Create a first sub-preselected vector set, comprising a set of triples formed by each word segment based on the semantic textual information of the segment itself and its context; and Create a second sub-preselected vector set, comprising a set of quintuples formed by each pair of word segments, based on the semantic text information of the word segment itself and its context, as well as the semantic text information between the word segments.

4. The method for constructing a knowledge graph according to claim 1, characterized in that, The confidence score of the first candidate instance includes: The formula for calculating the confidence score of candidate instances is as follows: Sim p (i,p)=max{Sim(i,t)|t∈p} Where ξ is the set of extraction patterns p that can extract candidate instances i, Sim(i,t) is the similarity calculated using cosine distance, and Conf ρ (p) represents the pattern confidence of the extraction pattern p.

5. The method for constructing a knowledge graph according to claim 4, characterized in that, The pattern confidence of the extracted pattern p includes: For the head entity, the formula for calculating the confidence score of extraction mode p is as follows: Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|; For tail entities, the extraction mode p is calculated using the following formula: Where |P| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the tail entity sample set, |N| is the number of first candidate instances obtained by matching according to extraction pattern p that appear in the head entity sample set, |U| is the number of first candidate instances obtained by matching according to extraction pattern p that are neither in the head entity sample set nor in the tail entity sample set, and W n W represents the weights of |N|. u The weights of |U|; For entity pairs, the pattern confidence p is calculated using the following formula: Where |P| is the number of first candidate instances obtained by matching extraction pattern p that appear in the sample set, |PU| is the number of first candidate instances obtained by matching extraction pattern p where the head entity appears in the head entity sample set and the tail entity appears in the tail entity sample set, |NU| is the number of first candidate instances obtained by matching extraction pattern p where the tail entity appears in the head entity sample set and the head entity appears in the tail entity sample set, |U| is the number of first candidate instances obtained by matching extraction pattern p where the head and tail entities are opposite to the head and tail entities in the sample set, |N| is the number of instances that do not belong to any of the above cases, and W nu W is the weight of |NU|. n W represents the weights of |N|. u The weights of |U|.

6. The method for constructing a knowledge graph according to claim 1, characterized in that, The step of calculating the reward value of the first candidate instance after filtering according to the reward function includes: R total =λ1r QUALITY +λ2r QUANTITY Where |S| is the number of first candidate instances that the agent decides to add to the first feature vector, and |C| is the number of first candidate instances found in the current round.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the method as described in any one of claims 1 to 6.

8. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores computer instructions for causing the computer to perform the method of any one of claims 1 to 6.