Knowledge graph construction method based on large language model

Through a large language model, semantic block extraction and relationship construction of unstructured data, combined with the Neo4j graph database, the problem of insufficient generalization ability and manual intervention in knowledge graph construction in the existing technology is solved, and efficient and accurate knowledge graph construction is achieved. .

CN119248938APending Publication Date: 2025-01-03SOUTHWEAT UNIV OF SCI & TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411348420.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

The existing methods of building knowledge graphs based on LLM are insufficient in generalization capabilities. They rely on specific ontological or thematic frameworks, and are difficult to widely apply in different disciplines and application scenarios. They require a lot of manual intervention to correct the redundancy and inconsistency between entities and relationships. sexual problems increase time and economic costs.

Method used

Using a large language model to rewritten unstructured data, extract entities and relationships through semantic blocks, use incremental methods to build global entities and relationship sets, and use Neo4j graph database for visual processing, reducing manual audit workload and improving construction efficiency.

Benefits of technology

It significantly improves the performance and efficiency of knowledge graph construction, reduces the workload of manual review, improves the accuracy of construction, and is suitable for diversified unstructured data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure BDA0005061632770000021
    Figure BDA0005061632770000021
  • Figure BDA0005061632770000022
    Figure BDA0005061632770000022
  • Figure BDA0005061632770000041
    Figure BDA0005061632770000041
Patent Text Reader

Abstract

The invention relates to a knowledge graph construction method and device based on a large language model, and belongs to the technical field of artificial intelligence, and the method comprises the following steps: converting an original document into structured semantic chunks, and carrying out information extraction according to a preset mode or frame by means of the large-scale language model (LLMs); performing entity recognition on the semantic blocks by means of LLMs and extracting entities, and gradually constructing a global entity set in an incremental mode; analyzing the entities and the semantic chunks through LLMs, and extracting a relationship between the entities; and visualizing the identified entities and the relationships thereof by using a Neo4j graphic database to construct a knowledge graph. The advanced large language model technology is adopted, so that the performance of knowledge graph construction is remarkably improved, and the workload of manual auditing is effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of artificial intelligence technology, and specifically relates to a knowledge graph construction method based on a large language model. Background Art

[0002] Knowledge graphs organize the knowledge of the human world in an orderly manner in the form of triples (i.e., head entities, relationships, and tail entities) to achieve effective organization of information. However, since many sources of knowledge are mostly unstructured, there are many problems in automatically constructing knowledge graphs, so they need to be optimized.

[0003] Traditional methods for building knowledge graphs based on LLMs are divided into three categories: ontology-guided, fine-tuning, and zero-shot / few-shot. These methods do not rely on a large amount of labeled data, but rely on LLMs with few or no examples to perform tasks. However, they also inevitably face some challenges and limitations.

[0004] First, the lack of generalization ability is significant. Many current research methods rely too much on specific ontologies or subject frameworks, which limits their wide applicability in different disciplines and application scenarios. Secondly, in the absence of predefined entity and relationship types, how to effectively identify, parse and integrate entities and relationships is still a major challenge facing current research. Furthermore, the problem of post-processing requirements cannot be ignored. Most research methods need to rely on a lot of post-processing work to solve the redundancy and inconsistency problems of entities and relationships in the information processing process.

[0005] Therefore, in the current process of building knowledge graphs based on LLM, it is generally necessary to rely on a large amount of manual intervention to verify and correct errors, which not only increases the time cost, but also increases the overall economic cost. Summary of the invention

[0006] The purpose of the present invention is to address the problems existing in the prior art and provide a knowledge graph construction method based on a large language model to construct a knowledge graph for unstructured data from diverse sources, greatly reducing the burden of manual detection while improving the efficiency and accuracy of knowledge graph construction.

[0007] The technical solution is as follows:

[0008] A method for constructing a knowledge graph based on a large language model includes the following steps:

[0009] Step 1: Use LLMs to rewrite the input file to generate semantic blocks, obtain knowledge graph data through the preset model, and use prompting technology to make LLMs focus on specific content in the file and extract relevant information;

