Knowledge graph construction method and device based on secondary annotation

By aggregating and annotating text data based on secondary annotation, training entity recognition models and generating triple sets, the problem of unconsidered entity and attribute dependencies in the prior art is solved, and the efficiency and accuracy of knowledge graph construction are improved.

CN119783793APending Publication Date: 2025-04-08CHINASOFT INFORMATION SYST ENG CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411866421.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-18
Publication Date
2025-04-08

AI Technical Summary

Technical Problem

Existing text entity recognition technology fails to effectively consider the dependence between entities and attributes, resulting in low efficiency and accuracy of building knowledge graphs in specific domains.

Method used

The secondary annotation method is adopted, by obtaining the target text data set corresponding to the target classification label, aggregating the text data of the same attribute value, annotating the labeled text data based on the preset BIO secondary annotation rules, and training the entity recognition model to generate a triple set of entities to build a knowledge graph.

Benefits of technology

By making full use of the dependence between entities and attributes, the efficiency and accuracy of building knowledge graphs in specific domains are improved, and the dependence between entities and attributes can be more effectively reflected.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119783793A_ABST
    Figure CN119783793A_ABST
Patent Text Reader

Abstract

The present invention provides a knowledge graph construction method and device based on secondary annotation, which obtains a target text data set corresponding to a target classification label, and aggregates text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; annotates the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and trains an entity recognition model with the obtained annotated text data as a training set; predicts the unannotated text data in each text data subset using the trained entity recognition model to obtain the prediction result of the unannotated text data; generates a triple set of the target entity based on the annotated text data and the prediction result, and constructs a knowledge graph based on the triple set. The present invention can alleviate the problem of low efficiency and accuracy in the construction of knowledge graphs in specific fields in the existing text entity recognition technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method and device for constructing a knowledge graph based on secondary annotation. Background Art

[0002] With the widespread use of information technology, a large amount of heterogeneous data has been accumulated in various fields. How to transform multi-source heterogeneous data into knowledge and generate value is becoming more and more urgent. Text entity recognition technology has been widely used in knowledge extraction in various industries. However, existing text entity recognition technology often classifies entities and attributes as nouns at the same level for recognition, without considering the dependency relationship between entities and attributes. This brings difficulties to effective knowledge extraction in specific fields, and the extracted knowledge cannot reflect the dependency relationship between entities and attributes, which makes the efficiency and accuracy of knowledge graph construction in specific fields low. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a method and device for constructing a knowledge graph based on secondary annotation to alleviate the above-mentioned problems existing in the related art.

[0004] In a first aspect, an embodiment of the present invention provides a method for constructing a knowledge graph based on secondary annotation, comprising: obtaining a target text data set corresponding to a target classification label, and aggregating text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; wherein the target classification label is used to uniquely characterize the classification of a target entity, and the target entity has at least one attribute; annotating the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and training an entity recognition model with the obtained annotated text data as a training set; wherein each training sample in the training set is annotated with a corresponding entity, attribute and attribute value; using the trained entity recognition model to predict the unannotated text data in each text data subset to obtain a prediction result of the unannotated text data; wherein the prediction result includes the entity, attribute and attribute value corresponding to the corresponding unannotated text data; generating a triple set of the target entity based on the annotated text data and the prediction result, and constructing a knowledge graph based on the triple set; wherein each triple in the triple set consists of a unique identifier, attribute and attribute value of the corresponding entity.

[0005] In the second aspect, an embodiment of the present invention also provides a knowledge graph construction device based on secondary annotation, including: an aggregation module, which is used to obtain a target text data set corresponding to a target classification label, and aggregate the text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; wherein the target classification label is used to uniquely characterize the classification of the target entity, and the target entity has at least one attribute; a training module, which is used to annotate the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and train an entity recognition model with the obtained annotated text data as a training set; wherein each training sample in the training set is annotated with a corresponding entity, attribute and attribute value; a prediction module, which is used to predict the unlabeled text data in each text data subset using the trained entity recognition model to obtain a prediction result of the unlabeled text data; wherein the prediction result includes the entity, attribute and attribute value corresponding to the corresponding unlabeled text data; a construction module, which is used to generate a triple set of the target entity based on the annotated text data and the prediction result, and construct a knowledge graph based on the triple set; wherein each triple in the triple set consists of a unique identifier, attribute and attribute value of the corresponding entity.

