A domain knowledge graph automatic construction method based on a large language model and prompt engineering

By combining large language models with prompting engineering, domain knowledge graphs are automatically constructed, solving the problems of high cost and low accuracy of manual annotation in traditional methods. This achieves efficient and accurate knowledge graph construction, which is suitable for automated construction in specific domains.

CN117035076BActive Publication Date: 2026-02-17KUNMING UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310965763.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-08-02
Publication Date
2026-02-17
Estimated Expiration
2043-08-02

AI Technical Summary

Technical Problem

Traditional knowledge graph construction methods rely on manual annotation, which is costly, inaccurate, and incomplete. Furthermore, large language models struggle to construct high-precision and highly complete domain knowledge graphs and cannot track updates to domain knowledge in real time.

Method used

By leveraging large language models and prompting engineering, and through retrieval-enhanced generative models and a role-playing framework, combined with Wikipedia data, a domain knowledge graph is automatically constructed. This includes task requirement encoding, document indexing, contextual information extraction, event extraction, and mind tree chain prompts, generating a high-precision and highly complete knowledge graph.

Benefits of technology

It enables efficient and accurate construction of domain knowledge graphs, reduces manual costs, and improves the accuracy and completeness of knowledge graphs, making it suitable for automated construction in specific domains.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117035076B_ABST
    Figure CN117035076B_ABST
Patent Text Reader

Abstract

The application relates to a field knowledge graph automatic construction method based on a large language model and a prompt engineering, and belongs to the natural language processing field. First, task requirements and Wikipedia documents are input into a retriever of a retrieval enhancement generation model to be encoded to obtain document indexes most relevant to the task requirements; after relevant documents are found according to the obtained document indexes, the relevant documents and the task requirements are input into a generator of the retrieval enhancement generation model to obtain context information combined with the two, and then key events are acquired; finally, a large language model performs event extraction on the context information; the events are input into a Role-Playing framework in a thinking tree chain prompt mode, an automatic feedback process of the large language model is performed, and text data for constructing a field knowledge graph is generated; and finally, data cleaning is performed on the feedback text data to obtain a final field knowledge graph. The application can efficiently, accurately and automatically construct a knowledge graph.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a field knowledge graph automatic construction method based on a large language model and prompt engineering, and belongs to the field of natural language processing. BACKGROUND

[0002] A field knowledge graph describes concepts, entities and their relationships in a specific field of the objective world in a structured manner, represents field professional knowledge in a form closer to human cognition of the world, and provides an ability to better organize, manage and understand professional field information. Therefore, it is necessary to construct a field knowledge graph in various fields. However, a traditional knowledge graph construction method mainly relies on manual annotation and expert knowledge manual arrangement, and often cannot efficiently extract entities, attributes and relationships from texts, which limits the speed and scale of field knowledge graph construction. A large language model can effectively reduce the cost of manually constructing a field knowledge graph, and can improve the accuracy and completeness of the knowledge graph. Therefore, a field knowledge graph construction method based on a large language model has become a key research content in the field of natural language processing.

[0003] The automatic construction of a field knowledge graph based on a large language model faces a series of problems such as low data quality, poor understanding of field professional knowledge, unclear structuring and difficult semantic representation. In view of the continuous updating and evolution of field knowledge, the automatic construction method of the field knowledge graph is difficult to track the latest information and associations based on the large language model in real time, which poses a challenge to the automatic construction of the field knowledge graph. The introduction of prompt engineering can effectively guide the model to generate consistent descriptions and relationships with the knowledge graph, and improve the construction accuracy and completeness of the large language model for the field knowledge graph. However, as a general model, the large language model cannot construct a field knowledge graph with high precision and high completeness in a specific field, and developers cannot effectively use prompts as input instructions for the large language model. Therefore, how to use prompt engineering to make the large language model construct a field knowledge graph with high precision and high completeness is a technical problem to be solved at present. SUMMARY

[0004] The technical problem to be solved by the application is to provide a field knowledge graph automatic construction method based on a large language model and prompt engineering, so as to solve the problems of high manual construction cost, low precision and poor completeness of the traditional knowledge graph construction method, and realize efficient, accurate and automatic construction of the knowledge graph.

[0005] The technical scheme of the present application is: a domain knowledge graph automatic construction method based on a large language model and a prompt engineering, task requirements and Wikipedia documents are input into the retriever of a retrieval enhancement generation model for coding to obtain the most relevant document index to the task requirements; after finding the relevant documents according to the obtained document index, the documents and the task requirements are input into the generator of the retrieval enhancement generation model to obtain the context information combined with the two, and then the key events are obtained, finally the large language model performs event extraction on the context information; the events are input into the Role-Playing framework in a thought tree chain prompt mode, an automatic feedback process of the large language model is performed, and text data for constructing the domain knowledge graph is generated.

