Method, device, equipment, storage medium and program product for constructing knowledge graph
By segmenting the target text, identifying entities, and disambiguating, and retrieving associated semantic blocks and subgraphs, the problem of inaccurate traditional knowledge graph construction is solved, resulting in a more accurate knowledge graph and reducing the waste of hardware resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-08
- Publication Date
- 2026-03-27
AI Technical Summary
Traditional knowledge graph construction methods cannot effectively integrate information scattered throughout the text, resulting in inaccurate knowledge graphs.
By segmenting the target text, performing entity recognition and disambiguation, retrieving semantic blocks and subgraphs that are related to the final entity, and fusing them, a target knowledge graph is constructed.
A target knowledge graph containing more comprehensive information was generated, which improved the accuracy of large language models in reasoning tasks and avoided the waste of hardware resources.
Smart Images

Figure CN121480669B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of artificial intelligence, and in particular to a method and device for constructing a knowledge graph, an electronic device, a storage medium and a program product. BACKGROUND
[0002] In today's era of digital information explosion, as a powerful knowledge representation and management tool, knowledge graph has important significance for improving information processing and intelligent application capabilities. With the rise of Retrieval-Augmented Generation (RAG) technology based on knowledge graph, the role of knowledge graph in enhancing the reasoning ability of Large Language Model is becoming more and more significant.
[0003] However, traditional knowledge graph construction methods have exposed many problems in practical application. In the current knowledge graph construction process, only the entity relationship within a semantic block is generally focused on, and the information scattered throughout the text cannot be effectively integrated, resulting in inaccurate constructed knowledge graph. SUMMARY
[0004] The present application provides a method and device for constructing a knowledge graph, an electronic device, a storage medium and a program product to solve the problem of inaccurate knowledge graph constructed by related technologies.
[0005] The present application provides a method for constructing a knowledge graph, comprising:
[0006] obtaining a target text and an initial knowledge graph;
[0007] After performing a blocking operation on the target text, at least one semantic block is obtained;
[0008] performing an entity recognition operation on each of the at least one semantic block to obtain a plurality of pre-entities;
[0009] performing disambiguation processing on the plurality of pre-entities to obtain at least one final entity;
[0010] According to the at least one semantic block and the target final entity, a final associated semantic block having an associated relationship with the target final entity is searched in the at least one semantic block, wherein the target final entity is any one of the at least one final entity;
[0011] According to the initial knowledge graph and the target final entity, a target subgraph corresponding to the target final entity is determined;
[0012] fusing the final associated semantic block corresponding to each of the at least one final entity and the target subgraph to obtain a target knowledge graph.
[0013] The application further provides a device for constructing a knowledge graph, comprising:
[0014] an acquisition module, configured to acquire a target text and an initial knowledge graph;
[0015] a block division module, configured to obtain at least one semantic block by performing a block division operation on the target text;
[0016] a recognition module, configured to obtain a plurality of pre-entities by performing an entity recognition operation on the at least one semantic block respectively;
[0017] a disambiguation module, configured to obtain at least one final entity by performing a disambiguation operation on the plurality of pre-entities;
[0018] a retrieval module, configured to retrieve a final associated semantic block having an association relationship with a target final entity from the at least one semantic block according to the at least one semantic block and the target final entity, wherein the target final entity is any one of the at least one final entity;
[0019] a determination module, configured to determine a target subgraph corresponding to the target final entity according to the initial knowledge graph and the target final entity;
[0020] a fusion module, configured to fuse the final associated semantic block and the target subgraph corresponding to the at least one final entity respectively to obtain a target knowledge graph.
[0021] The application further provides an electronic device, comprising a memory configured to store a computer program and a processor configured to execute the computer program to implement the steps of any one of the above methods for constructing a knowledge graph.
[0022] The application further provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps of any one of the above methods for constructing a knowledge graph.
[0023] The application further provides a computer program product, comprising a computer program, and the computer program is executed by a processor to implement the steps of any one of the above methods for constructing a knowledge graph.
[0024] With the present application, first, the target text and the initial knowledge graph are acquired. Then, the target text can be divided into at least one semantic block. For any semantic block, an entity recognition operation can be performed, so that a plurality of pre-entities can be obtained. In order to ensure the uniqueness of the entity, the plurality of pre-entities can be disambiguated to obtain at least one final entity. Further, in order to ensure the comprehensiveness and accuracy of the knowledge graph, the present scheme can retrieve a final associated semantic block associated with the final entity in the semantic block, and extract a target subgraph associated with the final entity from the initial knowledge graph. Finally, the final associated semantic block corresponding to the final entity and the target subgraph are fused. Since the final associated semantic block used in the fusion process not only contains the semantic block where the final entity originally exists, but also includes the semantic block where the entity associated with it exists, similarly, the target subgraph used includes the target subgraph associated with it, therefore, after completing the fusion operation, a target knowledge graph containing more comprehensive information can be obtained, that is, the target knowledge graph constructed by the present scheme is more accurate. In this way, the large language model can make the reasoning result more accurate in the process of performing the reasoning task using the target knowledge graph, and thus can avoid the problem of waste of hardware resources such as computing resources and storage resources caused by the need for multiple reasoning due to inaccurate reasoning results. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the embodiments of the present application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0026] Figure 1 A flowchart of a method for constructing a knowledge graph provided by an embodiment of the present application;
[0027] Figure 2 An architecture diagram of a service platform provided by an embodiment of the present application;
[0028] Figure 3 A flowchart of another method for constructing a knowledge graph provided by an embodiment of the present application;
[0029] Figure 4 A flowchart of a device for constructing a knowledge graph provided by an embodiment of the present application;
[0030] Figure 5 A structural diagram of an electronic device provided by an embodiment of the present application. DETAILED DESCRIPTION
[0031] With reference to the drawings, the technical solutions in the embodiments of the present application will be clearly and completely described below. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work fall within the protection scope of the present application.
[0032] It should be noted that in the description of the present application, the terms "comprise", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment comprising a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. The terms "first", "second" and the like in the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence.
[0033] In order for those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the drawings and specific embodiments.
[0034] The professional terms involved in the present application are explained below.
[0035] Semantic block: a text unit with relatively complete and independent semantics, which carries specific information content, usually revolves around a core theme or concept, and can be used as a basic unit for knowledge extraction and information retrieval. For example, a semantic block can be a complete sentence, "The core component of an electric vehicle is the battery system, which directly affects the vehicle's range."
[0036] Entity: in a specific technical field, an instance of a thing, object, concept or object that can be uniquely identified and has independent existence. For example, in the field of automobile technology, "electric vehicle" and "battery system" in the aforementioned semantic block example can be called entities. Pre-entity refers to an entity directly extracted from a semantic block, indicating that the entity has not undergone disambiguation. Disambiguation refers to merging multiple entities that express different ways but indicate the same object in essence into one entity. The final entity represents the entity after disambiguation.
[0037] Large language model (LLM): a deep learning-based artificial intelligence model that learns the statistical rules and semantic knowledge of language by pre-training on large-scale text data, so as to understand, generate, reason and manipulate natural language. "Large" refers to the large size of the model's parameters (usually has tens of billions to hundreds of billions of trainable parameters), large training data, and large computing scale.
[0038] Knowledge Graph (KG): A semantic network used to represent and store real-world knowledge, which describes entities, concepts, their attributes, and their relationships in the objective world in a structured form (usually a graph structure). The core components of a knowledge graph generally include nodes and edges, where nodes correspond to entities and edges correspond to relationships between two entities.
[0039] Embodiments of the present application provide a method for constructing a knowledge graph, which can be executed by a service platform (e.g., including one or more servers), as shown in Figure 1 The specific processing steps of the method for constructing a knowledge graph can include:
[0040] Step S101, obtaining a target text and an initial knowledge graph.
[0041] The target text can be a text in a specific technical field, or a text in a general technical field. For example, the specific technical field can be the electric vehicle technology field, the artificial intelligence technology field, etc. The general technical field can be a combination of multiple specific technical fields.
[0042] Specifically, the service platform can first obtain the target text and the initial knowledge graph, so that the initial knowledge graph can be updated based on the target text in the subsequent process, improving the comprehensiveness and professionalism of the knowledge graph.
[0043] Step S102, after performing a blocking operation on the target text, obtaining at least one semantic block.
[0044] Specifically, the service platform can input the target text into the pre-obtained blocking model to obtain at least one semantic block output by the blocking model. The blocking model can be the above-mentioned large language model. Correspondingly, the service platform can also input relevant prompt information, which can be "considering the logical connection words and semantic coherence between sentences when performing blocking". In this way, the semantic blocks output by the blocking model can better preserve the semantic integrity. For example, for the sentence combination "because of global climate change, the sea level rises.", under such a blocking manner, it can be ensured that the two sentences are not split when blocking.
[0045] Step S103, performing an entity recognition operation on each of the at least one semantic block to obtain a plurality of pre-entities.
[0046] Specifically, the service platform can use the Named Entity Recognition (NER) technology to perform an entity recognition operation on each semantic block of the target text, and determine the recognized entities as pre-entities.
[0047] In step S104, after the disambiguation processing on the plurality of pre-entities, at least one final entity is obtained.
[0048] Specifically, for the same pre-entity, since the pre-entity can exist in the plurality of semantic blocks of the target text, or different pre-entities exist in different semantic blocks to indicate the same object, the service platform can perform disambiguation processing on the plurality of determined pre-entities, so as to combine the same pre-entities and combine the pre-entities indicating the same object, and obtain at least one final entity. In this way, the at least one final entity can indicate different objects respectively, so that in the subsequent process, the problem of resource waste caused by processing repeated entities is avoided, and the accuracy of the target knowledge graph is ensured.
[0049] In step S105, according to the at least one semantic block and the target final entity, a final associated semantic block associated with the target final entity is searched in the at least one semantic block.
[0050] The target final entity is any one of the at least one final entity.
[0051] Specifically, for any final entity, the final entity can be involved in different positions of the target text, that is, the final entity is included in different semantic blocks. And the semantic blocks involving the final entity respectively contain information of different aspects of the final entity. Therefore, the service platform can compare the final entity with each semantic block respectively, and select a final associated semantic block associated with the final entity from them. Taking the target final entity as an example, the service platform can compare the target final entity with each semantic block respectively, determine whether each semantic block contains information associated with the target final entity, if yes, the corresponding semantic block is determined as a final associated semantic block associated with the target final entity, and if not, it is determined that the corresponding semantic block is not associated with the target final entity.
[0052] In step S106, according to the initial knowledge graph and the target final entity, a target subgraph corresponding to the target final entity is determined.
[0053] Specifically, the initial knowledge graph includes a plurality of subgraphs. Correspondingly, the service platform can compare each subgraph and the target final entity respectively, determine whether each subgraph is associated with the target final entity, if yes, the corresponding subgraph is determined as a target subgraph corresponding to the target final entity, and is extracted, and if not, it is determined that the corresponding subgraph is not associated with the target final entity, and does not need to be extracted.
[0054] In step S107, the final associated semantic block corresponding to each of the at least one final entity and the target subgraph are fused to obtain the target knowledge graph.
[0055] Specifically, since the final associated semantic block contains various information associated with the final entity, and the target subgraph also contains various information associated with the final entity, the final associated semantic block corresponding to each of the at least one final entity and the target subgraph can be fused to obtain the target knowledge graph, so that the target knowledge graph can add new information contained in the target text, and the target knowledge graph is more accurate.
[0056] The method for constructing a knowledge graph according to the embodiments of the present application first acquires a target text and an initial knowledge graph. Then, the target text can be divided into at least one semantic block. For any semantic block, an entity recognition operation can be performed, so that a plurality of pre-entities can be obtained. In order to ensure the uniqueness of the entity, the plurality of pre-entities can be disambiguated to obtain at least one final entity. Furthermore, in order to ensure the comprehensiveness and accuracy of the knowledge graph, the present scheme can search for a final associated semantic block having an association relationship with the final entity in the semantic block, and extract a target subgraph having an association relationship with the final entity from the initial knowledge graph. Finally, the final associated semantic block corresponding to the final entity and the target subgraph are fused. Since the final associated semantic block used in the fusion process not only contains the semantic block where the final entity originally exists, but also includes the semantic block where the entity having an association exists, similarly, the target subgraph used includes the target subgraph having an association, therefore, after the fusion operation is completed, a target knowledge graph containing more comprehensive information can be obtained, that is, the target knowledge graph constructed by the present scheme is more accurate. In this way, in the process of using the target knowledge graph to perform a reasoning task, the large language model can make the reasoning result more accurate, and thus can avoid the problem of waste of hardware resources such as computing resources and storage resources caused by the need for multiple reasoning due to inaccurate reasoning results.
[0057] For example, semantic block 1 is "A company was founded by B", semantic block 2 is "the company is headquartered in C", and semantic block 3 is "D took over A company in 2025". According to the processing of the related art, only the relationship "A company-founder-B" can be obtained, but according to the processing of the present scheme, "A company" and "the company" can be disambiguated as one entity, and semantic blocks 1, 2, and 3 can be determined as the final associated semantic block corresponding to "A company" in the text. In addition, in combination with "A company-product-computer" extracted from the initial knowledge graph, a complete relationship set including "founder", "headquarters location", "current manager", "product", and the like can be generated, and a knowledge target subgraph centered on "A company" can be accurately constructed.
[0058] In some optional embodiments, the service platform can further perform the following specific steps:
[0059] Step one, identify the target technical field to which the target text belongs.
[0060] Step two, according to the target technical field, obtain the training data set corresponding to the target technical field.
[0061] Step three, using the training data set, train the pre-obtained initial vector model to obtain the target vector model.
[0062] Among them, the target technical field can be the specific technical field or the general technical field mentioned above. The target vector model can be used for vector conversion operation on the pre-entity and the semantic block. For example, the target vector model can be "BGE-M3 model".
[0063] Specifically, the service platform can identify the target technical field to which the target text belongs through the large language model, and then according to the target technical field, extract the training data set matching the target technical field from the pre-constructed database, and then use the training data set to train the pre-obtained initial vector model to obtain the target vector model.
[0064] In this way, in order to adapt to the characteristics of the specific field document, fine-tuning the model can make the vector conversion more accurate, and then make the subsequent operation of finding the associated node and the associated semantic block more efficient and accurate, and finally improve the accuracy of the generated target knowledge graph. For example, in the legal document, a large number of legal provisions, case analysis and other texts are added in the training data, so that the model learns the specific terminology, semantics and logical relationships in the legal field, so as to more accurately vectorize the legal semantic block.
[0065] In some optional embodiments, in the above step S104, the service platform can perform the disambiguation processing of the pre-entity by using the following specific steps:
[0066] Step one, using the target vector model, performing vector conversion operation on the plurality of pre-entities respectively to obtain the vectors corresponding to the plurality of pre-entities respectively.
[0067] Step two, according to the first vector corresponding to the first pre-entity and the second vector corresponding to the second pre-entity, determining the similarity between the first pre-entity and the second pre-entity.
[0068] Step three, in the case where the similarity between the first pre-entity and any one of the other pre-entities is less than or equal to the preset similarity threshold, the first pre-entity is determined as the final entity.
[0069] Alternatively, in a case where it is determined that the similarity between the first pre-entity and one or more of the other pre-entities is greater than the preset similarity threshold, the one or more pre-entities and the first pre-entity are divided into a candidate entity group.
[0070] Step five, inputting the candidate entity group into the pre-obtained entity merging model to obtain a merging result output by the entity merging model.
[0071] The first pre-entity can be any one of the plurality of pre-entities, and the second pre-entity can be any one of the other pre-entities except the first pre-entity. The merging result can include one or more final entities. The entity merging model can be a large language model.
[0072] Specifically, for any pre-entity, the service platform can input the pre-entity into the target vector model, and obtain a vector corresponding to the pre-entity output by the target vector model after the pre-entity is vectorized by the target vector model.
[0073] For each two pre-entities, the service platform can calculate the corresponding similarity. Taking the first pre-entity and the second pre-entity as an example, the service platform can calculate the cos value of the included angle between the first vector and the second vector, and determine the value as the similarity between the first pre-entity and the second pre-entity.
[0074] For each pre-entity, the service platform can calculate the similarity between the pre-entity and other pre-entities. If the similarity between all the other pre-entities and the pre-entity is less than the preset similarity threshold, it means that there is no other pre-entity indicating the same object as the pre-entity, and the pre-entity can be directly determined as a final entity and added to the final entity set.
[0075] If there is one or more pre-entities with a similarity greater than the preset similarity threshold, the one or more pre-entities and the pre-entity can be divided into a candidate entity group. For each candidate entity group, the service platform can input all the pre-entities included in the candidate entity group into the entity merging model, and determine whether these pre-entities indicate the same object by the entity merging model. If yes, these pre-entities can be merged into a final entity. The merging operation can be to retain one of the pre-entities (which can be randomly selected, or the pre-entity with the highest frequency of occurrence in the target text, etc.) and eliminate the other pre-entities. For example, “electric vehicle”, “electric car” and “electric vehicle” can be merged into “electric car”. If not, these pre-entities can be determined as final entities respectively and added to the final entity set.
[0076] In this way, by two-step disambiguation, the uniqueness of the final entity can be more accurately ensured, and in the subsequent retrieval process based on the final entity, more accurate associated information (i.e., the final associated semantic block and the associated node, etc.) can be determined, and in the fusion process, a more accurate target knowledge graph can be constructed based on the associated information.
[0077] In some optional embodiments, the above-mentioned preset similarity threshold can be obtained according to a target technical field, and accordingly, the service platform can obtain the preset similarity threshold corresponding to the target technical field according to the target technical field. The preset similarity threshold corresponding to a professional technical field is less than the preset similarity threshold corresponding to a general technical field. In this way, for the text of the professional technical field with more professional terms and smaller entity expression differences, the threshold can be appropriately reduced (for example, 0.8), so as to avoid missing similar entities, and for the text of the general technical field, a higher threshold (for example, 0.85) can be maintained, so as to improve the screening efficiency.
[0078] In some optional embodiments, for the candidate entity group performing the merging operation, after obtaining the merging result, the source sub-block identification information of each pre-entity included in the candidate entity group can be extracted, and the final entity obtained by merging can be labeled according to the extracted source sub-block identification information of each pre-entity, so as to effectively reduce the entity reference ambiguity problem and improve the entity accuracy.
[0079] In some optional embodiments, in the above-mentioned step S105, the service platform can use the following specific steps to retrieve the final associated semantic block:
[0080] Step one, using a target vector model, performing vector conversion operation on at least one semantic block respectively to obtain vectors corresponding to the at least one semantic block respectively.
[0081] Step two, determining the similarity between the target final entity and the target semantic block according to the vector corresponding to the target final entity and the vector corresponding to the target semantic block.
[0082] Step three, determining at least one candidate semantic block from the at least one semantic block according to the similarity between the target final entity and the at least one semantic block.
[0083] Step four, selecting the final associated semantic block having an association relationship with the target final entity from the at least one candidate semantic block according to the target final entity and the at least one candidate semantic block.
[0084] Among them, the target final entity can be any one of the at least one final entity, and the target semantic block can be any one of the plurality of semantic blocks.
[0085] Specifically, for any semantic block, the service platform can input the semantic block into the target vector model, and obtain a vector corresponding to the semantic block output by the target vector model after the semantic block is vectorized by the target vector model.
[0086] The dimensions of the vector of the entity and the vector of the semantic block can be the same, and accordingly, in step two, the service platform can calculate the cos value of the included angle between the vector of the target final entity and the vector of the target semantic block, and determine the value as the similarity between the target final entity and the target semantic block.
[0087] In step three, the service platform can select a semantic block with a higher similarity to the target final entity from the semantic blocks as a candidate semantic block. For example, the service platform can sort at least one semantic block according to the similarity between the target final entity and the at least one semantic block from high to low to obtain a sorting value corresponding to each of the at least one semantic block. The semantic blocks before the first preset sorting value (for example, which can be 5) are determined as candidate semantic blocks. Alternatively, the semantic blocks with a similarity to the target final entity greater than a first similarity threshold are determined as candidate semantic blocks.
[0088] In step four, since the candidate semantic blocks are not necessarily semantic blocks that have a real association relationship with the target final semantic block, the service platform can further compare the target final entity with each candidate semantic block to determine the final associated semantic block that has a real association relationship.
[0089] In this way, candidate semantic blocks are selected based on similarity first, and the final associated semantic block is selected by performing an analysis operation, so that the data amount of the analysis operation is less, and resource occupation can be reduced.
[0090] In some optional embodiments, before step four of step S105, the service platform can further perform the following specific steps:
[0091] According to at least one semantic block, a target final entity, and a pre-built topic model, a semantic block consistent with the topic of the target final entity is determined in the at least one semantic block. The semantic block consistent with the topic of the target final entity is determined as a candidate semantic block.
[0092] Specifically, the service platform can input the target final entity into a pre-built topic model, identify the topic of the target final entity by the topic model, and output the topic of the target final entity. For example, the topic model can be “BERTopic”. In addition, for each semantic block, the service platform can also input the semantic block into the pre-built topic model, identify the topic of the semantic block by the topic model, and output the topic of the semantic block. Alternatively, the service platform can also only perform topic identification for semantic blocks whose similarity to the target final entity is less than or equal to the first similarity threshold. Finally, the service platform can determine the semantic block whose topic is consistent with the target final entity as a candidate semantic block.
[0093] In this way, for semantic blocks with low similarity, candidate semantic blocks can also be included to obtain more comprehensive context information, and a more comprehensive target knowledge graph can be generated in the subsequent fusion process.
[0094] In some optional embodiments, in step four of step S105, the service platform can specifically select a final associated semantic block associated with the target final entity by using the following specific steps:
[0095] Step 1: According to the target final entity, identify the number of occurrences and the position of the target final entity in the target candidate semantic block.
[0096] Step 2: Obtain the association closeness between the target final entity and the target candidate semantic block.
[0097] Step 3: According to the number of occurrences and the position of the target final entity in at least one candidate semantic block, and the association closeness corresponding to each of the at least one candidate semantic block, select a final associated semantic block associated with the target final entity from the at least one candidate semantic block.
[0098] Wherein, the position can be a title, a beginning of a paragraph, a beginning of a sentence, a middle of a sentence, an end of a sentence, etc. The target candidate semantic block can be any one of the at least one candidate semantic block.
[0099] Specifically, taking the target candidate semantic block as an example, the service platform can identify the number of occurrences of the target final entity in the target candidate semantic block, and the position of each occurrence in the target candidate semantic block according to the target final entity.
[0100] The service platform can directly determine the similarity between the target final entity and the target candidate semantic block as the association closeness between the target final entity and the target candidate semantic block. Alternatively, the target final entity and the target candidate semantic block can also be input into a large language model, and the association closeness between the target final entity and the target candidate semantic block can be output by the large language model.
[0101] After identifying the number of occurrences and the positions of the target final entity in each candidate semantic block, and the closeness between the target final entity and each candidate semantic block, the service platform can compare the target final entity and the candidate semantic blocks based on the three pieces of information, and select the final associated semantic block that actually has an association with the target final entity.
[0102] In some optional embodiments, in step 3 described above, the service platform can determine the importance indicator value according to the following specific steps, and select the final associated semantic block based on the importance indicator value:
[0103] Step a, determining the importance indicator value of the target candidate semantic block according to the number of occurrences and the positions of the target final entity in the target candidate semantic block, and the closeness between the target final entity and the target candidate semantic block.
[0104] Step b, selecting the final associated semantic block that has an association with the target final entity from the at least one candidate semantic block according to the importance indicator value of the at least one candidate semantic block.
[0105] Specifically, for each position of the target final entity in the target candidate semantic block, the service platform can obtain a sub-importance indicator value corresponding to the position according to the position (for example, 1 for a title, 0.8 for the beginning of a paragraph, 0.5 for the beginning of a sentence, 0.3 for the middle of a sentence, and 0.2 for the end of a sentence), and then the sub-importance indicator value of each determined position can be summed to obtain a first importance indicator value. Then, the importance indicator value of the target candidate semantic block can be calculated using the following expression: score=w1×freq+w2×pos_weight+w3×closeness, where score is the importance indicator value of the target candidate semantic block, freq is the number of occurrences, w1 is a first preset weight value corresponding to the number of occurrences, which can be 0.4, pos_weight can be the first importance indicator value, w2 is a second preset weight value corresponding to the position, which can be 0.3, closeness is the closeness, and w3 is a third preset weight value corresponding to the closeness, which can be 0.3.
[0106] The service platform can sort each candidate semantic block according to the importance indicator value of each candidate semantic block from high to low to obtain a ranking value of each candidate semantic block, and then select the candidate semantic block whose ranking value is before a third preset ranking value as the final associated semantic block that has an association with the target final entity. Alternatively, the candidate semantic block whose importance indicator value is greater than a preset importance threshold value can also be selected as the final associated semantic block.
[0107] In this way, by quantifying the importance, the final associated semantic block can be determined more accurately, and thus the target knowledge graph generated by using the final associated semantic block can be more accurate.
[0108] In some optional embodiments, in the step S106, the service platform can extract the target subgraph by using the following specific steps:
[0109] Step one, calculating the similarity between the target final entity and the plurality of nodes.
[0110] Step two, determining the similar nodes corresponding to the target final entity from the plurality of nodes according to the similarity between the target final entity and the plurality of nodes.
[0111] Step three, determining the neighbor nodes of the similar nodes from the plurality of nodes according to the at least one edge and the similar nodes.
[0112] Step four, determining the similar nodes and the neighbor nodes as the associated nodes having the association relationship with the target final entity.
[0113] Step five, extracting the edges corresponding to the associated nodes from the at least one edge according to the associated nodes.
[0114] The associated nodes and the corresponding edges constitute the target subgraph.
[0115] Specifically, in step one, the service platform can input each node included in the initial knowledge graph into the target vector model, and perform vectorization processing on each node by the target vector model to obtain the vector of each node. Then, for any node, the service platform can calculate the cos value of the included angle between the vector of the node and the vector of the target final entity, and determine the value as the similarity between the target final entity and the node.
[0116] In step two, the service platform can sort the plurality of nodes from high to low according to the similarity between the target final entity and the plurality of nodes to obtain the sorting values of the plurality of nodes. The nodes with the sorting values before the second preset sorting value are determined as the similar nodes corresponding to the target final entity. Alternatively, the service platform can determine the nodes having the similarity greater than the third similarity threshold value with the target final entity as the similar nodes corresponding to the target final entity.
[0117] In step three, for each similar node, the service platform can determine, according to the similar node, an edge corresponding to the similar node in the initial knowledge graph, and then determine, according to the edge, a neighbor node connected to the similar node, and determine all neighbor nodes and the similar node as association nodes having an association relationship with the target final entity, and extract the association nodes from the initial knowledge graph. The neighbor node can include an upstream node and / or a downstream node of the association node.
[0118] In step four, for each association node, the service platform can extract an edge corresponding to each association node from the initial knowledge graph, and perform a deduplication operation. In this way, the extracted edge and the association node jointly constitute a target subgraph corresponding to the target final entity.
[0119] For example, if a node and a relationship related to "new battery technology" are to be retrieved, not only the vector-similar battery technology node is retrieved, but also nodes in upstream and downstream technology association positions in the graph, such as battery material research and development, battery application field, and related nodes and their relationships are retrieved.
[0120] In this way, more comprehensive related information in the knowledge graph can be obtained, and more rich knowledge support for the knowledge graph fusion process can be provided, and in the subsequent fusion process, a more comprehensive and accurate target knowledge graph can be generated in combination with the final association semantic block of the target final entity.
[0121] In some optional embodiments, in step S107 described above, the service platform can perform the fusion operation by using the following specific steps:
[0122] Step one, generating at least one relationship triple according to the final association semantic block corresponding to the target final entity and the target subgraph.
[0123] Step two, constructing a target knowledge graph according to the at least one relationship triple.
[0124] The relationship triple includes a head entity, a relationship, and a tail entity. The target subgraph can include association nodes and edges corresponding to the association nodes.
[0125] Specifically, the service platform can extract at least one relationship triple from the final association semantic block and at least one relationship triple from the target subgraph. Then, the service platform can perform a deduplication operation on all extracted relationship triples to obtain final relationship triples, and then construct a target knowledge graph according to the final relationship triples. For example, for two duplicate entities both representing "A company", one has the latest product release information in the final association semantic block, and the other has more detailed company history information in the initial graph, and the information of the two entities is integrated during fusion.
[0126] In some optional embodiments, before step two in step S107, the service platform can first perform an evaluation operation on the relationship triplets, and accordingly, the service platform can adopt the following specific steps:
[0127] inputting the target relationship triplet, the target text, and the initial knowledge graph into a pre-built evaluation model to obtain entity fidelity and relationship fidelity corresponding to the target relationship triplet output by the evaluation model; and determining whether to retain the target relationship triplet according to the entity fidelity and the relationship fidelity corresponding to the target relationship triplet, so as to construct the target knowledge graph according to the retained relationship triplets.
[0128] The target relationship triplet is any one of the at least one relationship triplet. The evaluation model can be a large language model. The entity fidelity is used to indicate whether the entity appears in the target text, and the relationship fidelity is used to indicate whether the relationship between the two entities can be inferred from the target text or the initial knowledge graph. The entity fidelity and the relationship fidelity can both take a first preset value (for example, 1) and a second preset value (for example, 0).
[0129] Specifically, the service platform can input the target relationship triplet, the target text, the initial knowledge graph, etc. into the evaluation model, and output the entity fidelity and the relationship fidelity of the target relationship triplet after the evaluation operation of the evaluation model. When it is determined that the entity fidelity and the relationship fidelity of the target relationship triplet are both the first preset value, the target relationship triplet can be retained, or when it is determined that the entity fidelity or the relationship fidelity of the target relationship triplet is the second preset value, the target relationship triplet can be removed.
[0130] For example, for the entity "mobile phone", not only is it confirmed that it exists in the target text, but also it is checked whether the brand, model, function, etc. of the mobile phone in the initial knowledge graph are consistent with the description of the target text. In the relationship fidelity evaluation, a logical reasoning verification link is introduced. For the generated relationship "because A leads to B", it is verified by the large language model based on logical rules and domain knowledge whether the cause-and-effect relationship is reasonable, so as to avoid generating relationships that do not conform to logic.
[0131] In this way, through the pre-evaluation operation, reasonable relationship triplets are retained, and conflicting relationships are removed, so that the target knowledge graph generated based on the reasonable relationship triplets is more accurate.
[0132] In some optional embodiments, after identifying the pre-entity, the service platform can further obtain the identification information of the semantic block to which the pre-entity belongs, and take the identification information as the source semantic block identification information of the pre-entity. Moreover, the service platform can extract the entity type and description information corresponding to the pre-entity from the pre-constructed database according to the pre-entity, and the description information can be the definition and role of the pre-entity. Then, the pre-entity is labeled based on the entity type, description information, and source semantic block identification information. In the process of vectorization, in addition to the name of the pre-entity, one or more elements in the entity type, description information, and source semantic block identification information can be combined to vectorize the pre-entity. For example, in the field of biology, for the pre-entity "gene", not only is it labeled as a "biological molecule" type, but also its role in biological processes such as genetic information transmission and protein synthesis is further labeled according to biological ontology knowledge, so that the information of the pre-entity is more rich and accurate.
[0133] The above method of constructing a knowledge graph is described below with a specific example. As shown in Figure 2 The service platform includes an input layer, a core layer, and an output layer. The input layer is used to obtain a target text and perform semantic blocking operation. The core layer is used to extract pre-entities, two-stage entity disambiguation, double-path (target text and initial knowledge graph) retrieval, and generate relationship triples. The output layer is used to evaluate the relationship triples and output the target knowledge graph. Accordingly, the processing flow can be as shown in Figure 3 The processing flow includes the following steps:
[0134] First, input the target text into the service platform as the basis for subsequent processing.
[0135] Second, perform semantic blocking on the target text to obtain semantic blocks.
[0136] Third, for each semantic block, use named entity recognition technology to identify and extract pre-entities, and label entity types, descriptions, and source block identifiers.
[0137] Fourth, convert the extracted pre-entities into vector form to facilitate subsequent similarity calculation and other operations.
[0138] Fifth, vector similarity preliminary screening: calculate the cosine similarity between pre-entity vectors, and set a preset similarity threshold. If the similarity is greater than the preset similarity threshold, the relevant pre-entities are classified into the candidate entity set. If the similarity is less than or equal to the preset similarity threshold, the final entity is identified, and the final entity is classified into the final entity set.
[0139] Sixth, for the candidate entity set, further judge whether these candidate entities refer to the same entity by means of a large language model, merge the expressions referring to the same entity, obtain the final entity, and add it to the final entity set.
[0140] Seventh, corpus backtracking retrieval, according to the entities in the final entity set, retrieve the final associated semantic block in the semantic block of the target text.
[0141] Eighth, graph structure retrieval, retrieve the subgraph corresponding to the final entity in the final entity set from the initial knowledge graph.
[0142] Ninth, fusion retrieval, integrate the final associated semantic block obtained by corpus backtracking retrieval and the subgraph obtained by graph structure retrieval.
[0143] Tenth, input the fused retrieval result into the large language model, and generate the relationship triple by the large language model.
[0144] Eleventh, use the large language model to verify the generated relationship triple, and evaluate the entity fidelity and relationship fidelity.
[0145] Twelfth, the relationship triple that passes the verification participates in the fusion process of the knowledge graph, and the triple that fails the verification is eliminated, and finally the optimized knowledge graph is output.
[0146] The target text contains the sentences "The core component of electric vehicles is the battery system, which directly affects the vehicle's range." and "At present, lithium-ion batteries have become the mainstream battery type for electric vehicles due to their high energy density and long cycle life." According to semantics and logic, the two sentences are divided into one semantic block respectively. Use the BGE-M3 model fine-tuned on electric vehicle domain data to convert the two semantic blocks into vectors and store them in the vector database.
[0147] Through named entity recognition technology, pre-entities such as "electric vehicle", "battery system", "lithium-ion battery" are extracted, and "electric vehicle" is labeled as "transportation tool" type, described as "electric power driven car", "battery system" is labeled as "automobile component" type, described as "system for providing power storage for electric vehicles", "lithium-ion battery" is labeled as "battery type", described as "a battery based on lithium-ion movement". In the disambiguation stage, due to the possible simultaneous occurrence of "electric car" and "electric vehicle" in the target text, through vector similarity calculation and large language model judgment, they are merged into the entity "electric vehicle".
[0148] For the entity of "lithium-ion battery", the corpus backtracking retrieval not only finds the semantic blocks containing the entity, but also retrieves other semantic blocks related to battery technology through the topic model, such as semantic blocks about battery charging speed, safety, etc. The graph structure retrieval finds nodes related to "lithium-ion battery" from the initial knowledge graph, such as battery material suppliers, battery recycling companies, etc. and their relationships. Input these retrieved information into the large language model to generate relationship triples such as "lithium-ion battery - applied to - electric vehicle" and "lithium-ion battery - provided by - battery material supplier".
[0149] The generated relationship triples are evaluated to verify the relationship "lithium-ion battery - applied to - electric vehicle" by checking the actual application description of lithium-ion battery in electric vehicles in the target text to confirm entity fidelity and relationship fidelity. When fused with the initial knowledge graph, if the initial knowledge graph already has the "lithium-ion battery" entity, but does not have the relationship about its application in electric vehicles, add the newly generated relationship. If there are duplicate but different information relationships, fuse them according to the accuracy and completeness of the information.
[0150] The method for constructing a knowledge graph of the embodiments of the present application can avoid the problem of semantic fragmentation caused by fixed-length blocking during semantic blocking, and improve the coherence of entity recognition and relationship extraction. Using pre-entities as intermediate carriers simplifies the entity disambiguation process and can be applied to long texts. Combining corpus backtracking retrieval and graph structure retrieval provides dual-source information for the fusion process, improving relationship generation accuracy. The large language model is used to judge the authenticity of entities and relationships, effectively filtering conflicting relationships, inaccurate relationships, etc. In addition, the present scheme can realize incremental updating of entities and relationships, and is suitable for dynamic document sets.
[0151] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and the necessary general hardware platform, of course, it can also be realized by hardware, but in many cases the former is a better embodiment.
[0152] The embodiments of the present application also provide a device for constructing a knowledge graph, as shown in Figure 4 The device comprises:
[0153] The acquisition module 410 is configured to acquire a target text and an initial knowledge graph.
[0154] The blocking module 420 is configured to perform a blocking operation on the target text to obtain at least one semantic block.
[0155] The identification module 430 is configured to perform an entity recognition operation on the at least one semantic block to obtain a plurality of pre-entities.
[0156] the disambiguation module 440 is configured to perform disambiguation on the plurality of pre-entities to obtain at least one final entity;
[0157] the retrieval module 450 is configured to retrieve, according to the at least one semantic block and a target final entity, a final associated semantic block associated with the target final entity from the at least one semantic block, where the target final entity is any one of the at least one final entity;
[0158] the determination module 460 is configured to determine, according to the initial knowledge graph and the target final entity, a target subgraph corresponding to the target final entity;
[0159] the fusion module 470 is configured to fuse the final associated semantic block and the target subgraph corresponding to the at least one final entity, respectively, to obtain a target knowledge graph.
[0160] In some optional embodiments, the acquisition module 410 is further configured to:
[0161] identify a target technical field to which the target text belongs;
[0162] acquire, according to the target technical field, a training data set corresponding to the target technical field;
[0163] train the pre-acquired initial vector model by using the training data set to obtain a target vector model, where the target vector model is used for vector conversion operation on the pre-entities and the semantic blocks.
[0164] In some optional embodiments, the disambiguation module 440 is specifically configured to:
[0165] perform vector conversion operation on the plurality of pre-entities by using the target vector model to obtain vectors corresponding to the plurality of pre-entities, respectively;
[0166] determine a similarity between a first pre-entity and a second pre-entity according to a first vector corresponding to the first pre-entity and a second vector corresponding to the second pre-entity, where the first pre-entity is any one of the plurality of pre-entities, and the second pre-entity is any one of the other pre-entities except the first pre-entity in the plurality of pre-entities;
[0167] in a case where the similarity between the first pre-entity and any one of the other pre-entities is less than or equal to a preset similarity threshold, determine the first pre-entity as a final entity.
[0168] In some optional embodiments, the disambiguation module 440 is specifically configured to:
[0169] In a case where the similarity of the first pre-entity and one or more of the other pre-entities is greater than the preset similarity threshold, pre-entities in the first pre-entity and the other pre-entities that have a similarity greater than the preset similarity threshold with the first pre-entity are divided into a candidate entity group;
[0170] The candidate entity group is input into the pre-obtained entity merging model to obtain a merging result output by the entity merging model, where the merging result includes one or more final entities.
[0171] In some optional embodiments, the retrieval module 450 is specifically configured to:
[0172] The at least one semantic block is subjected to a vector conversion operation respectively by using the target vector model to obtain a vector corresponding to each of the at least one semantic block;
[0173] The similarity between the target final entity and the target semantic block is determined according to the vector corresponding to the target final entity and the vector corresponding to the target semantic block, where the target final entity is any one of the at least one final entity, and the target semantic block is any one of the plurality of semantic blocks;
[0174] At least one candidate semantic block is determined from the at least one semantic block according to the similarity between the target final entity and the at least one semantic block;
[0175] A final associated semantic block that has an association relationship with the target final entity is selected from the at least one candidate semantic block according to the target final entity and the at least one candidate semantic block.
[0176] In some optional embodiments, the retrieval module 450 is specifically configured to:
[0177] The at least one semantic block is sorted from high to low according to the similarity between the target final entity and the at least one semantic block to obtain a sorting value corresponding to each of the at least one semantic block;
[0178] Semantic blocks with a sorting value before a first preset sorting value are all determined as candidate semantic blocks.
[0179] In some optional embodiments, the retrieval module 450 is further configured to:
[0180] A semantic block that is consistent with a topic of the target final entity is determined from the at least one semantic block according to the target final entity and a pre-constructed topic model;
[0181] Semantic blocks that are consistent with the topic of the target final entity are all determined as candidate semantic blocks.
[0182] In some optional embodiments, the retrieval module 450 is specifically configured to:
[0183] According to the target end entity, identify the number of occurrences and the occurrence positions of the target end entity in the target candidate semantic block, wherein the target candidate semantic block is any one of the at least one candidate semantic block;
[0184] Obtain the association closeness between the target end entity and the target candidate semantic block;
[0185] According to the number of occurrences and the occurrence positions of the target end entity in the at least one candidate semantic block respectively, and the association closeness corresponding to the at least one candidate semantic block respectively, select the final association semantic block having the association relationship with the target end entity from the at least one candidate semantic block.
[0186] In some optional embodiments, the retrieval module 450 is specifically configured to:
[0187] Determine the similarity between the target end entity and the target candidate semantic block as the association closeness between the target end entity and the target candidate semantic block.
[0188] In some optional embodiments, the retrieval module 450 is specifically configured to:
[0189] According to the number of occurrences and the occurrence positions of the target end entity in the target candidate semantic block, and the association closeness between the target end entity and the target candidate semantic block, determine the importance indicator value of the target candidate semantic block;
[0190] According to the importance indicator value of the at least one candidate semantic block, select the final association semantic block having the association relationship with the target end entity from the at least one candidate semantic block.
[0191] In some optional embodiments, the initial knowledge graph includes a plurality of nodes and at least one edge; the determination module 460 is specifically configured to:
[0192] Calculate the similarity between the target end entity and the plurality of nodes;
[0193] According to the similarity between the target end entity and the plurality of nodes, determine the similar node corresponding to the target end entity from the plurality of nodes;
[0194] According to the at least one edge and the similar node, determine the neighbor node of the similar node from the plurality of nodes;
[0195] Determine the similar node and the neighbor node as the association node having the association relationship with the target end entity;
[0196] According to the association node, extract the edge corresponding to the association node from the at least one edge;
[0197] The target subgraph is formed by the association nodes and corresponding edges.
[0198] In some optional embodiments, the determining module 460 is specifically configured to:
[0199] The plurality of nodes are sorted according to the similarity between the target final entity and the plurality of nodes from high to low, to obtain a sorting value of the plurality of nodes.
[0200] The nodes with the sorting value before the second preset sorting value are all determined as the similar nodes corresponding to the target final entity.
[0201] In some optional embodiments, the fusion module 470 is specifically configured to:
[0202] At least one relationship triple is generated according to the final association semantic block corresponding to the target final entity and the target subgraph.
[0203] The target knowledge graph is constructed according to the at least one relationship triple.
[0204] In some optional embodiments, the fusion module 470 is further configured to:
[0205] The target relationship triple, the target text, and the initial knowledge graph are input into a pre-constructed evaluation model, to obtain an entity fidelity and a relationship fidelity corresponding to the target relationship triple output by the evaluation model, wherein the target relationship triple is any one of the at least one relationship triple.
[0206] According to the entity fidelity and the relationship fidelity corresponding to the target relationship triple, it is determined whether to retain the target relationship triple, so as to construct the target knowledge graph according to the retained relationship triple.
[0207] The features of the embodiments of the device for constructing a knowledge graph can be referred to the related descriptions of the embodiments of the method for constructing a knowledge graph, which will not be repeated here.
[0208] Embodiments of the present application also provide an electronic device, such as Figure 5 As shown in the figure, the electronic device includes a memory 10 and a processor 20, the memory 10 stores a computer program, and the processor 20 is configured to run the computer program to perform the steps in any of the above method embodiments for constructing a knowledge graph. The electronic device can be the service platform described above.
[0209] Embodiments of the present application also provide a computer readable storage medium, which stores a computer program, wherein the computer program is configured to perform the steps in any of the above method embodiments for constructing a knowledge graph when running.
[0210] In an example embodiment, the computer readable storage medium described above can include, but is not limited to, a U disk, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk or an optical disk, and various media that can store computer programs.
[0211] Embodiments of the present application also provide a computer program product, which comprises a computer program, and the computer program, when executed by a processor, implements the steps in any of the method embodiments of constructing a knowledge graph described above.
[0212] Embodiments of the present application also provide another computer program product, which comprises a non-volatile computer readable storage medium, and the non-volatile computer readable storage medium stores a computer program, and the computer program, when executed by a processor, implements the steps in any of the method embodiments of constructing a knowledge graph described above.
[0213] The skilled in the art can further realize that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be realized by electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in the above description in general terms. Whether the functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. The skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0214] The above describes in detail a method, device, electronic equipment, storage medium and program product for constructing a knowledge graph provided by the present application. The principles and implementation modes of the present application are described by applying specific examples in this paper, and the above description of the examples is only used to help understand the method of the present application and its core idea. It should be pointed out that, for those skilled in the art, without departing from the principles of the present application, some improvements and modifications can be made to the present application, and these improvements and modifications also fall within the protection scope of the claims of the present application.
Claims
1. A method for constructing a knowledge graph, characterized in that, include: Obtain the target text and an initial knowledge graph, wherein the initial knowledge graph includes multiple nodes and at least one edge; After performing a block segmentation operation on the target text, at least one semantic block is obtained; Entity recognition operations are performed on at least one of the semantic blocks to obtain multiple pre-entities; Using a pre-acquired target vector model, vector transformation operations are performed on at least one of the semantic blocks to obtain vectors corresponding to at least one of the semantic blocks; and vector transformation operations are performed on multiple pre-entities to obtain vectors corresponding to multiple pre-entities. After disambiguation processing of the multiple pre-entities, at least one final entity is obtained; The similarity between the target final entity and the target semantic block is determined based on the vector corresponding to the target final entity and the vector corresponding to the target semantic block, wherein the target final entity is any one of at least one final entity and the target semantic block is any one of a plurality of semantic blocks; Based on the similarity between the target final entity and at least one of the semantic blocks, at least one candidate semantic block is determined in at least one of the semantic blocks; Based on the target final entity, identify the number of times and the position of the target final entity in the target candidate semantic block, wherein the target candidate semantic block is any one of at least one of the candidate semantic blocks; The similarity between the target final entity and the target candidate semantic block is determined as the degree of association between the target final entity and the target candidate semantic block; Based on the frequency and position of the target final entity in the target candidate semantic block, and the degree of association between the target final entity and the target candidate semantic block, the importance index value of the target candidate semantic block is determined. The importance index value is expressed as score = w1 × freq + w2 × pos_weight + w3 × closeness, where freq is the frequency of occurrence, w1 is a first preset weight value, pos_weight is a first importance index value, w2 is a second preset weight value, closeness is the degree of association, and w3 is a third preset weight value. The first importance index value is determined based on the position of occurrence and the sub-importance index value corresponding to the position of occurrence. Based on the importance index value of at least one of the candidate semantic blocks, the final associated semantic block that is associated with the target final entity is selected from at least one of the candidate semantic blocks; Calculate the similarity between the target final entity and the plurality of nodes; based on the similarity between the target final entity and the plurality of nodes, determine the similar node corresponding to the target final entity among the plurality of nodes; based on at least one edge and the similar node, determine the neighbor node of the similar node among the plurality of nodes; determine both the similar node and the neighbor node as associated nodes that have an association relationship with the target final entity; based on the associated node, extract the edge corresponding to the associated node from at least one edge; wherein, the associated node and its corresponding edge constitute the target subgraph; The final associated semantic block and the target subgraph corresponding to at least one of the final entities are fused to obtain the target knowledge graph.
2. The method for constructing a knowledge graph according to claim 1, characterized in that, The method further includes: Identify the target technical field to which the target text belongs; Based on the target technical field, obtain a training dataset corresponding to the target technical field; Using the training dataset, the pre-acquired initial vector model is trained to obtain the target vector model, wherein the target vector model is used to perform vector transformation operations on the pre-entity and the semantic block.
3. The method for constructing a knowledge graph according to claim 2, characterized in that, After disambiguating the multiple pre-entities, at least one final entity is obtained, including: The similarity between the first pre-entity and the second pre-entity is determined based on the first vector corresponding to the first pre-entity and the second vector corresponding to the second pre-entity, wherein the first pre-entity is any one of the plurality of pre-entities and the second pre-entity is any one of the other pre-entities besides the first pre-entity. If the similarity between the first pre-entity and any of the other pre-entities is less than or equal to a preset similarity threshold, the first pre-entity is determined as the final entity.
4. The method for constructing a knowledge graph according to claim 3, characterized in that, The method further includes: If it is determined that the similarity between the first pre-entity and one or more pre-entities among the other pre-entities is greater than the preset similarity threshold, the pre-entities among the first pre-entity and the other pre-entities whose similarity with the first pre-entity is greater than the preset similarity threshold are divided into a candidate entity group. The candidate entity group is input into the pre-acquired entity merging model to obtain the merging result output by the entity merging model, wherein the merging result includes one or more of the final entities.
5. The method for constructing a knowledge graph according to any one of claims 1 to 4, characterized in that, The step of determining at least one candidate semantic block in at least one semantic block based on the similarity between the target final entity and at least one of the semantic blocks includes: Based on the similarity between the target final entity and at least one of the semantic blocks from high to low, at least one of the semantic blocks is sorted to obtain the sorting value corresponding to each of the at least one semantic block; All semantic blocks whose sorting value precedes the first preset sorting value are determined as candidate semantic blocks.
6. The method for constructing a knowledge graph according to any one of claims 1 to 4, characterized in that, The method further includes: Based on at least one of the semantic blocks, the target final entity, and a pre-built topic model, determine a semantic block in at least one of the semantic blocks that is consistent with the topic of the target final entity; All semantic blocks that are consistent with the theme of the target final entity are identified as candidate semantic blocks.
7. The method for constructing a knowledge graph according to any one of claims 1 to 4, characterized in that, The step of determining similar nodes corresponding to the target final entity among the multiple nodes based on the similarity between the target final entity and the multiple nodes includes: Based on the similarity between the target final entity and the multiple nodes from high to low, the multiple nodes are sorted to obtain the sorting value of the multiple nodes; All nodes whose sorting value is before the second preset sorting value are identified as similar nodes corresponding to the target final entity.
8. The method for constructing a knowledge graph according to any one of claims 1 to 4, characterized in that, The process of fusing the final associated semantic blocks and target subgraphs corresponding to at least one of the final entities to obtain the target knowledge graph includes: Based on the final associated semantic block and the target subgraph corresponding to the target final entity, at least one relation triplet is generated; The target knowledge graph is constructed based on at least one of the relation triples.
9. The method for constructing a knowledge graph according to claim 8, characterized in that, Before constructing the target knowledge graph based on at least one of the said relation triples, the method further includes: The target relation triple, the target text, and the initial knowledge graph are input into a pre-built evaluation model to obtain the entity fidelity and relation fidelity output by the evaluation model corresponding to the target relation triple, wherein the target relation triple is any one of at least one of the relation triples. Based on the entity fidelity and relation fidelity corresponding to the target relation triple, it is determined whether to retain the target relation triple so as to construct the target knowledge graph based on the retained relation triple.
10. An apparatus for constructing a knowledge graph, characterized in that, include: An acquisition module is used to acquire target text and an initial knowledge graph, wherein the initial knowledge graph includes multiple nodes and at least one edge; The segmentation module is used to segment the target text into blocks to obtain at least one semantic block. The identification module is used to perform entity identification operations on at least one of the semantic blocks respectively to obtain multiple pre-entities; The disambiguation module is used to perform vector transformation operations on at least one of the semantic blocks using a pre-acquired target vector model to obtain vectors corresponding to at least one of the semantic blocks respectively; and to perform vector transformation operations on multiple pre-entities to obtain vectors corresponding to multiple pre-entities respectively; and to obtain at least one final entity after disambiguation processing on multiple pre-entities. The retrieval module is configured to: determine the similarity between the target final entity and the target semantic block based on the vector corresponding to the target final entity and the vector corresponding to the target semantic block, wherein the target final entity is any one of at least one final entity, and the target semantic block is any one of a plurality of semantic blocks; determine at least one candidate semantic block among the at least one semantic block based on the similarity between the target final entity and the at least one semantic block; identify the occurrence frequency and position of the target final entity in the target candidate semantic block based on the target final entity, wherein the target candidate semantic block is any one of at least one candidate semantic block; determine the similarity between the target final entity and the target candidate semantic block as the degree of association between the target final entity and the target candidate semantic block; and determine the similarity between the target final entity and the target candidate semantic block based on the similarity between the target final entity and the target candidate semantic block. The importance index value of the target candidate semantic block is determined by considering the frequency and position of occurrence in the target candidate semantic block, as well as the degree of association between the target final entity and the target candidate semantic block. The importance index value is expressed as score = w1 × freq + w2 × pos_weight + w3 × closeness, where freq is the frequency of occurrence, w1 is a first preset weight value, pos_weight is a first importance index value, w2 is a second preset weight value, closeness is the degree of association, and w3 is a third preset weight value. The first importance index value is determined based on the occurrence position and the sub-importance index value corresponding to the occurrence position. Based on the importance index value of at least one candidate semantic block, the final associated semantic block that has an association relationship with the target final entity is selected from at least one candidate semantic block. The determination module is configured to: determine a target subgraph corresponding to the target final entity based on the initial knowledge graph and the target final entity; calculate the similarity between the target final entity and multiple nodes; determine similar nodes corresponding to the target final entity among the multiple nodes based on the similarity between the target final entity and the multiple nodes; determine neighbor nodes of the similar nodes among the multiple nodes based on at least one edge and the similar nodes; determine both the similar nodes and the neighbor nodes as associated nodes that have an association relationship with the target final entity; and extract the edge corresponding to the associated node from at least one edge based on the associated node; wherein the associated node and its corresponding edge constitute the target subgraph. The fusion module is used to fuse the final associated semantic blocks and target subgraphs corresponding to at least one of the final entities to obtain the target knowledge graph.
11. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the steps of the method for constructing a knowledge graph as described in any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for constructing a knowledge graph as described in any one of claims 1 to 9.
13. A computer program product, characterized in that, The computer program product includes a computer program, wherein the computer program, when executed by a processor, implements the steps of the method for constructing a knowledge graph as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Semantic knowledge graph construction method, electronic equipment and storage medium
CN115905575A
Entity word disambiguation method and device, knowledge graph generation method and device and knowledge recommendation method and device
CN116127053A