A method for automatically constructing knowledge graphs based on prior knowledge and knowledge connections
By introducing prior knowledge and knowledge connection technology in the construction of knowledge graph, and using multiple large language model agents to generate effective data related to the topic, the problems of high cost and low accuracy in traditional methods are solved, and efficient and accurate are achieved. The knowledge graph is automatically constructed, which enhances the completeness and accuracy of the knowledge graph.
Patent Information
- Application Number
- CN202410978360.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-22
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-07-22
AI Technical Summary
Traditional knowledge graph construction methods rely on manual annotation, resulting in high construction costs, low accuracy and incompleteness. In addition, large language models are inaccurate in extracting knowledge when building knowledge graphs in specific fields, with low effect and poor accuracy.
Using a method based on prior knowledge and knowledge connection, by saving the topic information for building the knowledge graph as a string, retrieving external data sources, injecting four large language model agents of tagging, reasoning, cognition and association, using knowledge to connect large The language model generates effective data related to the topic, and constructs entity-relationship-entity triples through multiple rounds of feedback to achieve automatic construction.
It improves the integrity and reliability of the knowledge graph, enhances the construction accuracy of large language models in specific fields, reduces manual construction costs, and solves the problems of difficult data verification and low controllability.
Smart Images

Figure CN118520945B
Abstract
Description
Technical Field
[0001] The present invention relates to a method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections, and belongs to the field of natural language processing. Background Art
[0002] The knowledge graph records the concepts, entities and their relationships in the objective world in detail in the form of a graph structure to simulate the way humans understand the cognitive world. This way of expression gives us the ability to organize, manage and understand professional information more effectively. Therefore, it is crucial to build knowledge graphs in various fields. However, traditional knowledge graph construction methods mainly rely on manual annotation and manual organization of expert knowledge. This method often cannot efficiently extract entities, attributes and relationships from texts, limiting the speed and scale of knowledge graph construction. In this context, the use of large language models can effectively reduce the cost of manually constructing knowledge graphs, while improving the accuracy and completeness of knowledge graphs. Therefore, the automatic construction method of knowledge graphs based on large language models has become a major research direction in the field of natural language processing.
[0003] The automatic construction of domain knowledge graphs based on large language models faces a series of problems such as unreliable data, poor understanding of domain expertise, and inaccurate extraction of original corpus knowledge. Moreover, as a general model, the large language model cannot construct a high-precision and high-completeness domain knowledge graph in a specific field. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for automatically constructing a knowledge graph based on prior knowledge and knowledge connection, which aims to address the problems faced by traditional knowledge graph construction methods, including high manual construction costs, low precision and incompleteness, so as to achieve efficient and accurate automatic construction of knowledge graphs. By introducing prior knowledge, it is possible to effectively solve the problems of inaccurate knowledge extraction and unreliable knowledge when constructing domain knowledge graphs using large language models. By introducing knowledge connection technology, it is possible to effectively solve the problems of low knowledge extraction effect and poor precision when constructing knowledge graphs based on external data using generative large language models.
[0005] The technical solution adopted by the present invention is: a method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections, the specific steps of which are:
[0006] Step 1: Save the relevant topic information of building the knowledge graph as a string to obtain prompt data;
[0007] Step 2: Retrieve article paragraphs from external data sources based on prompt data and save them;
[0008] Step 3: Inject the prompt templates of the four large language model agents: marking, reasoning, cognition, and association;
[0009] Step 4: Input the injected prompt template, article paragraphs and specific task requirements into the above four large language model agents to obtain prior knowledge;
[0010] Step 5: Connect the article paragraphs, prior knowledge, and predefined comparative prompt text input knowledge to the large language model to obtain valid data related to the knowledge graph topic;
[0011] Step 6: Use valid data related to the knowledge graph topic and predefined input prompts as the input layer of the large language model automatic proxy framework. After multiple rounds of feedback from the large language model, entity-relationship-entity triples are obtained to complete the construction of the knowledge graph.
[0012] The specific steps of Step 1 are:
[0013] Step 1.1: Convert all original corpus data in different formats such as text, voice, and PDF images from actual scenarios into unified character text and perform preliminary integration to obtain original character data;
[0014] Step 1.2: Clean the original character data, eliminate blank data and redundant data, and obtain prompt data.
[0015] The specific steps of Step 2 are:
[0016] Step 2.1: Use the prompt data as the input of the retrieval framework;
[0017] Step 2.2: Retrieve the paragraph text with the highest similarity to the prompt data from the pre-saved document external data source according to the maximum likelihood estimation search algorithm;
[0018] Step 2.3: Save the retrieved paragraph text as a string.
[0019] The specific steps of Step 3 are:
[0020] Step 3.1: Inject cognitive prompt templates according to the expected functions of cognitive agents;
[0021] Step 3.2: Inject the tag prompt template according to the expected function of the tag agent;
[0022] Step 3.1: Inject the reasoning prompt template according to the expected function of the reasoning agent;
[0023] Step 3.1: Inject associative prompt templates according to the expected functions of the associative agent.
[0024] The specific steps of Step 4 are:
[0025] Step 4.1: Input the injected prompt template as data relevance requirement into the four large language model agents;
[0026] Step 4.2: Input the article paragraphs as extracted corpus into the four large language model agents;
[0027] Step 4.3: Input the predefined generated data format as a specific task requirement into the four large language model agents;
[0028] Step 4.4: Four large language model agents generate prior knowledge related to the graph topic from four aspects based on the input data of Step 4.1- Step 4.3.
[0029] The specific steps of Step 5 are:
[0030] Step 5.1: Use the article paragraphs as the extracted data and the prior knowledge as the reference data;
[0031] Step 5.2: Use the predefined comparison prompt text as the prompt instruction and input it into the knowledge connection large language model;
[0032] Step 5.3: According to the prompt instructions, the large language model uses prior knowledge as the standard to extract the expansion information of relevant prior knowledge from the article paragraphs;
[0033] Step 5.3: Integrate prior knowledge and expanded information to obtain valid data related to the knowledge graph topic.
[0034] The specific steps of Step 6 are:
[0035] Step 6.1: Set the agent types of the two large language models in the automatic agent framework to "customer" and "knowledge graph construction expert";
[0036] Step 6.2: Pass valid data related to the knowledge graph topic as context to the "customer", and pass the input prompt as an instruction to the "knowledge graph construction expert";
[0037] Step 6.3: Based on multiple rounds of feedback, obtain the triple data contained in the local knowledge graph obtained in each feedback, and finally obtain the complete knowledge graph.
[0038] The beneficial effects of the present invention are: using a priori knowledge method to solve the problems of data verification difficulties in specific scenarios and incomplete valid data related to knowledge graph topics, thereby enhancing the integrity and reliability of the knowledge graph; using knowledge connection methods to solve the problems of low controllability and low precision of using a large language model as a driving engine, thereby improving the accuracy of the knowledge graph; using a large language model feedback agent framework as the main body of automatic construction, the dialogue feedback process can be applied to the automatic construction of the domain knowledge graph, reducing the cost of manual construction. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 It is the overall flow chart of the present invention. DETAILED DESCRIPTION
[0040] The present invention will be further described below in conjunction with the accompanying drawings and specific implementation methods.
[0041] Example 1: Figure 1 As shown in FIG, the specific steps of a method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections are as follows:
[0042] Step S1: The text input by the experts in the actual scene, such as "The smelting method of metal tin mainly depends on the material composition and content of the ore. Generally, the pyrometallurgy is the main method, and the hydrometallurgy is the auxiliary method", the recordings conveyed by the experts, the PDF pictures of tin smelting on the Internet, and the internal information of the company are all converted into unified character text through Baidu voice recognition and PaddleOCR recognition, and then preliminarily integrated to obtain the original character data. The original character data is cleaned to eliminate blank data and redundant data to obtain prompt data.
[0043] Step S2: The prompt data of step S1 and the general task requirement of "identifying the relevant paragraph contents of ore, equipment, gas, temperature, humidity, etc. contained in the relevant tin smelting process" are used as input of the retrieval framework. The framework retrieves the relevant text paragraphs according to the maximum likelihood estimation search algorithm and saves them as strings.
[0044] Step S3: Input the text: "You are an expert in the field of cognitive science. Please answer the following questions: I will provide you with several retrieved paragraphs: {paragraphs} Please extract the basic knowledge that the model may be familiar with or advanced information beyond the basic knowledge that the model is already familiar with from these paragraphs, and analyze the role of these contents. Summarize and consolidate these contents, which should deepen the model's understanding of the problem by being familiar with these basic and advanced information. This process is designed to encourage the model to understand the problem more thoroughly and expand its knowledge boundaries." as a cognitive prompt template to the cognitive agent; Input the text: "You are an expert in the field of cognitive science. Please answer the following questions: Question {question} I will provide you with several retrieved paragraphs:: {} Task description: Please extract the content that the model may not be familiar with from these paragraphs, which can provide the model with relevant background and unknown knowledge and concepts to help it better understand the problem, and analyze the role of these contents." as a marking prompt template to the marking agent; Input the text: "You are an expert in the field of logic. You have to answer the following questions: Question {question} I will provide you with some retrieved paragraphs: paragraph: {paragraph} Task description: Please extract from these paragraphs Extract content that helps enhance the model's causal and logical reasoning capabilities. Consolidate these contents and analyze how the selected information may affect the improvement of the model's causal and logical reasoning capabilities. " is input into the reasoning agent as a reasoning prompt template; the text: "Fact checking refers to the process of confirming the accuracy of a statement or claim through various sources or methods. This process ensures that the statement or claim is based on reliable and verifiable information while eliminating inaccurate or misleading content. Fact checking may involve checking data, literature, expert opinions or other credible sources. To answer the following question: {question}, I will provide you with some retrieved paragraphs: paragraph: {paragraph} Task description: Please extract content from these paragraphs that may contradict the model's existing knowledge. Identify information that, when added, can update the model's knowledge and prevent factual errors, alleviating model illusions. Note that these paragraphs are retrieved from an authoritative knowledge base, so it is assumed that they are correct. " is input into the associative agent as an associative prompt template.
[0045] Step S4: Input the above-injected prompt template as data relevance requirements into the above-mentioned four large language model agents. Input the article paragraphs as extracted corpus into the above-mentioned four large language model agents. Input the predefined generated data format and other requirements as specific task requirements into the above-mentioned four large language model agents. The agent generates prior knowledge related to the graph theme from four aspects based on the input data.
[0046] Step S5: Use the article paragraphs as the extracted data and the prior knowledge as the reference data; use the predefined comparative prompt text data "Based on your existing knowledge information, I will give you the text {text}, please extract relevant knowledge from it, exclude the knowledge information that contradicts your cognition, and integrate the relevant knowledge to generate text data" as the prompt instruction, and input it into the knowledge connection large language model; according to the prompt instruction, the knowledge connection large language model uses the prior knowledge as the standard to extract the expanded information of the relevant prior knowledge from the article paragraphs; integrate the prior knowledge and the expanded information to obtain valid data related to the knowledge graph theme.
[0047] Step S6: First, set the agent types of the two large language models in the Auto-GPT automatic agent framework to "customer" and "knowledge graph construction expert". The valid data related to the knowledge graph topic is passed to the "customer" as the context, and the input prompt is passed to the "tin smelting knowledge graph construction expert" as the instruction. According to multiple rounds of feedback, the triple data contained in the local knowledge graph obtained by each feedback is obtained, and finally the complete knowledge graph is obtained.
[0048] The specific implementation modes of the present invention are described in detail above in conjunction with the accompanying drawings, but the present invention is not limited to the above implementation modes, and various changes can be made within the knowledge scope of ordinary technicians in this field without departing from the purpose of the present invention.
Claims
1. A method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections, characterized in that: The specific steps are: Step 1: Save the relevant topic information of building the knowledge graph as a string to obtain prompt data; Step 2: Retrieve article paragraphs from external data sources based on prompt data and save them; Step 3: Inject the prompt templates of the four large language model agents: marking, reasoning, cognition, and association; Step 4: Input the injected prompt template, article paragraphs and specific task requirements into the above four large language model agents to obtain prior knowledge; Step 5: Connect the article paragraphs, prior knowledge, and predefined comparative prompt text input knowledge to the large language model to obtain valid data related to the knowledge graph topic; Step 6: Use valid data related to the knowledge graph topic and predefined input prompts as the input layer of the large language model automatic proxy framework. After multiple rounds of feedback from the large language model, entity-relationship-entity triples are obtained to complete the construction of the knowledge graph. Step 5 is as follows: Step 5.1: Use the article paragraphs as the extracted data and the prior knowledge as the reference data; Step 5.2: Use the predefined comparison prompt text as the prompt instruction and input it into the knowledge connection large language model; Step 5.3: According to the prompt instructions, the large language model uses prior knowledge as the standard to extract the expansion information of relevant prior knowledge from the article paragraphs; Step 5.3: Integrate prior knowledge and expanded information to obtain valid data related to the knowledge graph topic.
2. The method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections according to claim 1, characterized in that: Step 1 is as follows: Step 1.1: Convert all original corpus data in different formats such as text, voice, and PDF images from actual scenarios into unified character text and perform preliminary integration to obtain original character data; Step 1.2: Clean the original character data, eliminate blank data and redundant data, and obtain prompt data.
3. The method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections according to claim 1, characterized in that: Step 2 is as follows: Step 2.1: Use the prompt data as the input of the retrieval framework; Step 2.2: Retrieve the paragraph text with the highest similarity to the prompt data from the pre-saved document external data source according to the maximum likelihood estimation search algorithm; Step 2.3: Save the retrieved paragraph text as a string.
4. The method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections according to claim 1, characterized in that: Step 3 is as follows: Step 3.1: Inject cognitive prompt templates according to the expected functions of cognitive agents; Step 3.2: Inject the tag prompt template according to the expected function of the tag agent; Step 3.1: Inject the reasoning prompt template according to the expected function of the reasoning agent; Step 3.1: Inject associative prompt templates according to the expected functions of the associative agent.
5. The method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections according to claim 1, characterized in that: Step 4 is as follows: Step 4.1: Input the prompt template as data relevance requirement into four large language model agents; Step 4.2: Input the article paragraphs as extracted corpus into the four large language model agents; Step 4.3: Input the predefined generated data format as a specific task requirement into the four large language model agents; Step 4.4: Four large language model agents generate prior knowledge related to the graph topic from four aspects based on the input data of Step 4.1- Step 4.
3.
6. The method for automatically constructing a knowledge graph based on prior knowledge and knowledge connections according to claim 1, characterized in that: Step 6 is as follows: Step 6.1: Set the agent types of the two large language models in the automatic agent framework to "customer" and "knowledge graph construction expert"; Step 6.2: Pass valid data related to the knowledge graph topic as context to the "customer", and pass the input prompt as an instruction to the "knowledge graph construction expert"; Step 6.3: Based on multiple rounds of feedback, obtain the triple data contained in the local knowledge graph obtained in each feedback, and finally obtain the complete knowledge graph.