[0006] The specific steps are:

[0007] Step 1: The task requirements and Wikipedia documents are input into the retriever of the retrieval enhancement generation model for coding to obtain the most relevant document index to the task requirements.

[0008] Step 2: After finding the relevant documents according to the obtained document index, the documents and the task requirements are input into the generator of the retrieval enhancement generation model to obtain the context information combined with the two, and then the key events are obtained, and the context information is extracted by the large language model.

[0009] The key events are specifically: the triplets of entities-relation-entities formed in the text data.

[0010] Step 3: The events are input into the Role-Playing framework in a thought tree chain prompt mode, an automatic feedback process of the large language model is performed, and text data for constructing the domain knowledge graph is generated.

[0011] Step 4: The feedback text data is cleaned to obtain the final domain knowledge graph.

[0012] The Step 1 is specifically:

[0013] Step 1.1: The task requirements are input as the retriever of the retrieval enhancement generation model, and the BERT model encodes the task requirements into a task requirement index.

[0014] Step 1.2: The Wikipedia data is input as the retriever of the retrieval enhancement generation model, and the BERT model encodes the Wikipedia data into an initial document index.

[0015] Step 1.3: The most matched document to the task requirement index is found by maximum inner product search to generate a document index.

[0016] The maximum inner product is specifically calculated as:

[0017]

[0018] In the formula, x represents the encoded sequence of the task requirements, z represents the encoded sequence of the Wikipedia document, and Q(x) represents the question index. This is represented as the original document index. This represents the approximate solution probability of the question index and the document index, and the top K results are approximated using the TopK algorithm. Recorded as The output most relevant to Q(x)

[0019] Step 2 specifically refers to:

[0020] Step 2.1: The document and task requirements are used as input to the retrieval enhancement generative model generator. The BART model encodes and decodes the document and task requirements, and finally marginalizes them.

[0021] Marginalization specifically involves encoding each basic text unit (word vector) after the data is encoded, and then using different documents when predicting each token.

[0022] Step 2.2: Generate text data related to task requirements.

[0023] Step 2.3: Use the text data as input to the large language model, which will extract events from the data to obtain the relevant entities needed to build the knowledge graph.

[0024] Step 3 specifically refers to:

[0025] Step 3.1: Decompose the event into a mind tree chain as a timely reminder for the Role-Playing framework.

[0026] Step 3.2: Set the role type, kernel sampling, and feedback format of the selected large language model to the optimal values.

[0027] Step 3.3: Use the configured large language model as the main body of the dialogue feedback process to participate in the dialogue feedback process of automatic construction of the domain knowledge graph, and obtain all the text data required for constructing the domain knowledge graph generated during the feedback process.

[0028] In Step 4, data cleaning specifically involves:

[0029] Step 4.1: Extract characters from the valid part of the text data to obtain valid data.

[0030] Step 4.2: Convert the format of the valid data and save it as a CSV file.

[0031] The effective part in Step4.1 is specifically: the part conforming to the control output format instruction in the original input.

[0032] The beneficial effects of the present application are: using a large language model as the recognition subject of entities and relations enhances the recognition ability of events contained in the input text; adapting the general model to a specific field, and using Wikipedia as the data set for retrieval to enhance the context information generated by the model, enhances the integrity of the knowledge graph; using a thought tree chain thought prompt as a timely prompt for automatic construction of a knowledge graph enhances the accuracy of the large model in constructing the knowledge graph; using a Role-Playing framework as the main body of automatic construction, the dialog feedback process can be applied to the automatic construction of the domain knowledge graph, reducing the cost of manual construction. BRIEF DESCRIPTION OF DRAWINGS

[0033] Figure 1 is a step flowchart of the present application;

[0034] Figure 2 is a schematic diagram of the entity part required for constructing the knowledge graph of the present application;

[0035] Figure 3 is a schematic diagram of the knowledge graph constructed by the present application. DETAILED DESCRIPTION

[0036] The present application will be further described below in conjunction with the drawings and specific embodiments.

[0037] Embodiment 1: as shown, an automatic construction method of a domain knowledge graph based on a large language model and a prompt engineering, the specific steps are: Figure 1

[0038] Step 1: taking the task requirement: “constructing a domain knowledge graph of the metal tin forging process” as the input of the retrieval enhancement generation model retriever, the BERT model encodes the task requirement into a problem index, and at the same time, takes the Wikipedia data as the input of the retrieval enhancement generation model retriever, the BERT model encodes the Wikipedia data into an initial document index. Finally, the two indexes are combined into a final document index by approximately calculating the maximum inner product according to the following formula.

[0039]

