A method for automatically constructing inverse constraint knowledge graph based on adaptive feedback
By introducing adaptive feedback prompt technology and inverse constraint methods into large language models, the problems of unreliability of data and small pattern layer scale when building domain knowledge graphs are solved, and the automatic construction of knowledge graphs with high precision and high integrity is achieved.
Patent Information
- Application Number
- CN202411773608.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-05
- Publication Date
- 2025-03-25
- Estimated Expiration
- 2044-12-05
AI Technical Summary
When building domain knowledge graphs, large language models face problems such as unreliable data, poor understanding of domain expertise, inaccurate extraction of original corpus knowledge, and small scale of pattern layers, resulting in insufficient accuracy and completeness of generated knowledge graphs.
The automatic construction method of inverse constraint knowledge graph based on adaptive feedback is adopted to improve the accuracy and reliability of knowledge extraction through adaptive feedback prompt technology, and the problem of scale limitation of the mode layer is solved through inverse constraint methods to achieve larger-scale and higher-precision knowledge graph construction.
It effectively solves the problems caused by low-quality prompts of large language models when building domain knowledge graphs, improves the accuracy and reliability of the knowledge graphs, and expands the scale of the pattern layer, and improves the overall quality of the knowledge graphs.
Smart Images

Figure CN119250193B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an automatic construction method of an inverse constraint knowledge graph based on adaptive feedback, and belongs to the field of natural language processing. Background Art
[0002] The knowledge graph systematically records the concepts, entities and their relationships in the objective world in the form of a graph structure, aiming to simulate and enhance human cognition of the real world. This graphical expression method can not only effectively organize and manage complex information, but also promote the deep understanding and application of professional domain knowledge. Therefore, it is crucial to build knowledge graphs in various fields. However, building domain knowledge graphs based on large language models requires experts to design effective prompts to improve the generation quality of large language models. 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. As a general model, the large language model cannot build a high-precision and high-completeness domain knowledge graph in a specific field.
[0003] In this context, how to use adaptive prompts and inverse constraint methods to effectively reduce the cost of manually designed prompt words, improve the construction accuracy of large language models, increase the scale of the pattern layer without considering the input limitations of large language models, and at the same time improve the accuracy and completeness of domain knowledge graphs are technical problems that need to be solved urgently. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback, which aims to address the problems faced by the method of constructing a knowledge graph using a large language model, including unreliable data, poor understanding of domain expertise, inaccurate extraction of original corpus knowledge, small scale, etc., thereby achieving efficient and accurate automatic construction of a knowledge graph.
[0005] The technical solution of the present invention is: a method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback, which can effectively solve the problems of inaccurate and unreliable knowledge extraction due to improper prompt word design when constructing a domain knowledge graph using a large language model by introducing an adaptive feedback prompt technology. By introducing the inverse constraint method, the problems of small extraction scale and low precision can be effectively solved when constructing a domain knowledge graph using a generative large language model because the pattern layer is too large to be embedded in the prompt.
[0006] The specific steps are:
[0007] Step 1: Input the image and voice data into the OCR recognition module and the voice recognition module to obtain the initial text input data;
[0008] Step 2: Generate prompt examples based on predefined prompt templates and a small number of sample text data, and adaptively generate prompts using a large language model;
[0009] Step 3: Based on the predefined feedback prompt template, the prompt feedback large language model evaluates the prompt sample and obtains the prompt score;
[0010] Step 4: Sort the prompts according to the scores, and take the prompt with the highest score as the best prompt;
[0011] Step 5: Based on the optimal prompt and the predefined extraction prompt template, the knowledge extraction large language model extracts the open knowledge graph triples;
[0012] Step 6: Use the Transformer encoder to encode the open knowledge graph triples and the pattern layer text information to obtain the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector respectively;
[0013] Step 7: Use the vector similarity search module to match the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector to obtain the constrained domain knowledge graph triple and complete the knowledge graph construction.
[0014] The Step 1 is specifically as follows:
[0015] Step 1.1: Process the original image data from the actual scene through the OCR recognition module to obtain the text data in the image;
[0016] Step 1.2: Process the original speech data from the actual scene through the speech recognition module to obtain the text data in the speech;
[0017] Step 1.3: Perform data cleaning on the text data in the image, the text data in the speech, and the data in the original text format to obtain initial text input data.
[0018] Specifically, the data cleaning in the Step 1.3 is as follows: converting the text data in the image, the text data in the speech, and the data in the original text format into character data, and then eliminating redundancy and invalid characters from the character data.
[0019] The Step 2 is specifically as follows:
[0020] Step 2.1: Use the predefined generation prompt template as the adaptive prompt to generate the rule prompt of the large language model;
[0021] Step 2.2: Use the few-shot text data as adaptive prompts to generate the few-shot prompts of the large language model;
[0022] Step 2.3: Adaptive prompt generation The large language model generates prompt samples based on rule prompts and few-sample prompts.
[0023] Specifically, the prompt samples in Step 2.3 are: M homogeneous prompts that guide the prompt feedback large language model to complete the task, where M is the number of prompt samples received under the prompt feedback large language model.
[0024] The Step 3 is specifically as follows:
[0025] Step 3.1: Use the predefined feedback prompt template as the input prompt of the prompt feedback large language model;
[0026] Step 3.2: The prompt feedback large language model generates a prompt sample score key-value pair based on the input prompt.
[0027] Specifically, the prompt sample scoring key-value pair in Step 3.2 is: the prompt feedback large language model scores the task results obtained from different prompt samples, and the prompt sample and the corresponding score constitute a key-value pair.
[0028] Step 5 is as follows:
[0029] Step 5.1: Use the optimal prompt and predefined extraction prompt template as prompt rules and input them into the knowledge extraction large language model;
[0030] Step 5.2: Knowledge extraction The large language model extracts knowledge from the initial text input data according to the prompt rules to obtain open knowledge graph triples.
[0031] Specifically, the open knowledge graph triples in Step 5.2 are: all triples that exist in the text data without rules and domain scope constraints.
[0032] The Step 7 is specifically as follows:
[0033] Step 7.1: Input the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector into the vector similarity search module;
[0034] Step 7.2: Set the threshold Top K and obtain the top K relationship semantic information based on the pattern layer semantic information;
[0035] Step 7.3: Use the previous K relational semantic information as constraint rules to constrain the open knowledge graph triples, convert similar semantic information into the same relational expression, and delete redundant semantic information;
[0036] Step 7.4: Get the constraint domain knowledge graph triples.
[0037] Specifically, the vector similarity search module in Step 7.1 is as follows: a vector similarity matching algorithm based on cosine similarity is used to match similar pattern layer semantic information encoding vectors according to the open knowledge graph triple encoding vectors. If there are K similar relationships in the pattern layer, the K similar relationships replace the relationships in the open knowledge graph triples. If there are no similar relationships in the pattern layer, the triples are deleted to obtain the domain knowledge graph triples constrained by the pattern layer.
[0038] The beneficial effects of the present invention are: using adaptive feedback technology to solve the problems of poor understanding of domain expertise and inaccurate extraction of original corpus knowledge caused by the use of low-quality prompts in large language models, thereby enhancing the accuracy and reliability of knowledge graphs; using an inverse constraint method to solve the problems of limited embedding scale of the pattern layer with a large language model as the driving engine and small scope of domain constraints, thereby increasing the scale of the knowledge graph. 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 an automatic construction method of an inverse constraint knowledge graph based on adaptive feedback are as follows:
[0042] Step 1: Input the image and voice data into the OCR recognition module and the voice recognition module to obtain the text data to be processed;
[0043] Specifically, the texts input by experts in actual scenarios, such as "The iron-making process is essentially the process of reducing iron from its natural form - ore and other iron-containing compounds. The main iron-making methods include blast furnace method, direct reduction method, smelting reduction method, etc. The principle is that ore is subjected to physical and chemical reactions in a specific atmosphere (reducing substances CO, H2, C; suitable temperature, etc.) to obtain reduced pig iron.", recordings conveyed by experts, PDF images of iron smelting on the Internet, and internal corporate materials are converted into character data through the PaddleOCR recognition module and the PaddleSpeech voice recognition module, and redundancy and invalid characters are eliminated.
[0044] Step 2: Generate prompt examples based on predefined prompt templates and a small number of sample text data, and adaptively generate prompts using a large language model;
[0045] Specifically, the predefined prompt template "Please take {knowledge graph triple extraction} as the primary task, and describe in detail all the steps required to complete the task according to the task goal. Please give me different solutions, and all of them can complete the task goal." is used as the few-sample text data to generate the few-sample prompts of the large language model as the adaptive prompts. Prompt examples are generated according to the prompts.
[0046] Step 3: Based on the predefined feedback prompt template, the prompt feedback large language model evaluates the prompt sample and obtains the prompt score;
[0047] Specifically, the text: "You are an expert in the field of knowledge graphs. Please extract all existing triple information from the following text paragraph### according to each {prompt sample}, and present it in the form of [[prompt sample]: [subject, relationship, object]]. The rules are as follows: Please find all existing triples. There are no repeated triples, and the repetition judgment condition is [subject-relation same||relation-object same]. Analyze all potential triples, and the entities are not limited to text content. Compare the extracted [subject, relationship, object] with the text information to determine whether the [subject, relationship, object] generated by the {prompt sample} covers all the semantic information expressed by the text, including accuracy and completeness, and give a score of 0-10. Finally, give me feedback as [prompt sample]: [score]###." as a prompt feedback template and input the prompt feedback big language model, which generates a prompt score key-value pair.
[0048] Step 4: Sort each prompt example according to the score in the prompt score key-value pair, and take the prompt with the highest score as the optimal prompt.
[0049] Step 5: Based on the optimal prompt and the predefined extraction prompt template, the knowledge extraction large language model extracts the open knowledge graph triples;
[0050] Specifically, the optimal prompt and the predefined extraction prompt template are used as prompt rules and input into the knowledge extraction large language model. The knowledge extraction large language model extracts knowledge from the text data according to the prompt rule "You are an open knowledge graph triple extraction expert. Please extract all existing triple information from the following text paragraph ### according to each {prompt sample}, and present it in the form of [[prompt sample]: [subject, relationship, object]]. The rules are as follows: Please find all existing triples. There are no repeated triples, and the repetition judgment condition is [subject-relation is the same||relation-object is the same]. Analyze all potential triples, and entities are not limited to text content." to obtain open knowledge graph triples.
[0051] Step 6: Use the Transformer encoder to encode the open knowledge graph triples and the pattern layer text information to obtain the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector respectively;
[0052] Specifically, the Mistral-7B-V1.5 encoding model is used to encode the open knowledge graph triple to obtain the open knowledge graph triple encoding vector. The Mistral-7B-V1.5 encoding model is used to encode the pattern layer semantic information {relation semantic information} to obtain the pattern layer semantic information encoding vector.
[0053] Step 7: Use the vector similarity search module to match the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector to obtain the constraint domain knowledge graph triple and complete the knowledge graph construction;
[0054] Specifically, the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector are input into the vector similarity search module, and similar pattern layer semantic relationship vectors are matched according to the open knowledge graph triple vector based on cosine similarity. The threshold Top K = 5 is set, and the first 5 similar relationships replace the relationship in the open knowledge graph triple. If there is no similar relationship in the pattern layer, the triple is deleted to obtain the domain knowledge graph triple constrained by the pattern layer.
[0055] 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 an inverse constraint knowledge graph based on adaptive feedback, characterized in that: The specific steps are: Step 1: Input the image and voice data into the OCR recognition module and the voice recognition module to obtain the initial text input data; Step 2: Generate prompt examples based on predefined prompt templates and a small number of sample text data, and adaptively generate prompts using a large language model; Step 3: Based on the predefined feedback prompt template, the prompt feedback large language model evaluates the prompt sample and obtains the prompt score; Step 4: Sort the prompts according to the scores, and take the prompt with the highest score as the best prompt; Step 5: Based on the optimal prompt and the predefined extraction prompt template, the knowledge extraction large language model extracts the open knowledge graph triples; Step 6: Use the Transformer encoder to encode the open knowledge graph triples and the pattern layer text information to obtain the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector respectively; Step 7: Use the vector similarity search module to match the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector to obtain the constraint domain knowledge graph triple and complete the knowledge graph construction; The Step 7 is specifically as follows: Step 7.1: Input the open knowledge graph triple encoding vector and the pattern layer semantic information encoding vector into the vector similarity search module; Step 7.2: Set the threshold Top K and obtain the top K relationship semantic information based on the pattern layer semantic information; Step 7.3: Use the previous K relational semantic information as constraint rules to constrain the open knowledge graph triples, convert similar semantic information into the same relational expression, and delete redundant semantic information; Step 7.4: Get the constraint domain knowledge graph triples; The vector similarity search module in Step 7.1 is specifically: a vector similarity matching algorithm based on cosine similarity matches similar pattern layer semantic information encoding vectors according to the open knowledge graph triple encoding vectors. If there are K similar relationships in the pattern layer, the K similar relationships replace the relationships in the open knowledge graph triples. If there are no similar relationships in the pattern layer, the triples are deleted to obtain the domain knowledge graph triples constrained by the pattern layer.
2. According to claim 1, a method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback, characterized in that: The Step 1 is specifically as follows: Step 1.1: Process the original image data from the actual scene through the OCR recognition module to obtain the text data in the image; Step 1.2: Process the original speech data from the actual scene through the speech recognition module to obtain the text data in the speech; Step 1.3: Perform data cleaning on the text data in the image, the text data in the speech, and the data in the original text format to obtain initial text input data.
3. According to claim 1, the method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback is characterized in that: The Step 2 is specifically as follows: Step 2.1: Use the predefined generation prompt template as the adaptive prompt to generate the rule prompt of the large language model; Step 2.2: Use the few-shot text data as adaptive prompts to generate the few-shot prompts of the large language model; Step 2.3: Adaptive prompt generation The large language model generates prompt samples based on rule prompts and few-sample prompts.
4. The method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback according to claim 1, characterized in that: The Step 3 is specifically as follows: Step 3.1: Use the predefined feedback prompt template as the input prompt of the prompt feedback large language model; Step 3.2: The prompt feedback large language model generates a prompt sample score key-value pair based on the input prompt.
5. The method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback according to claim 1, characterized in that: Step 5 is as follows: Step 5.1: Use the optimal prompt and predefined extraction prompt template as prompt rules and input them into the knowledge extraction large language model; Step 5.2: Knowledge extraction The large language model extracts knowledge from the initial text input data according to the prompt rules to obtain open knowledge graph triples.
6. According to the method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback as described in claim 2, it is characterized in that: The data cleaning in the Step 1.3 is specifically as follows: converting the text data in the image, the text data in the speech, and the data in the original text format into character data, and then eliminating redundancy and invalid characters from the character data.
7. According to the method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback as described in claim 3, it is characterized in that: The prompt samples in Step 2.3 are specifically: M homogeneous prompts that guide the prompt feedback large language model to complete the task, where M is the number of prompt samples received under the prompt feedback large language model.
8. According to the method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback as described in claim 4, it is characterized in that: The prompt sample scoring key-value pair in Step 3.2 is specifically: the prompt feedback large language model scores the task results obtained from different prompt samples, and the prompt sample and the corresponding score form a key-value pair.
9. According to the method for automatically constructing an inverse constraint knowledge graph based on adaptive feedback as described in claim 5, it is characterized in that: The open knowledge graph triples in Step 5.2 are specifically: all triples that exist in the text data without rules and domain scope constraints.
Citation Information
Patent Citations
Military software defect multi-modal knowledge graph construction method, device and system
CN116860986A
Prompt word optimization method and system based on large language model
CN119047482A