[0006] The embodiment of the present invention provides a method and device for constructing a knowledge graph based on secondary annotation, which obtains a target text data set corresponding to a target classification label, and aggregates text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; annotates the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and trains an entity recognition model with the obtained annotated text data as a training set; predicts the unlabeled text data in each text data subset using the trained entity recognition model to obtain the prediction results of the unlabeled text data; generates a triple set of the target entity based on the annotated text data and the prediction results, and constructs a knowledge graph based on the triple set. By adopting the above technology, a training set is constructed to train the entity recognition model by annotating the text data to be annotated based on attribute value clustering based on the preset BIO secondary annotation rules, so that the trained entity recognition model can make full use of the dependency between entities and attributes when predicting unlabeled text data, and then generate a special triple consisting of the entity's unique identifier, attributes and attribute values ​​based on the annotated text data and the model prediction results. Finally, the special triple is used to construct the knowledge graph required for a specific field, thereby improving the efficiency and accuracy of constructing the knowledge graph in the specific field.

[0007] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or understood by practicing the present invention. The purpose and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.

[0008] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0009] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0010] Figure 1 A schematic diagram of a process for constructing a knowledge graph based on secondary annotation in an embodiment of the present invention;

[0011] Figure 2 An example diagram of input sequence and annotated sequence in an embodiment of the present invention;

[0012] Figure 3 An example diagram of an input sequence and an output sequence in an embodiment of the present invention;

[0013] Figure 4 This is a flowchart of a method for constructing a knowledge graph based on secondary annotation in an embodiment of the present invention;

[0014] Figure 5 It is a structural schematic diagram of a knowledge graph construction device based on secondary annotation in an embodiment of the present invention. DETAILED DESCRIPTION

[0015] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution of the present invention will be clearly and completely described in combination with the embodiments below. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0016] At present, existing text entity recognition technologies often classify entities and attributes as nouns at the same level for recognition, without considering the dependency relationship between entities and attributes. This brings difficulties to the effective knowledge extraction in specific fields, and the extracted knowledge cannot reflect the dependency relationship between entities and attributes, resulting in low efficiency and accuracy in the construction of knowledge graphs in specific fields.

[0017] Based on this, the present invention provides a method and device for constructing a knowledge graph based on secondary annotation, which can alleviate the above-mentioned problems existing in related technologies.

[0018] To facilitate understanding of this embodiment, firstly, a knowledge graph construction method based on secondary annotation disclosed in an embodiment of the present invention is described in detail, see Figure 1 As shown, the method may include the following steps:

[0019] Step S102, obtaining a target text data set corresponding to a target classification label, and aggregating text data corresponding to the same attribute value in the target text data set into a corresponding text data subset.

[0020] The target classification label may be used to uniquely characterize the classification of the target entity, and the target entity may have at least one attribute.

[0021] Step S104, annotating the text data to be annotated in the obtained text data subset based on the preset BIO secondary annotation rules, and training the entity recognition model with the obtained annotated text data as a training set.

[0022] Among them, the preset BIO secondary annotation rule can be: for the same text data, both the entity classification of the text data and the entity attributes of the text data are annotated. When constructing the training set, since it is necessary to adjust the parameters of the entity recognition model through feedback according to the prediction results of the entity recognition model, the training samples need to be annotated with entity attribute values ​​(i.e., actual attribute values) on the basis of entity classification and entity attributes, that is, each training sample in the training set is annotated with corresponding entities, attributes, and attribute values.

[0023] Step S106, using the trained entity recognition model to predict the unlabeled text data in each text data subset, to obtain a prediction result of the unlabeled text data.

[0024] The prediction results may include entities, attributes, and attribute values ​​corresponding to the corresponding unlabeled text data.

[0025] Step S108, generating a triple set of the target entity based on the annotated text data and the prediction results, and constructing a knowledge graph based on the triple set.

[0026] Each triple in the triple set may be composed of a unique identifier, an attribute, and an attribute value of the corresponding entity. For example, a triple may be expressed as <unique identifier, attribute, attribute value>, where the unique identifier is an identifier (such as a name, number, etc.) that can uniquely characterize an entity.

[0027] An embodiment of the present invention provides a knowledge graph construction method based on secondary annotation, which obtains a target text data set corresponding to a target classification label, and aggregates text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; annotates the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and trains an entity recognition model with the obtained annotated text data as a training set; uses the trained entity recognition model to predict the unlabeled text data in each text data subset to obtain the prediction results of the unlabeled text data; generates a triple set of the target entity based on the annotated text data and the prediction results, and constructs a knowledge graph based on the triple set. By adopting the above technology, a training set is constructed to train the entity recognition model by annotating the text data to be annotated based on attribute value clustering based on the preset BIO secondary annotation rules, so that the trained entity recognition model can make full use of the dependency between entities and attributes when predicting unlabeled text data, and then generate a special triple consisting of the entity's unique identifier, attributes and attribute values ​​based on the annotated text data and the model prediction results. Finally, the special triple is used to construct the knowledge graph required for a specific field, thereby improving the efficiency and accuracy of constructing the knowledge graph in the specific field.

