Knowledge graph construction method and device based on entity chain finger and storage medium
Through the combination of the target large language model and graph neural network, the problem of poor accuracy in knowledge graph construction in the existing technology is solved, the accurate identification and fusion of entities and relationships is achieved, and the adaptability of knowledge graphs is expanded.
Patent Information
- Application Number
- CN202510490338.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-18
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-18
AI Technical Summary
In the prior art, the extracted entities and relationships and the ontology model chain of the knowledge graph are highly subjective, resulting in poor accuracy in building knowledge graphs.
The fine-tuned target large language model is used to obtain candidate entities and relationships from text data, and the graph neural network is used to verify the rationality of entities and relationships, and the entity chain finger and relationship chain finger processing is used through the graph neural network, expanding the entities and relationships of unsuccessful chain fingers, and building a knowledge graph.
It improves the accuracy and adaptability of knowledge graph construction, ensures the accuracy of identification and extraction of entities and relationships, and realizes the effective integration and expansion of knowledge graphs and ontology models.
Smart Images

Figure CN120409640A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of knowledge graphs, and particularly to a method, device, and storage medium for constructing a knowledge graph based on entity linking. Background Art
[0002] In the fields of modern artificial intelligence and big data, as a structured semantic network, the knowledge graph has become an important support for applications such as information processing, intelligent search, and question answering systems. It represents and stores real-world knowledge in the form of nodes (entities) and edges (relationships), thereby achieving efficient storage, query, and reasoning of complex information. However, constructing an accurate knowledge graph still faces a series of technical challenges. Building a knowledge graph not only requires extracting entities and relationships, but also involves linking the extracted entities and relationships to the knowledge graph ontology model. In particular, the process of linking the extracted entities and relationships to the knowledge graph ontology model is crucial for accurately constructing the knowledge graph.
[0003] Currently, the commonly used method for linking the extracted entities and relationships to the knowledge graph ontology model is: based on manual review, establishing a mapping relationship between the extracted entities and relationships and the knowledge graph ontology model, and finally, based on the mapping relationship, completing the linking of entities and relationships. However, in this method, establishing the mapping relationship through manual review has strong subjectivity, resulting in large linking deviations and poor accuracy of the finally constructed knowledge graph. Summary of the Invention
[0004] To improve the accuracy of knowledge graph construction, this application provides a method, device, storage medium, and electronic device for constructing a knowledge graph based on entity linking.
[0005] In the first aspect of this application, a method for constructing a knowledge graph based on entity linking is provided, specifically including: Obtaining at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model, and constructing a knowledge graph ontology model corresponding to the text data to be analyzed; Performing relationship extraction on each of the candidate entities to obtain at least one target relationship, determining the candidate entities corresponding to the target relationship as target entities, and aggregating them into an entity combination; Performing rationality verification on each target entity and the corresponding target relationship in the entity combination. After the rationality verification passes, based on a preset graph neural network, performing entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and performing relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model to obtain a linked knowledge graph ontology model; Based on the target entity and target relationship of the unsuccessful linking, expand the knowledge graph ontology model after the linking to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0006] By adopting the above technical solution, through the target large language model, candidate entities and target relationships are more accurately identified from the text data to be analyzed. Then, the target relationships between the identified target entities are verified, so as to ensure the accuracy of the identified entities and the extracted relationships to a certain extent, and further lay a foundation for constructing an accurate knowledge graph subsequently. Further, based on the graph neural network, entity linking and relationship linking can be better carried out for the target entity and the target relationship respectively, so that the target entity and the target relationship can be better integrated with the knowledge graph ontology model. At the same time, based on the target entity and target relationship of the unsuccessful linking, the entity categories and relationship types of the knowledge graph ontology model after the linking are expanded, so as to better adapt to new knowledge, and further make the finally constructed knowledge graph more accurate.
[0007] Optionally, the rationality verification of each target entity and the corresponding target relationship in the entity combination specifically includes: Obtain the historical entities related to a single target entity in the constructed knowledge graph of the historical text data, count the first occurrence times of each historical entity, and select the first number of historical entities from each historical entity in descending order of the first occurrence times to be determined as key entities. The historical text data is text data in the same field as the text data to be analyzed; Obtain the historical relationships in which a single key entity and the corresponding target entity have occurred, count the second occurrence times of each historical relationship, and select the second number of historical relationships from each historical relationship in descending order of the second occurrence times to be determined as the key relationships corresponding to a single key entity; Determine the first weight of each key entity and the second weight of the key relationship corresponding to each key entity. The first weight is the ratio of the first occurrence times of each key entity to the sum of the first occurrence times of all key entities, and the second weight is the ratio of the second occurrence times of a single key relationship corresponding to the key entity to the sum of the second occurrence times of all corresponding key relationships; According to the first weight and the second weight, perform rationality verification on each target entity and the corresponding target relationship in the entity combination.
[0008] By adopting the above technical solution, the larger the first occurrence frequency is, the easier it is for the corresponding historical entity to have a relationship with the target entity in the text data to be analyzed, and then the key entity can be determined; the larger the second occurrence frequency is, the easier it is for a single key entity to have a corresponding historical relationship with the target entity, and then the key relationship can be determined. Finally, by combining the first weight and the second weight, analyze the specific situation of the relationship between the target entities in the entity combination, and then more accurately perform a rationality check on each target entity and the corresponding target relationship.
[0009] Optionally, the rationality check on each target entity and the corresponding target relationship in the entity combination according to the first weight and the second weight specifically includes: Obtain at least one other candidate entity and the corresponding other relationship that have a relationship with a single target entity in the entity combination; When the other candidate entity is a key entity, determine the corresponding other candidate entity as a reference entity, and when the other relationship corresponding to the reference entity is a key relationship, determine the other relationship corresponding to the reference entity as a reference relationship; If the reference relationship exists among the key relationships corresponding to the reference entity, calculate the first product of the first weight of the reference entity and the second weight of the corresponding reference relationship; Sum up each of the first products to obtain the sum of the first products of the corresponding target entity, and select the largest sum of the first products from the sums of the first products of each target entity in the entity combination; If the largest sum of the first products is greater than a preset first threshold, determine the target entity corresponding to the largest sum of the first products as the first entity, determine the remaining target entities as the second entities, and determine that the rationality check on the first entity passes; Based on the first entity, perform a rationality check on the second entity and perform a rationality check on the target relationship between the first entity and the second entity.
[0010] By adopting the above technical solution, the larger the sum of the first products is, the higher the overall rationality of the entity relationship between this target entity and other candidate entities is, indicating that the accuracy of identifying the target entity itself is higher. When the largest sum of the first products is greater than the preset first threshold, it indicates that the accuracy of identifying the corresponding target entity is relatively high. Then, determine the target entity corresponding to this largest sum of the first products as the first entity and determine that the rationality check on the first entity passes. Finally, with the first entity as a reference, more accurately perform a rationality check on the second entity and perform a rationality check on the target relationship between the first entity and the second entity.
[0011] Optionally, performing a rationality check on the second entity based on the first entity, and performing a rationality check on the target relationship between the first entity and the second entity, specifically including: Determine the target relationship between the first entity and the second entity as the relationship to be checked. When the relationship to be checked exists in each key relationship corresponding to a single key entity that is likely to have a relationship with the first entity, determine the corresponding key entity as the entity to be analyzed; Calculate the second product of the first weight of each entity to be analyzed and the second weight of the corresponding relationship to be checked, and select the largest second product from each of the second products; When the largest second product is greater than a preset second threshold, determine the entity to be analyzed corresponding to the largest second product as the reference entity. If the second entity is the reference entity, determine that the rationality check on the second entity and the relationship to be checked passes.
[0012] By adopting the above technical solution, the larger the second product, the greater the possibility that the entity to be analyzed has a relationship with the first entity and the relationship is the relationship to be checked. If the largest second product is greater than the preset second threshold, it indicates that the possibility of the corresponding entity to be analyzed having a relationship to be checked with the first entity is relatively large. Then, determine the corresponding entity to be analyzed as the reference entity. If the second entity is the reference entity, determine that the rationality check on the second entity and the relationship to be checked passes, thereby performing a more accurate rationality check.
[0013] Optionally, the method further includes: When the largest second product is not greater than the preset second threshold, if the second entity is a key entity corresponding to the first entity, calculate the third product of the first weight of the second entity and the second weights of the corresponding key relationships; Sum up each of the third products to obtain the sum of the second products. If the sum of the second products is greater than a preset third threshold, determine that the rationality check on the second entity passes; Select the largest third product from each of the third products, and replace the relationship to be checked with the key relationship corresponding to the largest third product.
[0014] By adopting the above technical solution, if the largest second product is not greater than the second threshold, it indicates that the possibility of other candidate entities having a relationship to be checked with the first entity is relatively small, and the relationship to be checked between the first entity and the second entity may be incorrect and needs further verification. Further, if the sum of the second products exceeds the third threshold, it indicates that the possibility of the second entity having an association with the first entity is relatively large. The second entity is not misidentified, but the relationship to be checked between the two is incorrect. Then, determine that the rationality check on the second entity passes.
[0015] Optionally, performing entity linking processing on each of the target entities and the entity categories in the knowledge graph ontology model based on a preset graph neural network specifically includes: Determining a first embedding vector corresponding to a single target entity and determining second embedding vectors for each entity category in the knowledge graph ontology model; Optimizing the first embedding vector through a preset graph neural network to obtain a first optimized vector, and optimizing the second embedding vector through the graph neural network to obtain a second optimized vector; Calculating the similarity between the first optimized vector and each of the second optimized vectors, and selecting the maximum similarity from each of the similarities; If the maximum similarity exceeds a preset similarity threshold, performing entity linking processing on the entity category corresponding to the maximum similarity and the single target entity.
[0016] By adopting the above technical solution, the first embedding vector and the second embedding vector are optimized through a graph neural network, so that the first optimized vector can more comprehensively and accurately represent the target entity, and the second optimized vector can more comprehensively and accurately represent the entity category. Further, if the maximum similarity exceeds the preset similarity threshold, it indicates that the single target entity and the corresponding entity category are relatively well matched. Then, performing entity linking processing on the entity category corresponding to the maximum similarity and the target entity, thereby facilitating the subsequent construction of a more accurate knowledge graph.
[0017] Optionally, expanding the entity-linked knowledge graph ontology model based on the un-successfully linked target entities and target relationships to obtain the final knowledge graph corresponding to the text data to be analyzed, specifically including: Determining the un-successfully linked target entities as new entities, and performing clustering analysis on all new entities to obtain at least one entity classification set; Adding the new entity closest to the corresponding clustering center in a single entity classification set to the entity-linked knowledge graph ontology model to obtain an expanded ontology model; Determining the un-successfully linked target relationships as new relationships, and performing clustering analysis on all new relationships to obtain at least one relationship classification set; Adding the new relationship closest to the corresponding clustering center in a single relationship classification set to the expanded ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0018] By adopting the above technical solution, if the target entity and the target relationship cannot be successfully linked, it indicates that the target entity does not match any entity categories in the knowledge graph ontology model, and the target relationship does not match any relationship types in the knowledge graph ontology model. The target entity and the target relationship are determined as new entities and new relationships, respectively, and there are corresponding new entity categories and relationship types. Then, the new entity closest to the corresponding cluster center in the entity classification set and the new relationship closest to the corresponding cluster center in the relationship classification set are added to the knowledge graph ontology model respectively, so as to realize the expansion of new entity categories and relationship types in the knowledge graph ontology model, and further enable the final knowledge graph ontology model to adapt to new knowledge.
[0019] In the second aspect of the present application, a knowledge graph construction device based on entity linking is provided, which specifically includes: An information acquisition module, configured to obtain at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model, and construct a knowledge graph ontology model corresponding to the text data to be analyzed; A relationship extraction module, configured to extract relationships for each of the candidate entities to obtain at least one target relationship, determine the candidate entity corresponding to the target relationship as a target entity, and summarize them into an entity combination; A linking processing module, configured to perform a rationality check on each target entity and the corresponding target relationship in the entity combination. After the rationality check passes, based on a preset graph neural network, perform entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and perform relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model, to obtain a linked knowledge graph ontology model; A graph construction module, configured to expand the linked knowledge graph ontology model based on the target entity and the target relationship that cannot be successfully linked, to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0020] By adopting the above technical solution, the information acquisition module obtains candidate entities from the text data to be analyzed and constructs a knowledge graph ontology model. Then, the relationship extraction module extracts at least one target relationship, determines the candidate entity corresponding to the target relationship as a target entity, and summarizes them into an entity combination. Next, after the rationality check passes, the linking processing module performs entity linking processing and relationship linking processing to obtain a linked knowledge graph ontology model. Finally, the graph construction module expands the linked knowledge graph ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0021] In a third aspect of the present application, a computer-readable storage medium is provided. A computer program is stored in the computer-readable storage medium. When the computer program is loaded and executed by a processor, the method steps described in any one of the first aspect are executed.
[0022] In a fourth aspect of the present application, an electronic device is provided, specifically including: A processor, a memory, and a computer program stored in the memory and capable of running on the processor. The processor is used to load and execute the computer program stored in the memory, so that the electronic device executes the method described in any one of the first aspect.
[0023] In summary, the present application includes at least one of the following beneficial technical effects: Through the target large language model, candidate entities are more accurately identified from the text data to be analyzed, and the target relationships are extracted. Then, the target relationships between the identified target entities are verified, thereby ensuring the accuracy of the identified entities and the extracted relationships to a certain extent, and further laying a foundation for constructing an accurate knowledge graph subsequently. Further, based on the graph neural network, entity linking and relationship linking can be better performed for the target entities and target relationships respectively, so that the target entities and target relationships can be better integrated with the knowledge graph ontology model. At the same time, based on the target entities and target relationships that have not been successfully linked, the entity categories and relationship types of the knowledge graph ontology model after linking are extended, so as to better adapt to new knowledge, and further make the finally constructed knowledge graph more accurate. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 is a schematic flowchart of a method for constructing a knowledge graph based on entity linking provided by an embodiment of the present application; Figure 2 is a schematic structural diagram of a device for constructing a knowledge graph based on entity linking provided by an embodiment of the present application; Figure 3 is a schematic structural diagram of another device for constructing a knowledge graph based on entity linking provided by an embodiment of the present application.
[0025] Description of the reference numerals: 11, information acquisition module; 12, relationship extraction module; 13, linking processing module; 14, graph construction module; 15, reasonable verification module. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0026] In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the accompanying drawings in the embodiments of this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments.
[0027] In the description of the embodiments of this application, words such as "exemplarily", "for example", or "for illustration" are used to give examples, illustrations, or explanations. Any embodiment or design solution described as "exemplarily", "for example", or "for illustration" in the embodiments of this application should not be construed as being more preferred or having more advantages than other embodiments or design solutions. Rather, the use of words such as "exemplarily", "for example", or "for illustration" is intended to present relevant concepts in a specific manner.
[0028] In the description of the embodiments of this application, the term "and / or" is merely a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, B exists alone, and both A and B exist simultaneously. In addition, unless otherwise specified, the meaning of the term "plural" refers to two or more. For example, multiple systems refer to two or more systems, and multiple screen terminals refer to two or more screen terminals. Furthermore, the terms "first" and "second" are only used for descriptive purposes and cannot be construed as indicating or implying relative importance or implicitly indicating the technical features indicated. Thus, the features defined with "first" and "second" may explicitly or implicitly include one or more of such features. The terms "include", "comprise", "have" and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0029] See Figure 1 , the embodiments of this application disclose a flowchart of a method for constructing a knowledge graph based on entity linking, which can be implemented depending on a computer program or run on an entity-linking-based knowledge graph construction device based on the von Neumann architecture. This computer program can be integrated into an application or run as an independent tool-type application, and specifically includes: S101: Obtain at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model, and construct a knowledge graph ontology model corresponding to the text data to be analyzed; Specifically, a large language model (LLM) refers to a deep learning model trained with a large amount of text data, enabling the model to generate natural language text or understand the meaning of language text. In the embodiments of the present application, the target large language model can adopt Qwen 2.5. In other embodiments, the target large language model can also adopt Llama 3. The text data to be analyzed is the text data for which a knowledge graph needs to be constructed specifically. Exemplarily, the text data to be analyzed can be text data such as news reports and research papers related to a single field, such as the medical field. Further, an entity refers to an object in the real world, such as a person, a place, etc. In knowledge graph construction, named entity recognition (NER) is a key step, which involves automatically identifying named entities from text data. Candidate entities are entities identified from the text data to be analyzed. The knowledge graph ontology model is a structured model for describing and organizing domain knowledge, including elements such as entity categories, relationship types, attributes, etc. Among them, the entity category is a set of categories for classifying entities, used to describe entities with similar attributes or features. The relationship type is a combination of types for classifying relationships between entities, used to describe the association relationships between entities.
[0030] It should be noted that the fine-tuning process of the target large language model is briefly described as follows: taking the text data sample, the names of the entities included in the text data sample, and the relationships between different entities as training samples, and inputting them into the target large language model for fine-tuning training. During the process, the cross-entropy loss function is used for parameter tuning until the model converges. This is the prior art and will not be elaborated here. The fine-tuned target large language model can automatically identify entities and extract the relationships between entities from the text data to be analyzed. Among them, the relationship between entities is to describe various semantic connections between different entities. Exemplarily, if the two entities are "place" and "event" respectively, then the relationship between the two entities is "occur at".
[0031] Further, through the fine-tuned target large language model, at least one candidate entity is identified from the text data to be analyzed. In addition, a feasible way to construct a knowledge graph ontology model is: based on the preset Neo4j tool, construct the knowledge graph ontology model based on the Schema mode. Among them, Schema is a structured framework for defining and describing entities, attributes, relationships, and how they are related to each other. It stipulates the basic constituent elements of the knowledge graph and their organization methods, providing a basis for constructing and applying the knowledge graph.
[0032] S102: Extract relationships for each candidate entity to obtain at least one target relationship, determine the candidate entities corresponding to the target relationship as target entities, and summarize them into an entity combination.
[0033] Specifically, after the candidate entities are determined, the target large language model after fine-tuning is used to extract the relationships between the pairwise candidate entities from the text data to be analyzed, obtaining at least one target relationship. Finally, the two candidate entities corresponding to a single target relationship are determined as target entities, and each target entity is aggregated into an entity combination.
[0034] S103: Perform a rationality check on each target entity and the corresponding target relationship in a single entity combination. After the rationality check passes, based on a preset graph neural network, perform entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and perform relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model, obtaining the linked knowledge graph ontology model.
[0035] Specifically, after the candidate entity recognition and the extraction of the target relationships between the candidate entities, it is necessary to check the rationality of the entity recognition and the rationality of the extracted target relationships, so as to improve the accuracy of entity recognition and relationship extraction, and further make the subsequently constructed knowledge graph more accurate. Further, perform a rationality check on each target entity and the corresponding target relationship in a single entity combination. A feasible check method is as follows: Obtain the historical entities in the already constructed knowledge graph of the historical text data that have a relationship with a single target entity in the entity combination. Among them, the historical text data is in the same field as the text data to be analyzed. Exemplarily, the historical text data and the text data to be analyzed can both be text data related to the medical field. Then, count the first occurrence times of each historical entity. The larger the first occurrence times, the more likely the corresponding historical entity is to have a relationship with the target entity in the text data to be analyzed. Select the first number of historical entities from each historical entity in descending order of the first occurrence times and determine them as key entities, that is, the entities that are likely to have a relationship with the target entity in the text data to be analyzed. Among them, the first occurrence times are the occurrence frequencies of the same historical entity among all historical entities.
[0036] Further, obtain the historical relationships in which a single key entity and the target entity have appeared, and count the second occurrence times of each historical relationship. The larger the second occurrence times, the more likely the single key entity and the target entity are to have the corresponding historical relationship. Select the second number of historical relationships from each historical relationship in descending order of the second occurrence times and determine them as the key relationships corresponding to the key entity, that is, the entity relationships that the key entity and the target entity are likely to have. Among them, the second occurrence times are the occurrence frequencies of the same historical relationship among all historical relationships.
[0037] Determine the first weight of each key entity and determine the second weight of the key relationship corresponding to each key entity, where the first weight is the ratio of the first occurrence times of each key entity to the sum of the first occurrence times of all key entities, and the second weight is the ratio of the second occurrence times of a single key relationship corresponding to the key entity to the sum of the second occurrence times of all corresponding key relationships. Finally, according to the first weight and the second weight, perform a rationality check on each target entity and the corresponding target relationship in a single entity combination. One achievable implementation method is as follows: Based on the various target relationships that have been extracted, screen out at least one other candidate entity and the corresponding other relationship that have a relationship with a single target entity in the entity combination from each candidate entity. Then, when the other candidate entity is a key entity, determine this other candidate entity as the reference entity, and when the other relationship corresponding to the reference entity, that is, the relationship between the reference entity and the single target entity, is a key relationship, determine this other relationship as the reference relationship. Further, if the above reference relationship exists among the various key relationships corresponding to the reference entity, then calculate the first product of the first weight of the reference entity and the second weight of the corresponding reference relationship. The larger the first product, the greater the possibility that the relationship between the target entity and the reference entity is the reference relationship, and the more reasonable the entity relationship is. Then, sum the first products corresponding to each reference entity that has a relationship with the target entity to obtain the sum of the first products corresponding to this target entity. The larger the sum of the first products, the higher the overall rationality of the entity relationship between this target entity and the other candidate entities, indicating the higher the accuracy of the recognition of the target entity itself.
[0038] Select the largest sum of the first products from the sums of the first products corresponding to each target entity in a single entity combination. If the largest sum of the first products is greater than a preset first threshold, it indicates that the recognition accuracy of the corresponding target entity is relatively high. Then, determine the target entity corresponding to this largest sum of the first products as the first entity and determine that the rationality check for the first entity passes. At the same time, determine the target entities other than the first entity in the entity combination as the second entities. Then, based on the first entity, perform a rationality check on the second entities and perform a rationality check on the target relationship between the first entity and the second entities. One achievable implementation method is as follows: Determine the target relationship between the first entity and the second entity as the relationship to be verified. For the first entity, when the relationship to be verified exists among the key relationships corresponding to a single key entity with which it is likely to have a relationship, determine the corresponding key entity as the entity to be analyzed. Calculate the second product of the first weight of each entity to be analyzed and the second weight of the corresponding relationship to be verified. The larger the second product, the greater the likelihood that the entity to be analyzed has a relationship with the first entity and the relationship is the relationship to be verified. Select the largest second product from all the second products. If the largest second product is greater than the preset second threshold, it indicates that the corresponding entity to be analyzed has a relatively high likelihood of having a relationship to be verified with the first entity. Then, determine the corresponding entity to be analyzed as the control entity. If the second entity is the control entity, determine that the rationality verification of the second entity and the relationship to be verified passes. If the second entity is not the control entity, it indicates that the second entity is likely to be misidentified. When none of the other target relationships corresponding to the first entity are the relationships to be verified, replace the second entity with this control entity.
[0039] In other embodiments, if the largest second product is not greater than the second threshold, it indicates that the likelihood of other candidate entities having a relationship to be verified with the first entity is relatively small, and the relationship to be verified between the first entity and the second entity may be incorrect and needs further verification. Then, when the second entity is a key entity corresponding to the first entity, calculate the third product of the first weight of the second entity and the second weights of the corresponding key relationships. The larger the third product, the greater the likelihood that there is a corresponding key relationship between the first entity and the second entity. Sum up all the third products to obtain the sum of the second products. Then, compare the sum of the second products with the preset third threshold. If the sum of the second products exceeds the third threshold, it indicates that the likelihood of a relationship between the second entity and the first entity is relatively large, and there is no misidentification problem with the second entity, but the relationship to be verified between the two is incorrect. Then, determine that the rationality verification of the second entity passes. Further, select the largest third product from all the third products. The key relationship corresponding to the largest third product is the most likely relationship between the first entity and the second entity. Then, replace the relationship to be verified with the key relationship corresponding to the largest third product.
[0040] Further, after the rationality verification passes, it is necessary to link each target entity to the entity category in the knowledge graph ontology model, so that the candidate entities identified from the text data to be analyzed can be accurately mapped to the knowledge graph ontology model and effectively integrated with the knowledge graph ontology model. Among them, entity linking is to identify multiple entities mentioned in different data sources that point to the same real-world object and associate them with the same node in the knowledge graph, so as to ensure the consistency and accuracy of the knowledge graph. Exemplarily, the entity is xxx Hospital, and the entity category for linking is the hospital category.
[0041] Further, a feasible way to perform entity linking is as follows: Determine the first embedding vector corresponding to a single target entity through a pre-set large language model, and determine the second embedding vectors of each entity category in the knowledge graph ontology model. Among them, an embedding vector is a method of converting text or an entity into a numerical representation that can be understood by a computer. Then, optimize the first embedding vector through a pre-set Graph Neural Networks (GNNs) to obtain a first optimized vector. Then optimize the second embedding vector to obtain a second optimized vector. Among them, a graph neural network is a neural network model that uses the topological structure of a graph for information transmission and update. In the embodiments of the present application, optimizing the embedding vector through a graph neural network is specifically to aggregate the information of neighbor nodes and integrate it into the embedding vector, so that the embedding vector can more comprehensively and accurately represent the entity.
[0042] Further, calculate the similarity between the first optimized vector and the second optimized vector, which can be specifically implemented through cosine similarity. In other embodiments, it can also be implemented by calculating the Euclidean distance. The greater the similarity, the more the single target entity matches the corresponding entity category in the knowledge graph ontology model, and the more suitable it is for linking. Then, select the maximum similarity from each similarity. If the maximum similarity exceeds the pre-set similarity threshold, it means that the single target entity is relatively well-matched with the corresponding entity category, then perform entity linking processing on the entity category corresponding to the maximum similarity and the target entity. On the contrary, if the maximum similarity does not exceed the similarity threshold, it means that the single target entity does not match the corresponding entity category and cannot be linked.
[0043] Further, the method for performing relationship linking is relatively similar to that of entity linking. It is also to determine the embedding vector corresponding to a single target relationship and the embedding vectors of each relationship type in the knowledge graph ontology model, and then optimize the embedding vector through a graph neural network to obtain an optimized vector, and then calculate the similarity between the optimized vector of the target relationship and the optimized vectors of each relationship type, and select the maximum similarity. If the maximum similarity exceeds the similarity threshold, it means that the target relationship is relatively well-matched with the corresponding relationship type, then perform targeted relationship linking processing. Finally, after the entity linking processing and the relationship linking processing are completed, the linked knowledge graph ontology model is obtained.
[0044] S104: Based on the target entities and target relationships that have not been successfully linked, expand the linked knowledge graph ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0045] Specifically, after the knowledge graph ontology model after entity linking is determined, target entities that do not match any entity categories in the knowledge graph ontology model and target relationships that do not match any relationship types in the knowledge graph ontology model are obtained, that is, the target entities and target relationships that have not been successfully linked. Further, the target entities that have not been successfully linked are determined as new entities, and all new entities are subjected to clustering analysis through a preset clustering algorithm. Similar new entities are grouped into the same group to obtain at least one entity classification set. Among them, the clustering algorithm uses K-means or hierarchical clustering. Then, the clustering center (cluster center) corresponding to a single entity classification set is determined through the clustering algorithm, and the distance between each new entity in the single entity classification set and the corresponding clustering center is calculated. The new entity with the smallest distance from the clustering center is added to the knowledge graph ontology model after entity linking to obtain an extended ontology model, thereby realizing the extension of new entity categories in the knowledge graph ontology model after entity linking, and further enabling the knowledge graph ontology model after entity linking to adapt to new knowledge. Among them, calculating the distance between a new entity and the clustering center is specifically calculating the Euclidean distance between the new entity and the clustering center.
[0046] Further, the target relationships that have not been successfully linked are determined as new relationships, and all new relationships are subjected to clustering analysis to obtain at least one relationship classification set. Then, the clustering center (cluster center) corresponding to a single relationship classification set is determined, and the distance between each new relationship in the single relationship classification set and the corresponding clustering center is calculated. The new relationship with the smallest distance from the clustering center is added to the extended ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed. Among them, calculating the distance between a new relationship and the clustering center is specifically calculating the Euclidean distance between the new relationship and the clustering center.
[0047] The implementation principle of a knowledge graph construction method based on entity linking in an embodiment of this application is as follows: Through the target large language model, candidate entities are accurately identified from the text data to be analyzed and target relationships are extracted. Then, the target relationships between the identified target entities are verified, thereby ensuring the accuracy of the identified entities and the extracted relationships to a certain extent, and further laying a foundation for constructing an accurate knowledge graph subsequently. Further, based on the graph neural network, entity linking and relationship linking can be better performed for the target entities and target relationships respectively, so that the target entities and target relationships can be better integrated with the knowledge graph ontology model. At the same time, based on the target entities and target relationships that have not been successfully linked, the entity categories and relationship types of the knowledge graph ontology model after entity linking are extended, so as to better adapt to new knowledge, and further make the finally constructed knowledge graph more accurate.
[0048] The following is an embodiment of the device of the present application, which can be used to execute the method embodiment of the present application. For details not disclosed in the device embodiment of the present application, please refer to the method embodiment of the present application.
[0049] Please refer to Figure 2 , which is a schematic structural diagram of a knowledge graph construction device based on entity linking provided by an embodiment of the present application. The device applied to the knowledge graph construction device based on entity linking can be implemented as all or part of the device through software, hardware, or a combination of both. The device includes an information acquisition module 11, a relationship extraction module 12, a linking processing module 13, and a graph construction module 14.
[0050] The information acquisition module 11 is configured to obtain at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model, and construct a knowledge graph ontology model corresponding to the text data to be analyzed; The relationship extraction module 12 is configured to extract relationships for each candidate entity to obtain at least one target relationship, determine the candidate entities corresponding to the target relationship as target entities, and summarize them into an entity combination; The linking processing module 13 is configured to perform a rationality check on each target entity and the corresponding target relationship in the entity combination. After the rationality check passes, based on a preset graph neural network, perform entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and perform relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model to obtain a linked knowledge graph ontology model; The graph construction module 14 is configured to expand the linked knowledge graph ontology model based on the target entities and target relationships that have not been successfully linked to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0051] Optionally, the linking processing module 13 is specifically configured to: Obtain historical entities in the constructed knowledge graph of historical text data that have a relationship with a single target entity in the entity combination, count the first occurrence times of each historical entity, and select the first number of historical entities from each historical entity in descending order of the first occurrence times to determine key entities. The historical text data is text data in the same field as the text data to be analyzed; Obtain the historical relationships in which a single key entity and the corresponding target entity have occurred, count the second occurrence times of each historical relationship, and select the second number of historical relationships from each historical relationship in descending order of the second occurrence times to determine the key relationships corresponding to the single key entity; Determine the first weight of each key entity, and determine the second weight of the key relationship corresponding to each key entity. The first weight is the ratio of the first occurrence times of each key entity to the sum of the first occurrence times of all key entities, and the second weight is the ratio of the second occurrence times of a single key relationship corresponding to the key entity to the sum of the second occurrence times of all corresponding key relationships; Perform a rationality check on each target entity and the corresponding target relationship in the entity combination according to the first weight and the second weight.
[0052] Optionally, the chain finger processing module 13 is specifically configured to: Obtain at least one other candidate entity and the corresponding other relationship that have a relationship with a single target entity in the entity combination; When the other candidate entity is a key entity, determine the corresponding other candidate entity as a reference entity, and when the other relationship corresponding to the reference entity is a key relationship, determine the other relationship corresponding to the reference entity as a reference relationship; If there is a reference relationship among the key relationships corresponding to the reference entity, calculate the first product of the first weight of the reference entity and the second weight of the corresponding reference relationship; Sum up the first products to obtain the sum of the first products of the corresponding target entity, and select the largest sum of the first products from the sums of the first products of each target entity in the entity combination; If the largest sum of the first products is greater than the preset first threshold, determine the target entity corresponding to the largest sum of the first products as the first entity, determine the remaining target entities as the second entities, and determine that the rationality check for the first entity passes; Based on the first entity, perform a rationality check on the second entity and perform a rationality check on the target relationship between the first entity and the second entity.
[0053] Optionally, the chain finger processing module 13 is specifically configured to: Determine the target relationship between the first entity and the second entity as the relationship to be checked. When there is a relationship to be checked among the key relationships corresponding to a single key entity that is likely to have a relationship with the first entity, determine the corresponding key entity as the entity to be analyzed; Calculate the second product of the first weight of each entity to be analyzed and the second weight of the corresponding relationship to be checked, and select the largest second product from the second products; When the largest second product is greater than the preset second threshold, determine the entity to be analyzed corresponding to the largest second product as the control entity. If the second entity is the control entity, determine that the rationality check for the second entity and the relationship to be checked passes.
[0054] Optionally, as Figure 3 shown, the device further includes a rationality check module 15, which is specifically configured to: When the maximum second product is not greater than a preset second threshold, if the second entity is a key entity corresponding to the first entity, calculate the third product of the first weight of the second entity and the second weights of the corresponding key relationships; Sum up the third products to obtain the sum of the second products. If the sum of the second products is greater than a preset third threshold, it is determined that the rationality check of the second entity passes; Select the maximum third product from the third products, and replace the relationship to be checked with the key relationship corresponding to the maximum third product.
[0055] Optionally, the chain processing module 13 is specifically used for: Determine the first embedding vector corresponding to a single target entity, and determine the second embedding vectors of each entity category in the knowledge graph ontology model; Optimize the first embedding vector through a preset graph neural network to obtain a first optimized vector, and optimize the second embedding vector through the graph neural network to obtain a second optimized vector; Calculate the similarity between the first optimized vector and each second optimized vector, and select the maximum similarity from the similarities; If the maximum similarity exceeds a preset similarity threshold, perform entity chaining processing on the entity category corresponding to the maximum similarity and the single target entity.
[0056] Optionally, the graph construction module 14 is specifically used for: Determine the target entities that have not been successfully chained as new entities, and perform clustering analysis on all new entities to obtain at least one entity classification set; Add the new entity closest to the corresponding cluster center in a single entity classification set to the knowledge graph ontology model after chaining to obtain an extended ontology model; Determine the target relationships that have not been successfully chained as new relationships, and perform clustering analysis on all new relationships to obtain at least one relationship classification set; Add the new relationship closest to the corresponding cluster center in a single relationship classification set to the extended ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
[0057] It should be noted that when the knowledge graph construction device based on entity linking provided in the above embodiments executes the knowledge graph construction method based on entity linking, only the division of the above functional modules is used for illustration. In practical applications, the above functions can be allocated to different functional modules according to needs, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the knowledge graph construction device based on entity linking and the method embodiment of the knowledge graph construction method based on entity linking provided in the above embodiments belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.
[0058] An embodiment of the present application also discloses a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, a knowledge graph construction method based on entity linking in the above embodiments is implemented.
[0059] Among them, the computer program can be stored in a computer-readable medium. The computer program includes computer program code. The computer program code can be in the form of source code, object code, executable file or some middleware form, etc. The computer-readable medium includes any entity or device, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium that can carry the computer program code. It should be noted that the computer-readable medium includes, but is not limited to, the above components.
[0060] Among them, through this computer-readable storage medium, a knowledge graph construction method based on entity linking in the above embodiments is stored in the computer-readable storage medium and is loaded and executed on a processor to facilitate the storage and application of the above method.
[0061] An embodiment of the present application also discloses an electronic device. A computer program is stored in the computer-readable storage medium. When the computer program is loaded and executed by a processor, a knowledge graph construction method based on entity linking in the above embodiments is implemented.
[0062] Among them, the electronic device can be a desktop computer, a laptop computer or a cloud server and the like. The electronic device includes, but is not limited to, a processor and a memory. For example, the electronic device can also include input / output devices, network access devices and a bus, etc.
[0063] Among them, the processor may adopt a central processing unit (CPU). Of course, according to the actual usage situation, other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. may also be adopted. The general-purpose processor may adopt a microprocessor or any conventional processor, etc. The present application does not make any restrictions in this regard.
[0064] Among them, the memory may be an internal storage unit of the electronic device. For example, the hard disk or memory of the electronic device, or it may also be an external storage device of the electronic device. For example, a plug-in hard disk, a smart media card (SMC), a secure digital card (SD), or a flash memory card (FC), etc., equipped on the electronic device. And the memory may also be a combination of the internal storage unit and the external storage device of the electronic device. The memory is used to store computer programs and other programs and data required by the electronic device. The memory may also be used to temporarily store the data that has been output or will be output. The present application does not make any restrictions in this regard.
[0065] Among them, through this electronic device, a method for constructing a knowledge graph based on entity linking in the above embodiment is stored in the memory of the electronic device, and is loaded and executed on the processor of the electronic device for convenient use.
[0066] The above are only exemplary embodiments of the present disclosure and should not be used to limit the scope of the present disclosure. That is, any equivalent changes and modifications made according to the teachings of the present disclosure still fall within the scope covered by the present disclosure. The present application aims to cover any variations, uses or adaptations of the present disclosure, and these variations, uses or adaptations follow the general principles of the present disclosure and include common general knowledge or conventional technical means in the technical field not recorded in the present disclosure. The description and the embodiments are only regarded as exemplary, and the scope and spirit of the present disclosure are defined by the claims.
Claims
1. A method for constructing a knowledge graph based on entity linking, characterized in that, The method includes: Obtaining at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model, and constructing a knowledge graph ontology model corresponding to the text data to be analyzed; Performing relationship extraction on each of the candidate entities to obtain at least one target relationship, determining the candidate entities corresponding to the target relationship as target entities and aggregating them into an entity combination; Performing rationality verification on each target entity and the corresponding target relationship in the entity combination. After the rationality verification passes, based on a preset graph neural network, performing entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and performing relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model to obtain a linked knowledge graph ontology model; Based on the target entities and target relationships that have not been successfully linked, expanding the linked knowledge graph ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
2. The method for constructing a knowledge graph based on entity linking according to claim 1, wherein The performing rationality verification on each target entity and the corresponding target relationship in the entity combination specifically includes: Obtaining historical entities in the constructed knowledge graph of historical text data that have a relationship with a single target entity in the entity combination, counting the first occurrence times of each historical entity, and selecting the first number of historical entities from each historical entity in descending order of the first occurrence times as key entities. The historical text data is text data in the same field as the text data to be analyzed; Obtaining the historical relationships in which a single key entity and the corresponding target entity have occurred, counting the second occurrence times of each historical relationship, and selecting the second number of historical relationships from each historical relationship in descending order of the second occurrence times as the key relationships corresponding to a single key entity; Determining the first weight of each key entity and the second weight of the key relationship corresponding to each key entity. The first weight is the ratio of the first occurrence times of each key entity to the sum of the first occurrence times of all key entities, and the second weight is the ratio of the second occurrence times of a single key relationship corresponding to a key entity to the sum of the second occurrence times of all corresponding key relationships; Performing rationality verification on each target entity and the corresponding target relationship in the entity combination according to the first weight and the second weight.
3. The method for constructing a knowledge graph based on entity linking according to claim 2, wherein The performing rationality verification on each target entity and the corresponding target relationship in the entity combination according to the first weight and the second weight specifically includes: Obtaining at least one other candidate entity and the corresponding other relationship that have a relationship with a single target entity in the entity combination; When the other candidate entity is a key entity, determining the corresponding other candidate entity as a reference entity, and when the other relationship corresponding to the reference entity is a key relationship, determining the other relationship corresponding to the reference entity as a reference relationship; If the reference relationship exists in each key relationship corresponding to the reference entity, calculate the first product of the first weight of the reference entity and the second weight of the corresponding reference relationship; Sum up each of the first products to obtain the sum of the first products of the corresponding target entity, and select the maximum sum of the first products from the sums of the first products of each target entity in the entity combination; If the maximum sum of the first products is greater than a preset first threshold, determine the target entity corresponding to the maximum sum of the first products as the first entity, determine the remaining target entities as the second entities, and determine that the rationality check for the first entity passes; Based on the first entity, perform a rationality check on the second entity and perform a rationality check on the target relationship between the first entity and the second entity.
4. The method for constructing a knowledge graph based on entity linking according to claim 3, wherein The performing a rationality check on the second entity based on the first entity and performing a rationality check on the target relationship between the first entity and the second entity specifically includes: Determine the target relationship between the first entity and the second entity as the relationship to be checked. When the relationship to be checked exists in each key relationship corresponding to a single key entity that is likely to have a relationship with the first entity, determine the corresponding key entity as the entity to be analyzed; Calculate the second product of the first weight of each entity to be analyzed and the second weight of the corresponding relationship to be checked, and select the maximum second product from each of the second products; When the maximum second product is greater than a preset second threshold, determine the entity to be analyzed corresponding to the maximum second product as the control entity. If the second entity is the control entity, determine that the rationality check for the second entity and the relationship to be checked passes.
5. The method for constructing a knowledge graph based on entity linking according to claim 4, characterized in that The method further includes: When the maximum second product is not greater than a preset second threshold, if the second entity is a key entity corresponding to the first entity, calculate the third product of the first weight of the second entity and the second weights of the corresponding key relationships; Sum up each of the third products to obtain the sum of the second products. If the sum of the second products is greater than a preset third threshold, determine that the rationality check for the second entity passes; Select the maximum third product from each of the third products, and replace the relationship to be checked with the key relationship corresponding to the maximum third product.
6. The method for constructing a knowledge graph based on entity linking according to claim 1, wherein The performing entity linking processing on each of the target entities and the entity categories in the knowledge graph ontology model based on a preset graph neural network specifically includes: Determine the first embedding vector corresponding to a single target entity and determine the second embedding vectors of each entity category in the knowledge graph ontology model; Optimize the first embedding vector through a preset graph neural network to obtain a first optimized vector, and optimize the second embedding vectors through the graph neural network to obtain second optimized vectors; Calculate the similarity between the first optimized vector and each of the second optimized vectors, and select the maximum similarity from each of the similarities; If the maximum similarity exceeds a preset similarity threshold, perform entity linking processing on the entity category corresponding to the maximum similarity and a single target entity.
7. The method for constructing a knowledge graph based on entity linking according to claim 1, wherein Based on the target entities and target relationships indicated by the unsuccessful linking, expand the knowledge graph ontology model after the linking to obtain the final knowledge graph corresponding to the text data to be analyzed, specifically including: Determine the target entities with unsuccessful linking as new entities, and perform clustering analysis on all new entities to obtain at least one entity classification set; Add the new entity closest to the corresponding clustering center in a single entity classification set to the knowledge graph ontology model after the linking to obtain an expanded ontology model; Determine the target relationships with unsuccessful linking as new relationships, and perform clustering analysis on all new relationships to obtain at least one relationship classification set; Add the new relationship closest to the corresponding clustering center in a single relationship classification set to the expanded ontology model to obtain the final knowledge graph corresponding to the text data to be analyzed.
8. A knowledge graph construction device based on entity linking, characterized in that, Including: An information acquisition module (11) for obtaining at least one candidate entity from the text data to be analyzed through a fine-tuned target large language model and constructing a knowledge graph ontology model corresponding to the text data to be analyzed; A relationship extraction module (12) for extracting relationships from each of the candidate entities to obtain at least one target relationship, determining the candidate entities corresponding to the target relationship as target entities and summarizing them into an entity combination; A linking processing module (13) for performing a rationality check on each target entity and the corresponding target relationship in the entity combination, and after the rationality check passes, based on a preset graph neural network, performing entity linking processing on each target entity and the entity categories in the knowledge graph ontology model, and performing relationship linking processing on each target relationship and the relationship types in the knowledge graph ontology model to obtain a knowledge graph ontology model after the linking; A graph construction module (14) for expanding the knowledge graph ontology model after the linking based on the target entities and target relationships with unsuccessful linking to obtain the final knowledge graph corresponding to the text data to be analyzed.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is loaded and executed by a processor, the method described in any one of claims 1-7 is implemented.
10. An electronic device, comprising a memory, a processor, and a computer program stored in the memory and capable of running on the processor, characterized in that, When the processor loads and executes the computer program, the method described in any one of claims 1-7 is implemented.
Citation Information
Patent Citations
Knowledge graph construction method and device for security entity, equipment and medium
CN112256889A
Entity linking method for natural language text and medical knowledge graph
CN113821597A
Heterogeneous information network representation learning method
CN117828107A
Visual development system for knowledge graph
CN118093895A
Intelligent verification method and system for electric power work ticket content
CN119202680A