[0040] ​Step2: The documents obtained according to the document index in Step1 and the task requirements are taken as the input of the retrieval enhancement generation model generator, and the BART model encodes and decodes the documents and the task requirements. After encoding the data, each basic unit of text (word vector) is encoded as token. Different documents are used to predict each token, and text data related to the task requirements is generated. The text data is taken as the input of the large language model, and the large language model performs event extraction on the data to finally generate related entities required for constructing the knowledge graph, such as Figure 2 as shown.

[0041] Step3: First, the event is chain-decomposed as a Role-Playing framework prompt. Second, the role type of the selected large language model is set to user and domain expert, the nuclear sampling temperature is set to 0 to ensure minimum randomness, the feedback format is set to JSON format, and the large language model type is set to gpt3.5-turbo. Finally, the set large language model is taken as the main body of the dialogue feedback process, participates in the dialogue feedback process of the automatic construction of the domain knowledge graph, and obtains all the text data generated in the feedback process.

[0042] Step4: First, the JSON format part of the text data in Step3 is character extracted to obtain the effective data in JSON format required for constructing the domain knowledge graph of metal tin forging. Second, the effective data is format-converted and saved as a csv file. Finally, the Neo4j graph database is imported to complete the visualization of the knowledge graph as Figure 3 as shown.

[0043] The specific embodiments of the present application are described in detail in combination with the drawings, but the present application is not limited to the above embodiments. Within the knowledge possessed by those skilled in the art, various changes can be made without departing from the purpose of the present application.

Claims

1. A method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering, characterized in that: Step 1: Input the task requirements and Wikipedia documents into the retrieval engine of the retrieval enhancement generative model for encoding, and obtain the document index most relevant to the task requirements; Step 2: After finding relevant documents based on the obtained document index, input them and the task requirements into the generator of the retrieval enhancement generation model to obtain contextual information combining the two, thereby obtaining key events, and extracting events from the contextual information through a large language model; Step 3: Input the events into the Role-Playing framework using a mind tree chain prompt method, and perform an automatic feedback process of the large language model to generate text data for constructing a domain knowledge graph; Step 4: Clean the feedback text data to obtain the final domain knowledge graph; Step 3 specifically refers to: Step 3.1: Decompose the event into a mind tree chain as a timely reminder for the Role-Playing framework; Step 3.2: Set the role type, kernel sampling, and feedback format of the selected large language model to the optimal values; Step 3.3: Use the configured large language model as the main body of the dialogue feedback process to participate in the dialogue feedback process of automatic construction of domain knowledge graph, and obtain all the text data required for constructing domain knowledge graph generated during the feedback process; The key event in Step 2 is to construct entity-relation-entity triples in the text data.

2. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 1, characterized in that, Step 1 specifically refers to: Step 1.1: The task requirements are used as the retrieval input of the retrieval enhancement generative model. The BERT model encodes the task requirements into a task requirement index. Step 1.2: Use Wikipedia data as the retrieval input for the retrieval augmentation generative model. The BERT model encodes the Wikipedia data into an initial document index. Step 1.3: Find the documents that best match the index requirements of the task by using maximum inner product search, and generate the document index.

3. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 1, characterized in that, Step 2 specifically includes: Step 2.1: The document and task requirements are used as input to the retrieval enhancement generative model generator. The BART model encodes and decodes the document and task requirements, and finally marginalizes them. Step 2.2: Generate text data related to task requirements; Step 2.3: Use the text data as input to the large language model, which will extract events from the data to obtain the relevant entities needed to build the knowledge graph.

4. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 1, characterized in that, In Step 4, data cleaning specifically involves: Step 4.1: Extract characters from the valid part of the text data to obtain valid data; Step 4.2: Convert the format of the valid data and save it as a CSV file.

5. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 2, characterized in that, The calculation of the maximum inner product in Step 1.3 is as follows: ; In the formula, x This is represented as a coded sequence of task requirements. z Represented as the encoded sequence of a Wikipedia document. Indicates the problem index. Represented as the original document index; This represents the approximate solution probability of the question index and the document index, and the top K results are approximated using the Top K algorithm. , recorded as Output and Most relevant .

6. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 4, characterized in that, The valid part in Step 4.1 is specifically the part that conforms to the control output format instructions in the original input.

7. The method for automatically constructing a domain knowledge graph based on a large language model and prompting engineering as described in claim 3, characterized in that, In Step 2.1, marginalization specifically involves encoding each basic text unit as a token after encoding the data, and using different documents when predicting each token.

Citation Information

Patent Citations

  • Knowledge graph construction method for military equipment

    CN111309925A

  • Knowledge question and answer retrieval method and device based on tourism domain knowledge graph

    CN111353030A