[0028] As a possible implementation, obtaining the target text data set corresponding to the target classification label in the above step S102 may include: obtaining initial text data, and assigning the same classification label to text data belonging to the same entity classification in the initial text data, and then extracting the text data with the target classification label as the target text data set.

[0029] Taking the entity classification of athletes as an example, we can first crawl some text data from the website as the initial text data, and then assign the "athlete" label to the text data related to athletes in the initial text data to identify the text data belonging to the athlete category through the "athlete" label. After that, the text data with the "athlete" label are combined into a target text data set and the target text data set is extracted.

[0030] As a possible implementation, each target text data in the target text data set may be stored in a corresponding first text document, and each first text document may have a corresponding document index and a first document storage location. Based on this, aggregating text data corresponding to the same attribute value in the target text data set into a corresponding text data subset in step S102 may include:

[0031] Step 1: segment each target text data in the target text data set, and clean the segmented text data.

[0032] The cleaning may include operations such as removing stop words and punctuation marks, which are not limited.

[0033] Step 2: Convert each first text word in the obtained cleaned text data into a corresponding first word vector, and determine a target word vector that matches the corresponding second word vector in the preset word vector library from the obtained first word vector.

[0034] Among them, the preset word vector library contains a second word vector corresponding to at least one attribute value of the target entity.

[0035] Exemplarily, after converting each word (i.e., the first text word) obtained after the above step 1 into a corresponding word vector, the following operations can be performed: for each first word vector obtained, calculate the similarity between the first word vector and each second word vector in the preset word vector library; if the similarity between the first word vector and the corresponding second word vector in the preset word vector library is greater than a preset similarity threshold, then determine the first word vector as the target word vector.

[0036] The above similarity may be cosine similarity, Euclidean distance, Manhattan distance, etc., without limitation.

[0037] Step 3: Based on the determined target word vector and the document index and the first document storage location of each first text document, an inverted index algorithm is used to determine the first target text document whose text data contains the same attribute value from the obtained first text documents.

[0038] Continuing with the previous example, each text data with the "athlete" tag can be stored in a folder named "athlete" in a text document with a document index and a document storage location. The specific document storage location can be expressed in the following form:

[0039] athlete / 1.txt

[0040] athlete / 2.txt ......

[0042] athlete / 100.txt

[0043] After performing operations such as word segmentation, stop word removal, punctuation removal, etc. on the text data contained in each text document and converting each of the split words into a corresponding first word vector, the target word vector corresponding to the specified attribute value can be determined by comparing the similarity between the first word vector and the second word vector stored in the database. Then, an inverted index algorithm is used to find text documents in a folder named "athletes" whose text data contains the same specified attribute value as the first target text document.

[0044] Step 4: The text data containing the same attribute value in the first target text document corresponding to the same attribute value are grouped into corresponding text data subsets.

[0045] Continuing with the previous example, after finding the first target text document in the folder named "Athlete", the text data contained in the first target text document containing the same specified attribute value can be combined into corresponding text data subsets, thereby forming different text data subsets from text data containing different specified attribute values, that is, the number of attribute values ​​remains consistent with the number of text data subsets.

[0046] As a possible implementation, after aggregating the text data corresponding to the same attribute value in the target text data set into a corresponding text data subset, the above-mentioned knowledge graph construction method based on secondary annotation may further include:

[0047] Step A1, converting each determined target word vector into a corresponding second text word.

[0048] Step A2: Generate a corresponding storage file directory for the text data subset based on the obtained second text word.

[0049] Each storage file uses its corresponding second text word as the file name.

[0050] Since there is a corresponding relationship between the target word vector and the attribute value, there is also a corresponding relationship between the word converted from the target word vector (i.e., the second text word) and the attribute value. In order to more intuitively reflect the corresponding relationship between the text data subset and the attribute value, after obtaining the second text word corresponding to the specified attribute value, the second text word can be used as the file name to establish a storage file directory for storing the corresponding text data subset.