[0010] Step 2: Use LLMs to analyze semantic blocks, identify and extract entity information, and then build a global entity set through an incremental approach;

[0011] Step 3: Using the semantic blocks generated in step 1 and the global entity set constructed in step 2, after parsing by LLMs, the relationships between entities are mined to further form a global relationship set.

[0012] Step 4: Integrate the data of the global entity set and the global relationship set to construct a knowledge graph, and use the Neo4j graph database to visualize the knowledge graph.

[0013] Furthermore, the knowledge graph data in step 1 is defined as E is a node set used to store entities, and R is an edge set used to store relationships. The preset model is similar to a predefined JSON file, which guides LLMs to extract specific feature values ​​(text information) from the document. If the required information exists in the document, a semi-filled JSON will be obtained, and then all the semi-filled JSONs will be aggregated to form a semantic block d of the document. All semantic blocks are integrated into a semantic block set D. The model is defined using Langchain's JSON Parser5, and the document is used as the context.

[0014] Furthermore, the steps of using LLMs to analyze semantic blocks in step 2 to form a global entity set are as follows:

[0015] Step 2.1 Use LLMs to extract entities e from the first semantic block d0. Assume that these entities are pairwise distinct in the first iteration, that is, each pair of entities is unique and each describes a semantically unique concept, forming a local entity set. Since this is the first semantic block, That is ε;

[0016] Step 2.2 For the subsequent semantic block d i ∈D, extract local entity set Next, try to convert the existing Merge with ε to refresh ε. The merging process includes the following situations:

[0017] Case 1 If the local entity If it is found in ε, it is added to the entity matching set ε d,matched middle;

[0018] Case 2 If no identical e is found i , then the cosine similarity metric with a predefined threshold is used to search for similar entities in ε. The formula for cosine similarity is as follows:

[0019]

[0020] The search process includes the following situations:

[0021] Case 2.1 If no matching item is found, e i Add to ε d,matched middle;

[0022] Case 2.2 If found, the best matching global entity e′ based on the maximum similarity i Add to ε d,matched middle;

[0023] Step 2.3 By replacing ε d,matched Unify with ε to update ε;

[0024] Step 2.4 Repeat steps 2.2 and 2.3 for each d in D, and finally form a comprehensive ε.

[0025] Furthermore, in step 3, the steps of using LLMs to parse the semantic blocks and the global entity set to form a global relationship set are as follows:

[0026] Step 3.1 provides the first semantic block d0 and the global entity set ε as context to LLMs to extract relations to form a local relation set Since it is the first semantic block, the local relation set The global relation set

[0027] Step 3.2 For the subsequent semantic block d i ∈D, extract local relation set Next, try to convert the existing and Merge, thus Refresh and merge processes include the following:

[0028] Case 1 If the local relationship exist If it is found in the relation, it is added to the relation matching set. middle;

[0029] Case 2 If not found, the cosine similarity metric with a predefined threshold is used To search for similar relationships, the formula for cosine similarity is as follows:

[0030]

[0031] The search process includes the following situations

[0032] Case 2.1 If no matching item is found, r i Add to middle;

[0033] Case 2.2 If found, the best matching global relation r′ based on the maximum similarity i Add to middle;

[0034] Step 3.3 By and Update with Unity

[0035] Step 3.4 Repeat steps 3.2 and 3.3 for each semantic block in D, and finally form a comprehensive

[0036] Furthermore, in step 4, the global entity set ε and the global relationship set Input into the Neo4j graph database to build a knowledge graph.

[0037] Beneficial effects:

[0038] 1) This invention significantly improves the performance of knowledge graph construction and effectively reduces the workload of manual review by adopting advanced large language model technology.

[0039] 2) The knowledge graph is constructed through a large language model, which improves the construction efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of the framework of the method of the present invention.

[0041] Figure 2 This is a graph of information consistency scores for different types of documents. DETAILED DESCRIPTION

