Entity mining method and device, computer device and storage medium
By generating prototype label vectors through clustering and encoding, and adding entity type labels to word fragments in the text to be labeled using similarity comparison, the problem of high cost in traditional entity mining is solved, and efficient and low-cost entity labeling and data preprocessing are achieved.
Patent Information
- Application Number
- CN202111197163.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-14
- Publication Date
- 2025-10-28
- Estimated Expiration
- 2041-10-14
AI Technical Summary
Traditional entity mining methods are costly, manual entity type labeling is expensive, and a large amount of labeled data is required for model training.
Prototype label vectors are generated by clustering and encoding. Entity type labels are added to word fragments in the text to be labeled using similarity comparison, reducing the amount of labeled data and generating multiple prototype label vectors using a small amount of similar labeled data.
It achieves cost savings in entity mining, reduces data requirements for model training, improves the efficiency and accuracy of entity annotation, and provides data cold start capability.
Smart Images

Figure CN114090769B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence technology and knowledge graph technology, and in particular to an entity mining method, apparatus, computer equipment, and storage medium. Background Technology
[0002] With the development of artificial intelligence technology, many advanced technologies have emerged, among which entity mining technology is an important one, playing a crucial role in many fields. For example, in the field of knowledge graphs, it is necessary to mine new entity representations from unstructured text and add corresponding entity type labels to construct structured knowledge graphs.
[0003] Traditional entity mining requires manual annotation of numerous sentences to identify target entity types. The annotated data is then used to train a model, which predicts the entity types of the sentences. This manual annotation process typically involves tens of thousands of annotations, making it extremely costly. Furthermore, the manual annotation of entity types within sentences is itself very expensive. Therefore, traditional entity mining methods are very costly. Summary of the Invention
[0004] Therefore, it is necessary to provide a cost-effective entity mining method, apparatus, computer equipment, and storage medium to address the aforementioned technical problems.
[0005] An entity mining method, the method comprising:
[0006] Retrieve the text entities labeled with the same entity type;
[0007] The labeled text entities are clustered to obtain multiple clusters;
[0008] Encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label.
[0009] Encode the text to be annotated to obtain the word vector corresponding to each word segment in the text;
[0010] For each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarity values;
[0011] If the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector.
[0012] A physical excavation device, the device comprising:
[0013] The acquisition module is used to acquire labeled text entities that are labeled with the same entity type.
[0014] The clustering module is used to cluster the labeled text entities to obtain multiple clusters;
[0015] The encoding module is used to encode the labeled text entities in the same cluster respectively, generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label; and to encode the text to be labeled to obtain the word vector corresponding to each word fragment in the text to be labeled.
[0016] The annotation module is used to determine the similarity between each word vector and the multiple prototype label vectors to obtain multiple similarities; if the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector.
[0017] In one embodiment, the encoding module is further configured to obtain a pre-trained label vector encoding model; input the labeled text entities in each cluster into the label vector encoding model, output the corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label.
[0018] In one embodiment, the apparatus further includes:
[0019] A training module is used to acquire sample data, which includes sample text and sample entity type labels of sample entities in the sample text. In each round of iterative training, for each sample entity type label, sample entities carrying the sample entity type label are selected from the sample data to obtain a corresponding support set. The sample entities in the support set are input into the label vector encoding model to be trained to predict multiple prototype label vectors corresponding to the sample entity type label. The sample text where the sample entity is located is vectorized to obtain a target vector. From the multiple predicted prototype label vectors, the prototype label vector closest to the target vector is selected. The model parameters are adjusted in the direction that makes the closest prototype label vector close to the target vector, and iterative training continues until the iteration stopping condition is met to obtain the final label vector encoding model.
[0020] In one embodiment, the training module is further configured to acquire raw data; search for entity nodes matching the entity names of text entities in the raw data from an open-source knowledge graph; if only one entity node is found, add an entity type label to the corresponding text entity in the raw data according to the entity type corresponding to the unique entity node to obtain labeled sample data; if multiple entity nodes are found, remove the text entities from the raw data.
[0021] In one embodiment, the training module is further configured to search for triples corresponding to text entities in the original data from the open-source knowledge graph; and determine entity nodes that match the entity name of the text entity from the triples.
[0022] In one embodiment, the original data includes the original page and hyperlinks in the original page; the training module is further configured to search for matching entity nodes in the open-source knowledge graph based on the entity names of the text entities in the original page; add entity type labels to the corresponding text entities in the original page based on the entity type corresponding to the unique entity node; determine the corresponding hyperlink entities in the pages to which the hyperlinks are connected, and add corresponding entity type labels to the hyperlink entities in the connected pages to obtain labeled sample data.
[0023] In one embodiment, the clustering module is further configured to pre-cluster the labeled text entities according to a preset number of candidate cluster centers to obtain multiple pre-clustering results; analyze the multiple pre-clustering results to obtain clustering analysis index values; select a target number of cluster centers from the multiple number of candidate cluster centers according to the clustering analysis index values; and cluster the labeled text entities according to the target number of cluster centers to obtain multiple clusters.
[0024] A computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program performing the following steps:
[0025] Retrieve the text entities labeled with the same entity type;
[0026] The labeled text entities are clustered to obtain multiple clusters;
[0027] Encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label.
[0028] Encode the text to be annotated to obtain the word vector corresponding to each word segment in the text;
[0029] For each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarity values;
[0030] If the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector.
[0031] A computer-readable storage medium having a computer program stored thereon, the computer program performing the following steps when executed by a processor:
[0032] Retrieve the text entities labeled with the same entity type;
[0033] The labeled text entities are clustered to obtain multiple clusters;
[0034] Encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label.
[0035] Encode the text to be annotated to obtain the word vector corresponding to each word segment in the text;
[0036] For each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarity values;
[0037] If the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector.
[0038] The aforementioned entity mining method, apparatus, computer equipment, and storage medium acquire labeled text entities with the same entity type label; cluster the labeled text entities to obtain multiple clusters; encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, resulting in multiple prototype label vectors corresponding to the entity type label. In this case, the amount of labeled text entity data is much smaller than the amount of supervised training data, equivalent to using a small amount of similar labeled data to generate multiple prototype label vectors corresponding to the entity type label. Furthermore, when performing entity mining on the text to be labeled, the text to be labeled can be encoded to obtain word vectors corresponding to each word segment in the text to be labeled; for each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarities; if the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word segment corresponding to the word vector. That is, the text to be labeled can be encoded and directly compared with multiple prototype label vectors to add entity type labels to the word segments in the text to be labeled. That is, entity mining can be achieved without a large amount of labeled data to train the model, only a small amount of similar labeled data is needed, thus saving costs. Attached Figure Description
[0039] Figure 1 This is a diagram illustrating the application environment of the entity mining method in one embodiment;
[0040] Figure 2 This is a flowchart illustrating an entity mining method in one embodiment;
[0041] Figure 3 This is a flowchart illustrating the model training steps in one embodiment;
[0042] Figure 4 This is a schematic diagram illustrating the principle of entity mining using a label vector encoding model in one embodiment;
[0043] Figure 5 This is a block diagram of a physical excavation device in one embodiment;
[0044] Figure 6 A block diagram of the entity excavation device in another embodiment;
[0045] Figure 7 This is an internal structural diagram of a computer device in one embodiment;
[0046] Figure 8 Another embodiment shows the internal structure of a computer device. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0048] The entity mining method provided in this application can be applied to, for example... Figure 1 In the application environment shown, server 102 communicates with terminal 104 via a network. Terminal 104 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, and portable wearable devices. Server 102 can be implemented using a standalone server or a server cluster consisting of multiple servers.
[0049] Server 102 can obtain labeled text entities sent by terminal 104 that are labeled with the same entity type. Server 102 can cluster the labeled text entities to obtain multiple clusters; it can encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, thus obtaining multiple prototype label vectors corresponding to entity type labels. Server 102 can encode the text to be labeled to obtain word vectors corresponding to each word segment in the text to be labeled; for each word vector, it can determine the similarity between the word vector and multiple prototype label vectors, thus obtaining multiple similarity scores. If the maximum similarity score among the multiple similarity scores is greater than or equal to a preset threshold, server 102 can add entity type labels to the word segments corresponding to the word vectors.
[0050] It should be noted that, Figure 1 This is merely an illustrative example. In other embodiments, server 102 may also directly retrieve labeled text entities with the same entity type from the database.
[0051] In one embodiment, such as Figure 2 As shown, an entity mining method is provided. This method can be applied to computer equipment, which can be a terminal or a server. The method specifically includes the following steps:
[0052] Step 202: Obtain the labeled text entities that are labeled with the same entity type.
[0053] In this context, an entity is an objectively existing and distinguishable thing. In databases, an entity often refers to a collection of things of a certain kind. Each individual data object of a category is called an entity. A text entity is an entity in text or a text-formatted entity. A labeled text entity is a text entity carrying an entity type label. Entity type labels are used to characterize the entity type. For example, the text entity "Shanghai" could carry the entity type label "city".
[0054] It is understood that the number of labeled text entities with the same entity type label obtained in step 202 is much smaller than the amount of labeled data during supervised model training. That is, a small amount of similar labeled data (i.e. labeled text entities with the same entity type label) can be used to predict the entity type label of word fragments in the text to be labeled by executing the methods in the various embodiments of this application. Compared with using a large amount of labeled data for model training, this greatly reduces the amount of data and saves costs.
[0055] In one embodiment, the computer device can directly retrieve labeled text entities with the same entity type tag from a database or terminal, or it can retrieve unlabeled text entities without entity type tags. Then, it can automatically add entity type tags to the unlabeled text entities and retrieve labeled text entities with the same entity type tag from them. No limitation is imposed on this approach.
[0056] Step 204: Cluster the labeled text entities to obtain multiple clusters.
[0057] Specifically, the computer device clusters labeled text entities with the same entity type, resulting in multiple clusters. In essence, it further clusters labeled text entities of the same entity type.
[0058] In one embodiment, a computer device can perform cluster analysis on labeled text entities to calculate the optimal number of target cluster centers, and then cluster the labeled text entities according to the target number of cluster centers to obtain multiple clusters.
[0059] In one embodiment, a computer device can use the K-means clustering algorithm to cluster labeled text entities according to the target number of cluster centers, resulting in multiple clusters. The K-means clustering algorithm is an iterative clustering analysis algorithm.
[0060] Step 206: Encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type labels.
[0061] Among them, ProtoVectors are vectors related to entity type labels, that is, vectors used to represent the entity type characteristics corresponding to the entity type label.
[0062] Specifically, for each cluster, the computer device can encode the labeled text entities within that cluster, and then combine the encoded vectors to generate a corresponding prototype label vector. It can be understood that at least one prototype label vector is generated for each cluster. Since each cluster has a corresponding prototype label vector, and the labeled text entities within these clusters all correspond to the same entity type label, the prototype label vectors corresponding to multiple clusters are thus multiple prototype label vectors corresponding to the entity type label.
[0063] In one embodiment, the computer device can randomly combine the encoded vectors to generate corresponding prototype label vectors. Specifically, the computer device can randomly select vectors from the encoded vectors and combine the randomly selected vectors to generate corresponding prototype label vectors.
[0064] In other embodiments, the computer device may also select and combine the encoded vectors according to preset rules to generate corresponding prototype label vectors. This is not a limitation.
[0065] In one embodiment, a computer device can use a pre-trained label vector encoding model to encode labeled text entities within the same cluster, generating corresponding prototype label vectors. The label vector encoding model is a neural network model used to encode and generate prototype label vectors.
[0066] It should be noted that if there are multiple entity type tags, steps 202 to 206 can be executed for each entity type tag to obtain multiple prototype tag vectors corresponding to each entity type tag.
[0067] Step 208: Encode the text to be annotated to obtain the word vector corresponding to each word segment in the text to be annotated.
[0068] Specifically, computer devices can encode each word segment in the text to be annotated to obtain the word vector corresponding to each word segment in the text to be annotated.
[0069] It can be understood that the text to be annotated includes multiple word fragments, which are multiple tokens. The text to be annotated is equivalent to a sequence of word fragments, or a sequence of tokens. This is equivalent to encoding each token in the token sequence to represent each token as a vector, which is to obtain the word vector corresponding to each word fragment (i.e., token).
[0070] In one embodiment, the text to be labeled can be dialogue log text generated by the dialogue system. That is, based on the methods in the various embodiments of this application, corresponding entity type tags can be added to entities in the dialogue log text, i.e., entities can be extracted from the dialogue log text.
[0071] Step 210: For each word vector, determine the similarity between the word vector and multiple prototype label vectors to obtain multiple similarity scores.
[0072] Specifically, for each word vector obtained from the encoding of the text to be labeled, when determining which entity type label the word vector belongs to, the similarity between the word vector and each prototype label vector corresponding to the entity type label to be determined can be calculated to obtain multiple similarities corresponding to the word vector under the entity type label to be determined.
[0073] Step 212: If the maximum similarity among multiple similarities is greater than or equal to a preset threshold, then add entity type labels to the word fragments corresponding to the word vectors.
[0074] Specifically, the computer device can determine the maximum similarity from multiple similarities corresponding to the word vector under the entity type label to be determined. If the maximum similarity is greater than or equal to a preset threshold, it means that the entity type represented by the entity type label is the entity type to which the word fragment corresponding to the word vector belongs. Therefore, the entity type label can be added to the word fragment corresponding to the word vector.
[0075] It is understandable that when there are multiple entity type labels to be determined, the current entity type label can be selected sequentially from these multiple labels. Then, the similarity between the word vector and the prototype label vector corresponding to the current entity type label is calculated. If the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, the current entity type label is added to the word segment corresponding to the word vector. If the maximum similarity is less than the preset threshold, the next entity type label to be determined is selected as the current entity type label, and the process returns to the step of calculating the similarity between the word vector and the prototype label vector corresponding to the current entity type label, continuing until the corresponding entity type label is added to the word segment corresponding to the word vector or all the entity type labels to be determined have been compared.
[0076] The aforementioned entity mining method obtains labeled text entities with the same entity type label; clusters the labeled text entities to obtain multiple clusters; and encodes the labeled text entities in the same cluster to generate corresponding prototype label vectors, resulting in multiple prototype label vectors corresponding to the entity type label. In this case, the amount of labeled text entity data is much smaller than the amount of supervised training data, equivalent to using a small amount of similar labeled data to generate multiple prototype label vectors corresponding to the entity type label. Furthermore, when performing entity mining on the text to be labeled, the text can be encoded to obtain word vectors corresponding to each word segment in the text to be labeled; for each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarities; if the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, the entity type label is added to the word segment corresponding to the word vector. That is, the text to be labeled can be encoded and directly compared with multiple prototype label vectors to add entity type labels to the word segments in the text to be labeled. That is, entity mining can be achieved without a large amount of labeled data to train the model, only a small amount of similar labeled data is needed, thus saving costs.
[0077] Secondly, traditional methods for entity mining using supervised training models require continuous data updates to the training model. However, the method in this application does not require updating the training. It can accurately and conveniently label entities in the text by comparing similarity with multiple prototype label vectors. It has universality, saving the cost of updating the training while ensuring the accuracy of entity mining.
[0078] Furthermore, by adding entity type labels to entities in the text using the entity mining method in this application embodiment, the labeled text can be used as basic data for more precise subsequent processing. For example, it provides basic data for training and updating a more accurate annotation model, thus providing data cold start capability and eliminating the need for manual annotation by annotators, thereby improving efficiency.
[0079] In one embodiment, step 206 encodes the labeled text entities in the same cluster to generate corresponding prototype label vectors, thereby obtaining multiple prototype label vectors corresponding to the entity type label. This includes: obtaining a pre-trained label vector encoding model; inputting the labeled text entities in each cluster into the label vector encoding model, outputting the corresponding prototype label vectors, and obtaining multiple prototype label vectors corresponding to the entity type label.
[0080] The label vector encoding model is a neural network model used to encode and generate multiple prototype label vectors; it can also be called a multi-prototype network.
[0081] Specifically, a label vector encoding model is pre-trained in the computer device. The computer device can input the labeled text entities in each cluster into the label vector encoding model for encoding processing. The label vector encoding model can combine the vectors obtained from encoding the labeled text entities to generate corresponding prototype label vectors. Thus, the prototype label vectors corresponding to each cluster are used as multiple prototype label vectors corresponding to the entity type labels.
[0082] In one embodiment, a computer device can use sample text with sample text type labels to train a label vector encoding model through supervised training.
[0083] In the above embodiments, based on the pre-trained label vector encoding model, multiple prototype label vectors corresponding to entity type labels can be accurately predicted.
[0084] like Figure 3 As shown, in one embodiment, the label vector encoding model is obtained through a model training step, which includes:
[0085] Step 302: Obtain sample data; the sample data includes sample text and sample entity type labels of sample entities in the sample text.
[0086] In one embodiment, the computer device may select a subset of sample entity type labels from the sample entity type labels included in the sample data, and perform iterative training in steps 304 to 312 based on the selected sample entity type labels to achieve training with fewer samples. For example, if the total number of sample entity type labels included in the sample data is N, T sample entity type labels may be randomly selected from them for iterative training.
[0087] In one embodiment, the labels for positive and negative samples in the sample data are automatically predicted. However, mislabeling may occur in the sample data; for example, a negative sample might be incorrectly predicted as a positive sample, leading to a low recall rate. This means the proportion of correctly predicted positive samples (i.e., true positive samples) is low compared to the actual predicted positive samples. In this task, we focus on the positive sample labeling results, so we need to avoid interference from mispredicted negative samples. Therefore, before using the sample data for model training, the computer can preprocess the sample data to improve the accuracy of automatic prediction labeling. Specifically, the computer can pre-train multiple models using k-fold cross-validation, and then use these models to re-predict entity type labels for the sample text entities in the sample data, i.e., re-label them. For sample entities that are actually negative but were mispredicted as positive, they can be relabeled as uncertain, thus removing uncertainly labeled sample entities from the sample data to avoid introducing erroneous supervision signals and improve recall.
[0088] Step 304: In each round of iterative training, for each sample entity type label, filter the sample entities carrying the sample entity type label from the sample data to obtain the corresponding support set.
[0089] It is understandable that the support set is a part of the sample data, that is, a portion selected from the full sample data as the support set.
[0090] Specifically, during iterative training, for each sample entity type label, the computer device can randomly select a preset number of sample entities carrying the sample entity type label from the sample entities carrying that sample entity type label in the sample data, and use this selected part of the data as the corresponding support set for that sample entity type label.
[0091] It's understandable that the support set selected for each sample entity type label can be multiple sets, specifically based on the number of prototype label vectors corresponding to that sample entity type label. For example, assuming we need to predict v prototype label vectors for a sample entity type label, then we can select V support sets. The data size in each support set is the preset number used for selection; this preset number can be k. Therefore, the data size in the v support sets would be v*K data points.
[0092] Step 306: Input the sample entities in the support set into the label vector encoding model to be trained, and predict multiple prototype label vectors corresponding to the sample entity type labels.
[0093] Specifically, computer equipment can input the sample entities from each selected support set into the label vector encoding model to be trained, and predict multiple prototype label vectors corresponding to the sample entity type labels.
[0094] In one embodiment, for each support set, the computer device can encode the sample entities input to the support set using a label vector encoding model to be trained, obtaining corresponding vectors, and then calculate the average of the obtained vectors to obtain a prototype label vector. Therefore, for multiple support sets, this process can yield multiple prototype label vectors. For example, for v support sets, v prototype label vectors can be obtained.
[0095] Step 308: Vectorize the sample text containing the sample entity to obtain the target vector.
[0096] Specifically, computer equipment can vectorize the sample text containing the sample entity to obtain the target vector, which is equivalent to vectorizing the statement.
[0097] Step 310: Select the prototype label vector that is closest to the target vector from the multiple predicted prototype label vectors.
[0098] Specifically, the computer device can calculate the similarity between the target vector and multiple predicted prototype label vectors, and select the prototype label vector with the highest similarity from the multiple prototype label vectors. In other words, the prototype label vector with the highest similarity is the prototype label vector that is closest to the target vector.
[0099] Step 312: Adjust the model parameters in the direction that makes the closest prototype label vector close to the target vector, and continue iterative training until the iteration stopping condition is met to obtain the final label vector encoding model.
[0100] Specifically, the computer device can adjust the model parameters in the direction that makes the closest prototype label vector close to the target vector, and enter the next round of iterative training. This iterative training continues until the iteration stopping condition is met, and the final label vector encoding model is obtained.
[0101] It can be understood that each sample entity type label corresponds to multiple prototype label vectors, which is equivalent to each sample entity type label having multiple centers. Adjusting the model parameters in the direction that makes the closest prototype label vector close to the target vector is equivalent to ensuring that each text entity can be optimized to the vicinity of the closest center point, thereby reducing the optimization difficulty and saving training costs.
[0102] In the above embodiments, a label vector encoding model can be trained using a small number of samples, which greatly saves data costs and also saves the processing resources consumed during the model training process caused by too many samples.
[0103] Figure 4 This is a schematic diagram illustrating the principle of entity mining using a label vector encoding model in one embodiment. See also... Figure 4 This approach, referencing the concept of pointer networks, breaks down entity type prediction into classification based on the entity's head and tail. Specifically, the sentence to be labeled (i.e., the text to be labeled), "Mr. Bush asked Congress to raise to $6 billion," can be input into a base network model trained on a transformer network architecture. This allows each word segment (i.e., each token) to be encoded, abstracted into a vector representation to obtain word vectors. Then, classification is performed based on the head and tail, respectively. During classification, cosine similarity is calculated based on multiple prototype label vectors pre-generated by the label vector encoding model for entity type labels. That is, the word vectors are compared with the multiple prototype label vectors corresponding to the entity type labels, and the similarity is calculated using cosine similarity. The head classification result and tail classification result are obtained separately. It can be understood that both the head classification result and the tail classification result include the calculated similarity scores. Therefore, the maximum similarity score can be selected from the similarity scores with multiple prototype label vectors. Taking the content shown in 402 as an example, "In the head classification result, P: 0.95, 0.1, 0.03, 0.1, 0.02, 0.01, 0.21, 0.0, 0.07, 0.12" represents 10 similarity comparison results, with the maximum similarity score being 0.95. It can be understood that the entity type label can be determined based on the maximum similarity score in the head classification result and the tail classification result.
[0104] In one embodiment, obtaining sample data in step 302 includes: obtaining raw data; searching for entity nodes matching the entity names of text entities in the raw data from an open-source knowledge graph; if only one entity node is found, adding an entity type label to the corresponding text entity in the raw data according to the entity type corresponding to the unique entity node to obtain labeled sample data; if multiple entity nodes are found, removing the text entities from the raw data.
[0105] The raw data refers to the original text without sample text type labels. This means the raw data includes text entities without sample text type labels. The open-source knowledge graph is an open-source knowledge graph. A knowledge graph is a graph-based data structure composed of nodes (points) and edges (edges). Each node represents an "entity," and each edge represents a "relationship" between entities. Essentially, a knowledge graph is a semantic network. Entity nodes are the nodes representing entities in the open-source knowledge graph.
[0106] In one embodiment, the open-source knowledge graph can be any one of CN-DBpedia, Zhishi.me, or BabelNet.
[0107] It is understandable that computer devices can look up the entity type corresponding to each text entity in the original data from the open-source knowledge graph, and then add the corresponding entity type label to each text entity.
[0108] Specifically, the computer device can search for entity nodes in the open-source knowledge graph that match the entity name of a text entity in the original data. If only one entity node is found (i.e., one text entity in the original data uniquely corresponds to one entity node), then an entity type label is added to the corresponding text entity in the original data based on the entity type corresponding to the unique entity node. If multiple entity nodes are found (i.e., one text entity in the original data corresponds to multiple entity nodes), it indicates that the text entity is ambiguous, and the computer device can then remove the text entity from the original data.
[0109] For example, searching for the entity name "notebook" in an open-source knowledge graph may match multiple entity nodes, such as an entity node representing "computer" and an entity node representing "notebook". In this case, the ambiguous text entity "notebook" is filtered out from the original data.
[0110] In one embodiment, a computer device can use encyclopedia websites with abundant hyperlinks between entities as a data source to crawl raw data. In another embodiment, the computer device can obtain the main text information from the encyclopedia website, save this main text information along with the hyperlinks on the text entities within it, and obtain the raw data. It can be understood that hyperlinks on text entities are used to represent the relationships between text entities.
[0111] In other embodiments, the computer device may also directly obtain raw data from a database, without having to crawl raw data from encyclopedia websites.
[0112] In the above embodiments, ambiguous text entities in the original data can be removed based on the open-source knowledge graph, and corresponding entity type labels can be automatically added to the remaining unambiguous text entities, which is very convenient and efficient. In addition, removing ambiguous text entities in the original data can reduce noise and improve the accuracy of the sample data.
[0113] In one embodiment, searching for entity nodes matching the entity name of a text entity in the original data from an open-source knowledge graph includes: searching for triples corresponding to the text entities in the original data from the open-source knowledge graph; and determining entity nodes matching the entity name of the text entities from the triples.
[0114] It is understandable that in a knowledge graph, a node-edge-node can be regarded as a record, the first entity node is regarded as the subject, the edge as the predicate, and the second entity node as the object. Subject, predicate, and object constitute a record. Therefore, the data in the knowledge graph is organized in the form of triples (subject, predicate, object).
[0115] Therefore, multiple triples are pre-built in the open-source knowledge graph. Computer devices can search for the triples corresponding to each text entity in the original data from the open-source knowledge graph. It can be understood that the subject and object in each triple are two entity nodes. Therefore, the computer device can determine the entity node that matches the entity name of the text entity from the corresponding triple. Then, based on the entity type corresponding to the matching entity node, an entity type label is added to the text entity.
[0116] In one embodiment, when the original data includes the original page and hyperlinks in the original page, the computer device can not only determine the triples of the text entities in the original page to determine the entity type label of the text entities, but also determine the hyperlink entity corresponding to the hyperlink, determine the triples corresponding to the hyperlink entity, and then determine the entity type label corresponding to the hyperlink entity based on the triples.
[0117] In one embodiment, the text entity and the corresponding hyperlink entity in the original page can be two entity nodes in a triple, and the predicate in the triple can be the relationship between the text entity and the corresponding hyperlink entity. If a set of text entities and hyperlink entities exists in multiple triples, it indicates that the text entities and hyperlink entities have multiple relationships, that is, multiple predicates. The computer device can then select a target predicate as a predicate annotation to characterize the final or most consistent relationship between the text entity and the corresponding hyperlink entity in the original page. For example, the computer device can select the predicate that is used most frequently (i.e., the most commonly used predicate) as the target predicate, and then use the target predicate to annotate the corresponding triples.
[0118] It is understandable that an entity may have multiple relationships with another entity. For example, Shanghai and Beijing may have relationships in terms of history, economy, etc. The most suitable relationship can be selected as the predicate label (i.e., relation label) in the triple.
[0119] In the above embodiments, triples based on open-source knowledge graphs can quickly add labels to the original data, that is, they can quickly and conveniently obtain labeled sample data.
[0120] In one embodiment, the original data includes the original page and hyperlinks within the original page. Searching for entity nodes matching the entity names of text entities in the original data from an open-source knowledge graph includes: searching for matching entity nodes in the open-source knowledge graph based on the text entities in the original page. In this embodiment, adding entity type tags to the corresponding text entities in the original data based on the unique entity type corresponding to each entity node to obtain labeled sample data includes: adding entity type tags to the corresponding text entities in the original page based on the unique entity type corresponding to each entity node; determining the corresponding hyperlink entity in the page to which the hyperlink connects, and adding corresponding entity type tags to the hyperlink entity in the connected page to obtain labeled sample data.
[0121] In this context, a hyperlink entity refers to a text entity that a user clicks on from a text entity on the original page via a corresponding hyperlink. Essentially, a hyperlink entity is a text entity on the page that the hyperlink links to.
[0122] For example, in the original page A, "City 1" is a text entity with a corresponding hyperlink. Clicking "City 1" will trigger the corresponding hyperlink to jump to the text entity "City 2" in page B. Therefore, "City 2" is a hyperlink entity.
[0123] Specifically, the computer device can search for matching entity nodes in an open-source knowledge graph based on the text entities in the original page. If the found entity node is unique, the computer device determines the entity type corresponding to that unique entity node from the open-source knowledge graph and adds an entity type label representing that entity type to the corresponding text entity in the original page. The computer device can also determine the corresponding hyperlink entity in the page that the hyperlink connects to, and can add the corresponding entity type label to that hyperlink entity in the linked page. After performing the above annotation, the computer device can obtain the annotated sample data.
[0124] In one embodiment, the computer device can parse the relationship between text entities and corresponding hyperlink entities in the original page. If the relationship determines that the hyperlink entity and the corresponding text entity belong to the same type of entity, the hyperlink entity can be labeled according to the entity type tag of the text entity corresponding to the hyperlink entity in the original page (i.e., the text entity corresponding to the hyperlink used to jump to the hyperlink entity in the original page). In one embodiment, the computer device can obtain the corresponding predicate annotation from the triple to which the text entity and the corresponding hyperlink entity belong, and determine whether the hyperlink entity and the corresponding text entity belong to the same type of entity based on the relationship represented by the predicate annotation.
[0125] In another embodiment, the computer device may also search for an entity node matching the entity name from an open-source knowledge graph based on the entity name of the hyperlink entity. If only one entity node is found, an entity type tag is added to the hyperlink entity based on the entity type corresponding to the unique entity node.
[0126] In one embodiment, the computer device can also obtain a list of entity aliases, which records various entity aliases. The computer device can search the original page according to the entity aliases recorded in the list, find text entities on the page that match the entity aliases, and add corresponding entity type tags to the searched text entities according to the entity type corresponding to the entity alias. This avoids missing entity type tags for entity aliases on the page, greatly improving the accuracy of automatic tagging. It can be understood that the entity alias corresponds to the same entity type as the regular entity name.
[0127] In one embodiment, the computer device can also look up the entity alias corresponding to the hyperlink entity from the entity alias list, search for the entity alias in the page linked by the hyperlink entity to find text entities that match the entity alias, and add entity type tags corresponding to the hyperlink entity to the text entities found in the linked pages. For example, if page B is the page linked by a hyperlink in the original page A, and page B has multiple entity aliases for hyperlink entity 1, then the entity aliases for hyperlink entity 1 can be found in the entity alias list, and then searched in page B to find text entities in page B that match the entity aliases. These text entities in page B are then all marked with the same entity type tag as hyperlink entity 1.
[0128] In one embodiment, a computer device can determine two-hop hyperlink entities from the original page. A two-hop hyperlink entity refers to a text entity reachable by clicking the hyperlink twice on the page. The computer device can search for the entity alias corresponding to the two-hop hyperlink entity from a list of entity aliases, and then search for text entities matching the entity alias on the page containing the two-hop hyperlink entity. Finally, the computer device adds an entity type tag corresponding to the two-hop hyperlink entity to the text entities found on the page.
[0129] In the above embodiments, not only can text entities in the original page be annotated, but hyperlink entities can also be conveniently annotated, which improves the annotation efficiency of the original data and thus improves the generation efficiency of sample data.
[0130] In one embodiment, step 204 clusters the labeled text entities to obtain multiple clusters, including: performing pre-clustering on the labeled text entities according to a preset number of candidate cluster centers to obtain multiple pre-clustering results; analyzing the multiple pre-clustering results to obtain clustering analysis index values; selecting a target number of cluster centers from the multiple candidate cluster centers based on the clustering analysis index values; and clustering the labeled text entities according to the target number of cluster centers to obtain multiple clusters.
[0131] Here, the clustering analysis index value is the numerical value of the clustering analysis indicator. The clustering analysis indicator is the metric used to perform clustering analysis. In one embodiment, the clustering analysis indicator can be BIC. Pre-clustering is equivalent to preliminary clustering or attempted clustering, and is not the clustering process used to generate the final clustering result.
[0132] Specifically, the computer device can pre-cluster the labeled text entities according to a preset number of candidate cluster centers, obtaining multiple pre-clustering results. The computer device can analyze the multiple pre-clustering results to obtain clustering analysis index values. That is, it attempts to perform clustering using multiple candidate cluster center numbers K (i.e., using different K values), and uses the clustering results to calculate clustering analysis index values. Furthermore, the computer device can select the target number of cluster centers from the multiple candidate cluster center numbers based on the clustering analysis index values, that is, select the most suitable number of cluster centers.
[0133] In one embodiment, the computer device may select the minimum cluster analysis index value from the cluster analysis index values calculated based on each clustering result, and use the number of candidate cluster centers corresponding to the minimum cluster analysis index value as the target number of cluster centers.
[0134] Furthermore, the computer equipment can cluster the labeled text entities according to the selected target cluster centers, resulting in multiple clusters.
[0135] In the above embodiments, the appropriate number of target cluster centers can be determined based on the clustering analysis index value, thereby enabling reasonable clustering of labeled text entities, which in turn improves the accuracy of subsequent generation of prototype label vectors, thereby improving the accuracy of subsequent entity type label addition, i.e., improving the accuracy of entity mining.
[0136] It should be understood that although the steps in the flowcharts of the various embodiments of this application are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the various embodiments of this application may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least a portion of the steps or stages of other steps.
[0137] In one embodiment, such as Figure 5 As shown, an entity mining device is provided, including: an acquisition module 502, a clustering module 504, an encoding module 506, and an annotation module 508, wherein:
[0138] Module 502 is used to obtain labeled text entities that are labeled with the same entity type.
[0139] Clustering module 504 is used to cluster the labeled text entities to obtain multiple clusters;
[0140] Encoding module 506 is used to encode the labeled text entities in the same cluster respectively, generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label; and to encode the text to be labeled to obtain the word vector corresponding to each word segment in the text to be labeled.
[0141] The annotation module 508 is used to determine the similarity between each word vector and the plurality of prototype label vectors to obtain multiple similarities; if the maximum similarity among the plurality of similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector.
[0142] In one embodiment, the encoding module 506 is further configured to obtain a pre-trained label vector encoding model; input the labeled text entities in each cluster into the label vector encoding model, output the corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label.
[0143] like Figure 6 As shown, in one embodiment, the apparatus further includes:
[0144] Training module 501 is used to acquire sample data; the sample data includes sample text and sample entity type labels of sample entities in the sample text; in each round of iterative training, for each sample entity type label, sample entities carrying the sample entity type label are selected from the sample data to obtain a corresponding support set; the sample entities in the support set are input into the label vector encoding model to be trained to predict multiple prototype label vectors corresponding to the sample entity type label; the sample text where the sample entity is located is vectorized to obtain a target vector; from the multiple predicted prototype label vectors, the prototype label vector closest to the target vector is selected; the model parameters are adjusted in the direction that makes the closest prototype label vector close to the target vector, and iterative training continues until the iteration stopping condition is met to obtain the final label vector encoding model.
[0145] In one embodiment, the training module 501 is further configured to acquire raw data; search for entity nodes matching the entity names of text entities in the raw data from an open-source knowledge graph; if only one entity node is found, add an entity type label to the corresponding text entity in the raw data according to the entity type corresponding to the unique entity node to obtain labeled sample data; if multiple entity nodes are found, remove the text entities from the raw data.
[0146] In one embodiment, the training module 501 is further configured to search for triples corresponding to text entities in the original data from the open-source knowledge graph; and determine entity nodes that match the entity name of the text entity from the triples.
[0147] In one embodiment, the original data includes the original page and hyperlinks in the original page; the training module 501 is further configured to search for matching entity nodes in the open-source knowledge graph based on the entity names of the text entities in the original page; add entity type labels to the corresponding text entities in the original page based on the entity type corresponding to the unique entity node; determine the corresponding hyperlink entities in the pages to which the hyperlinks are connected, and add corresponding entity type labels to the hyperlink entities in the connected pages to obtain labeled sample data.
[0148] In one embodiment, the clustering module 504 is further configured to pre-cluster the labeled text entities according to a preset number of candidate cluster centers to obtain multiple pre-clustering results; analyze the multiple pre-clustering results to obtain clustering analysis index values; select a target number of cluster centers from the multiple number of candidate cluster centers according to the clustering analysis index values; and cluster the labeled text entities according to the target number of cluster centers to obtain multiple clusters.
[0149] Specific limitations regarding the physical excavation device can be found in the limitations of the physical excavation method described above, and will not be repeated here. Each module in the aforementioned physical excavation device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.
[0150] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, the computer device includes a processor, memory, and a network interface connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The network interface is used to communicate with external terminals via a network connection. When the computer program is executed by the processor, it implements an entity mining method.
[0151] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 8As shown, the computer device includes a processor, memory, communication interface, display screen, and input devices connected via a system bus. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, carrier networks, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements an entity mining method. The display screen can be an LCD screen or an e-ink screen. The input devices can be a touch layer covering the display screen, buttons, a trackball, or a touchpad mounted on the computer device casing, or an external keyboard, touchpad, or mouse.
[0152] Those skilled in the art will understand that Figure 7 or Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0153] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the methods described in the embodiments of this application.
[0154] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the methods described in the embodiments of this application.
[0155] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0156] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0157] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for entity mining, characterized in that, The method includes: Retrieve the text entities labeled with the same entity type; The labeled text entities are clustered to obtain multiple clusters; Encode the labeled text entities in the same cluster to generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label. Encode the text to be annotated to obtain the word vector corresponding to each word segment in the text; For each word vector, the similarity between the word vector and the multiple prototype label vectors is determined to obtain multiple similarity values; If the maximum similarity among the multiple similarities is greater than or equal to a preset threshold, then the entity type label is added to the word fragment corresponding to the word vector; The step of encoding the labeled text entities in the same cluster to generate corresponding prototype label vectors results in multiple prototype label vectors corresponding to the entity type labels, including: Obtain a pre-trained label vector encoding model; wherein the label vector encoding model is obtained through a model training step; Each labeled text entity in each cluster is input into the label vector encoding model, and the corresponding prototype label vector is output to obtain multiple prototype label vectors corresponding to the entity type label. In the model training step, obtaining sample data includes: Obtain the raw data; Based on the entity name of the text entity in the original data, find the entity node that matches the entity name from the open-source knowledge graph; If only one entity node is found, then according to the entity type corresponding to the unique entity node, an entity type label is added to the corresponding text entity in the original data to obtain the labeled sample data. If multiple entity nodes are found, the text entities in the original data are removed.
2. The method according to claim 1, characterized in that, The model training steps include: Obtain sample data; the sample data includes sample text and sample entity type labels of sample entities in the sample text; In each round of iterative training, for each sample entity type label, sample entities carrying the sample entity type label are selected from the sample data to obtain the corresponding support set; The sample entities in the support set are input into the label vector encoding model to be trained, and multiple prototype label vectors corresponding to the type label of the sample entity are predicted. The sample text containing the sample entity is vectorized to obtain the target vector; From the multiple predicted prototype label vectors, select the prototype label vector that is closest to the target vector; Adjust the model parameters in the direction that makes the closest prototype label vector close to the target vector, and continue iterative training until the iteration stopping condition is met to obtain the final label vector encoding model.
3. The method according to claim 1, characterized in that, The step of searching for entity nodes matching the entity names of text entities in the original data from the open-source knowledge graph includes: From the open-source knowledge graph, find the triples corresponding to the text entities in the original data; From the triples, determine the entity node that matches the entity name of the text entity.
4. The method according to claim 1, characterized in that, The original data includes the original page and hyperlinks within the original page; the step of searching for entity nodes matching the entity names of text entities in the original data from the open-source knowledge graph includes: Based on the entity name of the text entity in the original page, search for matching entity nodes from the open-source knowledge graph; The step of adding entity type labels to the corresponding text entities in the original data based on the unique entity type corresponding to the entity node to obtain labeled sample data includes: Based on the entity type corresponding to the unique entity node, add entity type tags to the corresponding text entities in the original page; Identify the corresponding hyperlink entity in the page to which the hyperlink is connected, and add the corresponding entity type tag to the hyperlink entity in the page to which it is connected, to obtain the labeled sample data.
5. The method according to claim 1, characterized in that, The process of clustering the labeled text entities yields multiple clusters, including: The labeled text entities are pre-clustered according to a preset number of candidate cluster centers to obtain multiple pre-clustering results; Analyze multiple pre-clustering results to obtain clustering analysis index values; Based on the clustering analysis index values, select the target number of cluster centers from the multiple candidate cluster center numbers; Based on the number of target cluster centers, the labeled text entities are clustered to obtain multiple clusters.
6. A physical excavation device, characterized in that, The device includes: The acquisition module is used to acquire labeled text entities that are labeled with the same entity type. The clustering module is used to cluster the labeled text entities to obtain multiple clusters; The encoding module is used to encode the labeled text entities in the same cluster respectively, generate corresponding prototype label vectors, and obtain multiple prototype label vectors corresponding to the entity type label; and to encode the text to be labeled to obtain the word vector corresponding to each word fragment in the text to be labeled. The annotation module is used to determine the similarity between each word vector and the plurality of prototype label vectors to obtain multiple similarities; if the maximum similarity among the plurality of similarities is greater than or equal to a preset threshold, then the entity type label is added to the word segment corresponding to the word vector; The encoding module is also used to obtain a pre-trained label vector encoding model; wherein the label vector encoding model is obtained through a model training step; the labeled text entities in each cluster are respectively input into the label vector encoding model, and the corresponding prototype label vectors are output to obtain multiple prototype label vectors corresponding to the entity type label; The training module is used to perform the model training steps. The training module is also used to acquire raw data; search for entity nodes matching the entity names of text entities in the raw data from an open-source knowledge graph; if only one entity node is found, add an entity type label to the corresponding text entity in the raw data according to the entity type corresponding to the unique entity node to obtain labeled sample data; if multiple entity nodes are found, remove the text entities from the raw data.
7. The apparatus according to claim 6, characterized in that, The training module is further configured to acquire sample data, which includes sample text and sample entity type labels for sample entities within the sample text. In each iteration of training, for each sample entity type label, sample entities carrying the sample entity type label are selected from the sample data to obtain a corresponding support set. The sample entities in the support set are input into the label vector encoding model to be trained to predict multiple prototype label vectors corresponding to the sample entity type label. The sample text containing the sample entity is vectorized to obtain a target vector. From the predicted multiple prototype label vectors, the prototype label vector closest to the target vector is selected. The model parameters are adjusted in the direction that makes the closest prototype label vector close to the target vector, and iterative training continues until the iteration stopping condition is met to obtain the final label vector encoding model.
8. The apparatus according to claim 6, characterized in that, The training module is also used to search for triples corresponding to text entities in the original data from the open-source knowledge graph; and to determine entity nodes that match the entity name of the text entity from the triples.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Text label determination method and device
CN106611052A
Text classification method and device based on target semantics, equipment and storage medium
CN113486670A