[0051] Continuing with the previous example, after finding the first target text document in the folder named "Athlete", a folder with the corresponding name of the second text word corresponding to the same attribute value (i.e., corresponding to the same target word vector) can be established for the text data in the first target text document containing the same attribute value (i.e., corresponding to the same target word vector), and the storage location corresponding to the folder in the folder named "Athlete" can be used as the storage file directory for the text data subset corresponding to the same attribute value.

[0052] Step A3: for each text data subset, each text data in the text data subset is stored in a corresponding second text document in the storage file directory corresponding to the text data subset.

[0053] Each second text document has a corresponding second document storage location.

[0054] Continuing with the previous example, after the storage file directory corresponding to each text data subset is known, each text data in a folder named as a second text word can be stored in a text document with a corresponding document storage location under the folder named as the second text word. The specific document storage location can be expressed in the following form:

[0055] athlete / XX / 1.txt

[0056] athlete / XX / 2.txt

[0057] …

[0058] athlete / YY / 1.txt

[0059] athlete / YY / 2.txt

[0060] …

[0061] In this representation, "XX" and "YY" are second text words corresponding to two different attribute values ​​of the name attribute of the athlete.

[0062] As a possible implementation, in the above step S104, labeling the text data to be labeled in the obtained text data subset based on the preset BIO secondary labeling rule may include:

[0063] Step a1: based on the second document storage position of each second text document, determine the text data to be annotated corresponding to the corresponding text data subset from each second text document.

[0064] Continuing with the previous example, each second text document can be found according to the second document storage location of each second text document, and then the text data contained in each second document can be found. After that, the text data that needs to be annotated in each second text document is used as the text data to be annotated corresponding to the corresponding text data subset, so that each operation of determining the corresponding text data to be annotated only needs to be performed in an independent text document, thereby improving the efficiency and accuracy of determining the text data to be annotated.

[0065] Step a2: annotate corresponding entities and attributes for the text data to be annotated corresponding to each text data subset according to the preset BIO secondary annotation rules.

[0066] Continuing with the previous example, after determining the text data to be annotated corresponding to a text data subset, the text data to be annotated corresponding to the text data subset can be annotated according to the pre-defined BIO secondary annotation rules, so that the text data to be annotated in the text data subset has corresponding entities and attributes.

[0067] For ease of description, a single text data to be annotated can be recorded as a single input sequence composed of multiple text characters, and the sequence obtained after annotating the single input sequence according to the preset BIO secondary annotation rules is recorded as the annotation sequence. Figure 2 As shown in the figure, for the input sequence "XX was a basketball player from country M", the representation of the label sequence corresponding to the input sequence can be:

[0068] X B-Athlete-Name

[0069] X I-Athlete-Name

[0070] Zeng O

[0071] Yes

[0072] US B-Athlete-Nationality

[0073] National I-Athlete-Nationality

[0074] Basketball B-Athletes-Competitions

[0075] Ball I-Athletes-Competitions

[0076] Luck

[0077] Animation

[0078] Member

[0079] .O

[0080] Step a3: annotate corresponding attribute values ​​for the text data annotated with entities and attributes corresponding to each text data subset.