[0042] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. The directions or positional relationships indicated by the terms "upper", "lower", "front", "back", "left", "right", "bottom", "inside", "outside", etc. are based on the directions or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention, rather than indicating or implying that the device or element referred to must have a specific direction, be constructed and operated in a specific direction, and therefore cannot be understood as limiting the present invention:

[0043] like Figure 1 A method for constructing a knowledge graph based on a large language model is shown, comprising the following steps:

[0044] Step 1: Use LLMs to rewrite the input file to generate semantic blocks, obtain knowledge graph data through the preset model, and use prompting technology to make LLMs focus on specific content in the file and extract relevant information;

[0045] Step 2: Use LLMs to analyze semantic blocks, identify and extract entity information, and then build a global entity set through an incremental approach;

[0046] Step 3: Using the semantic blocks generated in step 1 and the global entity set constructed in step 2, after parsing by LLMs, the relationships between entities are mined to further form a global relationship set.

[0047] Step 4: Integrate the data of the global entity set and the global relationship set to construct a knowledge graph, and use the Neo4j graph database to visualize the knowledge graph.

[0048] The knowledge graph data in step 1 is defined as E is a node set used to store entities, and R is an edge set used to store relationships. The preset model is similar to a predefined JSON file, which guides LLMs to extract specific feature values ​​(text information) from the document. If the required information exists in the document, a semi-filled JSON will be obtained, and then all the semi-filled JSONs will be aggregated to form a semantic block d of the document. All semantic blocks are integrated into a semantic block set D. The model is defined using Langchain's JSON Parser5, and the document is used as the context.

[0049] In step 2, the steps of using LLMs to analyze semantic blocks and form a global entity set are as follows:

[0050] Step 2.1 Use LLMs to extract entities e from the first semantic block d0. Assume that these entities are pairwise distinct in the first iteration, that is, each pair of entities is unique and each describes a semantically unique concept, forming a local entity set. Since this is the first semantic block, That is ε;

[0051] Step 2.2 For the subsequent semantic block d i ∈D, extract local entity set Next, try to convert the existing Merge with ε to refresh ε. The merging process includes the following situations:

[0052] Case 1 If the local entity If it is found in ε, it is added to the entity matching set ε d,matched middle;

[0053] Case 2 If no identical e is found i , then the cosine similarity metric with a predefined threshold is used to search for similar entities in ε. The formula for cosine similarity is as follows:

[0054]

[0055] The search process includes the following situations:

[0056] Case 2.1 If no matching item is found, e i Add to ε d,matched middle;

[0057] Case 2.2 If found, the best matching global entity e′ based on the maximum similarity i Add to ε d,matched middle;

[0058] Step 2.3 By replacing ε d,matched Unify with ε to update ε;

[0059] Step 2.4 Repeat steps 2.2 and 2.3 for each d in D, and finally form a comprehensive ε.

[0060] In step 3, the steps of using LLMs to parse semantic blocks and global entity sets to form global relationship sets are as follows:

[0061] Step 3.1 provides the first semantic block d0 and the global entity set ε as context to LLMs to extract relations to form a local relation set Since it is the first semantic block, the local relation set The global relation set

[0062] Step 3.2 For the subsequent semantic block d i ∈D, extract local relation set Next, try to convert the existing and Merge, thus Refresh and merge processes include the following:

[0063] Case 1 If the local relationship exist If it is found in the relation, it is added to the relation matching set. middle;

[0064] Case 2 If not found, the cosine similarity metric with a predefined threshold is used To search for similar relationships, the formula for cosine similarity is as follows:

[0065]

[0066] The search process includes the following situations

[0067] Case 2.1 If no matching item is found, r i Add to middle;

[0068] Case 2.2 If found, the best matching global relation r′ based on the maximum similarity i Add to middle;

[0069] Step 3.3 By and Update with Unity

[0070] Step 3.4 Repeat steps 3.2 and 3.3 for each semantic block in D, and finally form a comprehensive