[0081] Continuing with the previous example, since the purpose of training an entity recognition model is actually to predict the entities, attributes, and attribute values ​​corresponding to the corresponding input sequence through the trained entity recognition model, in order to calculate the loss function value during the training of the entity recognition model and continuously adjust the parameters of the entity recognition model with the goal of minimizing the loss function value, after obtaining the labeling sequence corresponding to a certain input sequence, it is also necessary to further label the corresponding actual attribute values ​​for the labeling sequence as the true value information for calculating the loss function value, so that the sequence with the true value information is used as a training sample for training the entity recognition model, and the true value information corresponds to the attribute value obtained after the entity recognition model predicts and calculates the input sequence. For example Figure 3 As shown in the figure, after the input sequence "XX was also an outstanding basketball player of country M..." is input into the entity recognition model for prediction calculation, the entity recognition model will output the output sequence corresponding to the input sequence, which contains arrays corresponding to the three different attributes of the athlete ( Figure 3 The output sequence can be represented as follows: [

[0083] {"XX","Athlete-Name"},

[0084] {"M Country","Athlete-Nationality"},

[0085] {"Basketball","Athlete-Sport"},

[0086] … ]

[0088] As a possible implementation, the unique identifier may be the name of the corresponding entity; based on this, the triple set of the target entity generated based on the annotated text data and the prediction result in the above step S108 may include:

[0089] Step B1, based on the entities, attributes and attribute values ​​annotated in the obtained annotated text data and the entities, attributes and attribute values ​​in the prediction results, a candidate triple set of the target entity is generated, wherein each candidate triple in the candidate triple set consists of the name, attribute and attribute value of the corresponding entity.

[0090] Continuing with the previous example, after obtaining training samples (i.e., annotated text data) by further annotating the annotated sequence with corresponding actual attribute values ​​and predicting the output sequence corresponding to the unlabeled text data through the trained entity recognition model, the entities, attributes, and attribute values ​​annotated by each training sample can be used to construct candidate triples corresponding to each training sample (in the form of <name, attribute, attribute value>), and the entities, attributes, and attribute values ​​contained in each output sequence can be used to construct the candidate triples corresponding to each output sequence. All candidate triples constructed using entities, attributes, and attribute values ​​can form a candidate triple set for a specified entity (such as an athlete entity).

[0091] Step B2, performing deduplication processing on the candidate triples in the candidate triple set to obtain a triple set.

[0092] Continuing with the previous example, since the candidate triple set generally contains candidate triples with exactly the same elements (i.e. repeated), only one candidate triple can be retained from the repeated candidate triples in the candidate triple set to achieve deduplication of the candidate triples in the candidate triple set. The candidate triples retained after deduplication can form the triple set required to construct the knowledge graph.

[0093] As a possible implementation, the entity recognition model can adopt a BERT-CRF model or a BILSTM-CRF model. The BERT-CRF model is a model that combines BERT (Bidirectional Encoder Representations from Transformers) with CRF (Conditional Random Field), and the BILSTM-CRF model is a model that combines BILSTM (Bidirectional Long Short-Term Memory) with CRF.

[0094] As a possible implementation, constructing a knowledge graph based on a triple set in the above step S108 may include: extracting elements of each triple in the triple set, and using a preset cypher statement to construct a knowledge graph using the extracted elements.

[0095] For ease of understanding, the operation of the above-mentioned knowledge graph construction method based on secondary annotation is described as follows by taking a specific application as an example.

[0096] The essence of knowledge graph is the process of converting structured data and unstructured data into knowledge. According to the knowledge representation method, entity knowledge can be constructed in the form of <entity, attribute, attribute value> triples. The main idea of ​​the above-mentioned knowledge graph construction method based on secondary annotation is to adopt a top-down design mode. The top layer of this design mode is ontology design, and the bottom layer of this design mode is to construct the knowledge graph based on ontology. In ontology design, concepts, relationship types, and attributes are clearly characterized. Concepts are the classification of specific entities, relationship types are the classification of specific relationships, and attributes are the classification of specific attribute values.

[0097] See also Figure 4 As shown, the above-mentioned knowledge graph construction method based on secondary annotation mainly includes the following steps:

[0098] Step S1, define the ontology.

[0099] Ontology is an abstract and artificial definition based on the research field. Ontology includes concepts, relationship types, and attributes. For example, if the concept includes athletes, then the attributes defined for athletes include name, gender, nationality, and competition events.

[0100] Step S2, capturing text data.

[0101] The crawler can be used to crawl text data from relevant websites according to ontology concepts, and the crawled text data can be preliminarily classified according to the classification labels of the entities. The preliminarily classified text data can be downloaded to a text document in a file directory named after the concept name for storage.

[0102] Step S3: text data clustering.

[0103] The text data captured from the website is further clustered by converting the text data into word vectors and calculating the similarity between the word vectors. The specific steps of text data clustering may include:

[0104] Step S31, traverse the text data, perform operations such as word segmentation, remove stop words, and remove punctuation on the text data.

[0105] Step S32, converting the words obtained after the above step S31 into word vectors through Word2Vec, storing the obtained word vectors in a vector library, and establishing a mapping relationship between the word vectors and the text document index.

[0106] Step S33, calculate the cosine similarity between the newly stored word vector and the existing word vector in the vector library, and use the word vector whose cosine similarity is greater than the preset cosine similarity threshold as the target word vector, then use the inverted index algorithm to query the target text document corresponding to the target word vector, and then convert each target word vector into a corresponding target word, and use the corresponding target word to name the corresponding file directory.

[0107] Step S34, using the Python program to store the text data associated with the same target word vector in a text document in a file directory named after the corresponding target word, so as to form a clustering relationship of the text data through the hierarchical relationship of the file directory.

[0108] Step S35, manually verifying the result obtained after the above step S34, and adjusting and optimizing the existing clustering relationship according to the manual verification result.

[0109] Step S4, annotating text data.

[0110] Based on the BIO secondary annotation rules, the text data to be annotated is manually annotated (the larger the amount of annotated data, the better the training effect of the entity recognition model), and the annotated text data with labeled entities, attributes and attribute values ​​is used as training data.

[0111] Step S5: algorithm selection.

[0112] Select the BERT+CRF algorithm as the entity recognition model, input the training data into the entity recognition model to train the entity recognition model, and obtain the trained entity recognition model after the training is completed.

[0113] Step S6, entity recognition model prediction.

[0114] Any clustered text data obtained after selecting the above step S3 is input into the trained entity recognition model for prediction, and the trained entity recognition model outputs the prediction result.

[0115] Step S7, generating a triplet.

[0116] According to the concepts defined in the ontology (such as athletes, etc.), the name of the concept can be used as the default name of the entity. According to the attributes defined in the concept (such as name, gender, nationality, competition event, etc.), the text data corresponding to the corresponding attribute is directly corresponded. In the case of existing ontology information, the ontology information can be traversed in a loop and the concept + attribute can be used as the key information to compare with the corresponding attribute value in the output sequence corresponding to the ontology information. Finally, the entity name, attribute and attribute value that match the corresponding attribute value are obtained to form the entity triple information. The representation of triple information is as follows:

[0117] (XX, name, XX),

[0118] (XX, nationality, country M),

[0119] (XX, competition event, basketball), ......

[0121] Step S8, knowledge is entered into the graph.

[0122] Traverse the triples to obtain the elements contained in each triple, and use cypher syntax to import the obtained elements into the graph database to build the knowledge graph. The knowledge graph construction is completed.

[0123] By adopting the above-mentioned knowledge graph construction method based on secondary annotation, by combining the BIO secondary annotation method with the construction of the model training set, the entities and their attributes can be annotated together in the corresponding text data during the model training stage, so that the model has the ability to utilize the dependency relationship between entities and attributes, so as to subsequently generate triples in the form of <entity, attribute, attribute value> and use the triples for knowledge entry into the graph, which significantly improves the efficiency and accuracy of entering effective entity knowledge into the graph, reduces the workload of manual screening of effective knowledge, can meet the needs of building knowledge graphs in specific fields, and promotes the standardization of knowledge graphs.

[0124] Based on the above-mentioned knowledge graph construction method based on secondary annotation, the embodiment of the present invention also provides a knowledge graph construction device based on secondary annotation, see Figure 5 As shown, the device may include the following modules:

[0125] Aggregation module 502 is used to obtain a target text data set corresponding to a target classification label, and aggregate text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; wherein the target classification label is used to uniquely characterize the classification of a target entity, and the target entity has at least one attribute.

[0126] The training module 504 is used to annotate the text data to be annotated in the obtained text data subset based on the preset BIO secondary annotation rules, and use the obtained annotated text data as a training set to train the entity recognition model; wherein each training sample in the training set is annotated with corresponding entities, attributes and attribute values.

[0127] The prediction module 506 is used to use the trained entity recognition model to predict the unlabeled text data in each text data subset to obtain the prediction results of the unlabeled text data; wherein the prediction results include the entities, attributes and attribute values ​​corresponding to the corresponding unlabeled text data.

[0128] Construction module 508 is used to generate a triple set of the target entity based on the annotated text data and the prediction results, and to construct a knowledge graph based on the triple set; wherein each triple in the triple set consists of a unique identifier, attributes and attribute values ​​of the corresponding entity.

[0129] The above-mentioned knowledge graph construction device based on secondary annotation is adopted to train the entity recognition model by constructing a training set by annotating the text data to be annotated after clustering based on attribute values ​​based on preset BIO secondary annotation rules, so that the trained entity recognition model can make full use of the dependency relationship between entities and attributes when predicting unlabeled text data, and then generate a special triple consisting of the unique identifier, attributes and attribute values ​​of the entity based on the annotated text data and the model prediction results, and finally use the special triple to construct the knowledge graph required for a specific field, thereby improving the efficiency and accuracy of constructing the knowledge graph in the specific field.

[0130] The aggregation module 502 may also be used to obtain initial text data, assign the same classification label to text data belonging to the same entity classification in the initial text data, and then extract the text data with the target classification label as the target text data set.

[0131] Each target text data in the above-mentioned target text data set can be stored in a corresponding first text document, and each first text document can correspond to a corresponding document index and a first document storage location; based on this, the above-mentioned aggregation module 502 can also be used to: segment each target text data in the target text data set, and clean the obtained segmented text data; wherein, the cleaning includes removing stop words; converting each first text word in the obtained cleaned text data into a corresponding first word vector, and determining a target word vector that matches the corresponding second word vector in a preset word vector library from the obtained first word vector; wherein, the preset word vector library contains a second word vector corresponding to at least one attribute value of the target entity; based on the determined target word vector and the document index and first document storage location of each first text document, an inverted index algorithm is used to determine the first target text document whose text data contains the same attribute value from the obtained first text document; the text data containing the same attribute value in the first target text document corresponding to the same attribute value is formed into a corresponding text data subset.

[0132] The above-mentioned aggregation module 502 can also be used to: for each first word vector obtained, calculate the similarity between the first word vector and each second word vector in the preset word vector library; if the similarity between the first word vector and the corresponding second word vector in the preset word vector library is greater than a preset similarity threshold, then determine the first word vector as the target word vector.

[0133] The above-mentioned aggregation module 502 can also be used to perform the following operations after aggregating the text data corresponding to the same attribute value in the target text data set into a corresponding text data subset: converting each determined target word vector into a corresponding second text word; generating a corresponding storage file directory for the text data subset based on the obtained second text word; wherein each storage file is named by its corresponding second text word; for each text data subset, each text data in the text data subset is stored in a corresponding second text document under the storage file directory corresponding to the text data subset; wherein each second text document has a corresponding second document storage location.

[0134] The above-mentioned training module 504 can also be used for: determining the text data to be annotated corresponding to the corresponding text data subset from each second text document based on the second document storage position of each second text document; annotating the corresponding entities and attributes for the text data to be annotated corresponding to each text data subset according to the preset BIO secondary annotation rules; and annotating the corresponding attribute values ​​for the text data annotated with entities and attributes corresponding to each text data subset.

[0135] The above-mentioned unique identifier can be the name of the corresponding entity; based on this, the above-mentioned construction module 508 can also be used to: generate a set of candidate triples of the target entity based on the entities, attributes and attribute values ​​annotated by the annotated text data and the entities, attributes and attribute values ​​in the prediction results; wherein each candidate triple in the candidate triple set is composed of the name, attributes and attribute values ​​of the corresponding entity; and deduplicate the candidate triples in the candidate triple set to obtain the triple set.

[0136] The above entity recognition model can adopt a BERT-CRF model or a BILSTM-CRF model.

[0137] The above-mentioned construction module 508 can also be used to extract the elements of each triple in the triple set, and use the preset cypher statement to construct a knowledge graph using the extracted elements.

[0138] The implementation principle and technical effects of the knowledge graph construction device based on secondary annotation provided in the embodiment of the present invention are the same as those of the aforementioned embodiment of the knowledge graph construction method based on secondary annotation. For the sake of brief description, for matters not mentioned in the embodiment of the knowledge graph construction device based on secondary annotation, reference may be made to the corresponding contents in the aforementioned embodiment of the knowledge graph construction method based on secondary annotation.

[0139] Unless otherwise specifically stated, the relative steps, numerical expressions and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present invention.

[0140] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0141] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as limiting the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.

[0142] Finally, it should be noted that the above-described embodiments are only specific implementations of the present invention, which are used to illustrate the technical solutions of the present invention, rather than to limit them. The protection scope of the present invention is not limited thereto. Although the present invention is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed by the present invention, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.

Claims

1. A knowledge graph construction method based on secondary annotation, characterized in that: include: Obtain a target text data set corresponding to a target classification label, and aggregate text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; wherein the target classification label is used to uniquely characterize the classification of a target entity, and the target entity has at least one attribute; Annotate the text data to be annotated in the obtained text data subset based on the preset BIO secondary annotation rules, and use the obtained annotated text data as a training set to train the entity recognition model; wherein each training sample in the training set is annotated with corresponding entities, attributes and attribute values; Using the trained entity recognition model to predict the unlabeled text data in each text data subset, to obtain the prediction results of the unlabeled text data; wherein the prediction results include entities, attributes and attribute values ​​corresponding to the corresponding unlabeled text data; A triple set of the target entity is generated based on the annotated text data and the prediction results, and a knowledge graph is constructed based on the triple set; wherein each triple in the triple set consists of a unique identifier, attributes and attribute values ​​of the corresponding entity.

2. The method for constructing a knowledge graph based on secondary annotation according to claim 1, characterized in that: Get the target text dataset corresponding to the target classification label, including: Initial text data is obtained, and the same classification label is assigned to text data belonging to the same entity classification in the initial text data, and then the text data with the target classification label is extracted as the target text data set.