[0071] In step 4, the global entity set ε and the global relationship set Input into the Neo4j graph database to build a knowledge graph. Figure 2 The consistency score diagram of different types of document information is shown. In order to verify the accuracy of the method proposed in the present invention, simulation experiments are conducted on three types of documents: academic resumes, scientific articles, and web page information, from complete consistency to basic consistency and finally medium consistency. It can be seen from the figure that except for the web page information with 20% medium consistency, the rest of the cases have high complete consistency and basic consistency, which may be due to the excessive unstructured data in the web page information.

[0072] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the principles and spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A knowledge graph construction method based on a large language model, characterized by: The following steps are involved: Step 1: Use LLMs to rewrite the input file to generate semantic blocks, obtain knowledge graph data through the preset model, and use prompting technology to make LLMs focus on specific content in the file and extract relevant information; Step 2: Use LLMs to analyze semantic blocks, identify and extract entity information, and then build a global entity set through an incremental approach; Step 3: Using the semantic blocks generated in step 1 and the global entity set constructed in step 2, after parsing by LLMs, the relationships between entities are mined to further form a global relationship set. Step 4: Integrate the data of the global entity set and the global relationship set to construct a knowledge graph, and use the Neo4j graph database to visualize the knowledge graph.

2. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: The knowledge graph data in step 1 is defined as Where ε is a node set used to store entities, The edge set is used to store relations; the preset model is similar to a predefined JSON file, which guides LLMs to extract specific feature values ​​(text information) from the document. If the required information exists in the document, a semi-filled JSON will be obtained, and then all the semi-filled JSONs will be aggregated to form the semantic block d of the document. All semantic blocks are integrated into a semantic block set D; the model is defined using Langchain's JSONParser5, and the document is used as the context.

3. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: In step 2, the steps of using LLMs to analyze semantic blocks and form a global entity set are as follows: Step 2.1 Use LLMs to extract entities e from the first semantic block d0. Assume that these entities are pairwise distinct in the first iteration, that is, each pair of entities is unique and each describes a semantically unique concept, forming a local entity set. Since this is the first semantic block, That is ε; Step 2.2 For the subsequent semantic block d i ∈D, extract local entity set Next, try to convert the existing Merge with ε to refresh ε. The merging process includes the following situations: Case 1 If the local entity If it is found in ε, it is added to the entity matching set ε d,matched middle; Case 2 If no identical e is found i , then the cosine similarity metric with a predefined threshold is used to search for similar entities in ε. The formula for cosine similarity is as follows: The search process includes the following situations: Case 2.1 If no matching item is found, e i Add to ε d,matched middle; Case 2.2 If found, the best matching global entity e′ based on the maximum similarity i Add to ε d,matched middle; step 2.3 By changing ε d,matched Unify with ε to update ε; Step 2.4 Repeat steps 2.2 and 2.3 for each d in D, and finally form a comprehensive ε.

4. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: In step 3, the steps of using LLMs to parse the semantic block and the global entity set to form a global relationship set are as follows: Step 3.1 provides the first semantic block d0 and the global entity set ε as context to LLMs to extract relations to form a local relation set Since it is the first semantic block, the local relation set The global relation set Step 3.2 For the subsequent semantic block d i ∈D, extract local relation set Next, try to convert the existing and Merge, thus Refresh and merge processes include the following: Case 1 If the local relationship exist If it is found in the relation, it is added to the relation matching set. middle; Case 2 If not found, the cosine similarity metric with a predefined threshold is used To search for similar relationships, the formula for cosine similarity is as follows: The search process includes the following situations Case 2.1 If no matching item is found, r i Add to middle; Case 2.2 If found, the best matching global relation r′ based on the maximum similarity i Add to middle; Step 3.3 By and Update with Unity Step 3.4 Repeat steps 3.2 and 3.3 for each semantic block in D, and finally form a comprehensive 5. The method for constructing a knowledge graph based on a large language model according to claim 1, characterized in that: In step 4, the global entity set ε and the global relationship set Input into the Neo4j graph database to build a knowledge graph.