3. The method for constructing a knowledge graph based on secondary annotation according to claim 1, characterized in that: Each target text data in the target text data set is stored in a corresponding first text document, and each first text document has a corresponding document index and a first document storage location; Aggregating text data corresponding to the same attribute value in the target text data set into corresponding text data subsets, including: Segment each target text data in the target text data set, and clean the obtained segmented text data; wherein the cleaning includes removing stop words; Convert each first text word in the obtained cleaned text data into a corresponding first word vector, and determine a target word vector corresponding to a corresponding second word vector in a preset word vector library from the obtained first word vector; wherein the preset word vector library has a second word vector corresponding to at least one attribute value of the target entity; Based on the determined target word vector and the document index and the first document storage position of each first text document, an inverted index algorithm is used to determine the first target text document whose text data contains the same attribute value from the obtained first text documents; The text data containing the same attribute value in the first target text document corresponding to the same attribute value is formed into a corresponding text data subset.

4. The method for constructing a knowledge graph based on secondary annotation according to claim 3, characterized in that: Determining a target word vector corresponding to a corresponding second word vector in a preset word vector library from the obtained first word vector includes: For each first word vector obtained, the similarity between the first word vector and each second word vector in the preset word vector library is calculated. If the similarity between the first word vector and the corresponding second word vector in the preset word vector library is greater than the preset similarity threshold, the first word vector is determined as the target word vector.

5. The method for constructing a knowledge graph based on secondary annotation according to claim 3, characterized in that: After aggregating the text data corresponding to the same attribute value in the target text data set into a corresponding text data subset, the method further includes: Convert each determined target word vector into a corresponding second text word; Generate a corresponding storage file directory for the text data subset based on the obtained second text word; wherein each storage file has its corresponding second text word as the file name; For each text data subset, each text data in the text data subset is stored in a corresponding second text document under the storage file directory corresponding to the text data subset; wherein each second text document has a corresponding second document storage location.

6. The method for constructing a knowledge graph based on secondary annotation according to claim 5, characterized in that: The text data to be annotated in the obtained text data subset is annotated based on the preset BIO secondary annotation rules, including: Based on the second document storage location of each second text document, determining the to-be-annotated text data corresponding to the corresponding text data subset from each second text document; According to the preset BIO secondary annotation rules, the corresponding entities and attributes are annotated for the text data to be annotated corresponding to each text data subset; The corresponding attribute values ​​are labeled for the text data with entities and attributes corresponding to each text data subset.

7. The method for constructing a knowledge graph based on secondary annotation according to claim 1, characterized in that: The unique identifier is the name of the corresponding entity; generating a triple set of the target entity based on the annotated text data and the prediction result, including: Based on the entities, attributes and attribute values ​​annotated by the annotated text data and the entities, attributes and attribute values ​​in the prediction results, a candidate triple set of the target entity is generated; wherein each candidate triple in the candidate triple set is composed of the name, attribute and attribute value of the corresponding entity; Deduplication processing is performed on candidate triples in the candidate triple set to obtain the triple set.

8. The method for constructing a knowledge graph based on secondary annotation according to claim 1, characterized in that: The entity recognition model adopts a BERT-CRF model or a BILSTM-CRF model.

9. The method for constructing a knowledge graph based on secondary annotation according to claim 1, characterized in that: Constructing a knowledge graph based on the triple set includes: The elements of each triple in the triple set are extracted, and a knowledge graph is constructed using the extracted elements using a preset cypher statement.

10. A knowledge graph construction device based on secondary annotation, characterized in that: include: An aggregation module is used to obtain a target text data set corresponding to a target classification label, and aggregate text data corresponding to the same attribute value in the target text data set into a corresponding text data subset; wherein the target classification label is used to uniquely characterize the classification of a target entity, and the target entity has at least one attribute; A training module is used to annotate the text data to be annotated in the obtained text data subset based on a preset BIO secondary annotation rule, and train an entity recognition model using the obtained annotated text data as a training set; wherein each training sample in the training set is annotated with a corresponding entity, attribute and attribute value; A prediction module, used to predict the unlabeled text data in each text data subset using the trained entity recognition model to obtain the prediction results of the unlabeled text data; wherein the prediction results include entities, attributes and attribute values ​​corresponding to the corresponding unlabeled text data; A construction module is used to generate a triple set of the target entity based on the annotated text data and the prediction results, and to construct a knowledge graph based on the triple set; wherein each triple in the triple set consists of a unique identifier, attributes and attribute values ​​of the corresponding entity.