Knowledge graph open domain construction and RAG question and answer method and device and storage medium

Through multi-path data processing and open domain information extraction of large language models, a complete knowledge graph is constructed, and the beam search strategy is used to perform RAG questions and answers, which solves the knowledge graph construction and multi-hop inference of existing systems under diverse entities and relationship types under different entities and relationship types. The problem of insufficient ability achieves more accurate Q&A results.

CN119416882APending Publication Date: 2025-02-11SHANDONG ZHIYANG SHANGSHUI INFORMATION TECH CO LTD
View PDF 0 Cites 14 Cited by

Patent Information

Application Number
CN202411451818.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-17
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

When the existing RAG question and answer system deals with diverse entities and relationship types, it is unable to build a complete knowledge graph, and its multi-hop reasoning ability is limited. Due to the influence of the retrieved irrelevant information, the answer is inaccurate.

Method used

A multi-path data processing strategy is adopted to parse unstructured text files, use a large language model to extract open domain information, obtain initial triplets, and filter and score through post-processing to build a complete knowledge graph. Based on the knowledge graph, a beam search strategy is used to generate inference chains and perform RAG questions and answers.

Benefits of technology

The knowledge graph construction under the situation of diversified entities and relationship types is realized, the multi-hop reasoning ability of the RAG question and answer system is enhanced, the impact of irrelevant information is reduced, and the accuracy of answers is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119416882A_ABST
    Figure CN119416882A_ABST
Patent Text Reader

Abstract

The invention provides a knowledge graph open domain construction and RAG question and answer method and device and a storage medium. The method comprises the steps of obtaining text content in a text file; performing text division on the text content to obtain text blocks; performing open domain information extraction on each text block by utilizing a large language model to obtain an initial triple; performing post-processing on the initial triad to obtain a post-processing triad for constructing the knowledge graph; constructing a knowledge graph according to the post-processing triple; the method for realizing RAG question answering based on the knowledge graph comprises the following steps: performing knowledge graph retrieval on a question to obtain a context related to the question, then constructing a question answering cue word by using the context and the question, and sorting out an answer to the question by a large language model based on the question answering cue word. According to the method, the problem that a complete knowledge graph cannot be obtained during defined domain knowledge graph construction in the face of diversified entities and relation types is solved, and the problems that RAG retrieval information is weak in correlation with problems and the multi-hop reasoning capability is limited are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of knowledge graph open domain construction and RAG question answering technology, and in particular to a knowledge graph open domain construction and RAG question answering method, device and storage medium. Background Art

[0002] Automatically building a knowledge graph is essential to structure data and make it accessible, allowing users to search for information efficiently. Knowledge graphs also facilitate insight, reasoning, and inference. Traditional natural language processing methods face limitations, including the use of predefined entity types and the need for supervised learning. Current research leverages the power of large language models for triple extraction, such as zero-shot or few-shot learning, and most still use limited domains. However, when faced with documents of various categories and huge content, it is impossible to predefine the categories of all entities and relations.

[0003] With the rapid development of artificial intelligence technology, intelligent question-answering systems are increasingly widely used in various fields. Among them, the question-answering system based on Retrieve and Generate (RAG) has become a hot topic of current research because it combines the advantages of information retrieval and natural language generation. However, existing RAG methods may retrieve information that is irrelevant to the question, which will introduce noise and mislead large language model question-answering. In addition, multi-hop questions require the model to perform multi-step reasoning to obtain the correct answer. When dealing with such questions, the existing RAG model is limited in its multi-hop reasoning ability due to the influence of the retrieved irrelevant information. Summary of the invention

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the present invention provides a knowledge graph open domain construction and RAG question answering method, device and storage medium.

[0005] In a first aspect, the present invention provides a knowledge graph open domain construction and RAG question answering method, comprising:

[0006] Adopting a multi-path data processing strategy, parsing and reading unstructured text files in a set format, and obtaining the text content in the text files;

[0007] The read text content is divided into text blocks; the open domain information of each text block is extracted using a large language model to obtain initial triples;

[0008] The initial triples are post-processed to obtain post-processed triples for constructing a knowledge graph; a knowledge graph is constructed based on the post-processed triples; and RAG question answering based on the knowledge graph includes: first, a knowledge graph search is performed on the question to obtain context related to the question, and then question and answer prompt words are constructed using the context and the question, and provided to a large language model, which compiles answers to the questions based on the question and answer prompt words.

[0009] Furthermore, a multi-path data processing strategy is adopted to parse and read an unstructured text file of a set format, and the text content in the text file includes:

[0010] Build a pdf file reader, a doc / docx file reader, and a txt file reader:

[0011] For any text file whose text content needs to be extracted, select the corresponding file reader according to the format suffix of the text file to obtain the text content;

[0012] Use rules to clean text content, remove noise data including page numbers, table titles, and figure titles, and standardize punctuation.

[0013] Furthermore, the read text content is divided into text blocks including:

[0014] First, determine the title of each part of the text content, and preliminarily divide the text blocks according to the scope of the text content summarized by each title;

[0015] It is determined whether the length of each initially divided text block exceeds a defined length threshold. If so, the initially divided text block is further divided according to punctuation marks, and the title information is added to the text block obtained by further division.

[0016] Furthermore, the process of extracting open domain information from each text block using the large language model to obtain the initial triples includes: traversing the obtained text blocks, constructing each text block into open domain information extraction prompt words, and the open domain information extraction prompt words include: open domain information extraction task instructions, extraction requirements, case descriptions, and text blocks that need to be subjected to open domain information extraction;

[0017] Under the constraint of the open domain information extraction prompt word, the large language model performs open domain information extraction on the text block that needs to be subjected to open domain information extraction in the open domain information extraction prompt word to obtain an initial triple.

[0018] Furthermore, the process of post-processing the initial triples to obtain post-processed triples for constructing the knowledge graph includes:

[0019] Build rules for filtering triples with irregular formats and merging head entities with the same tail entity relationship;

[0020] For each triple of text block, use rules to filter;

[0021] Construct scoring prompts for scoring triples. The scoring prompts include five parts: task instructions for scoring triples, scoring method steps, case description, text blocks for extracting triples, and triples;

[0022] For the triples processed by the rule, the scoring prompt words are used to control the large language model to score the triples;

[0023] Triples with scores lower than a predefined threshold are filtered out to obtain post-processed triples for constructing the knowledge graph.

[0024] Furthermore, the process of constructing a knowledge graph based on post-processing triples includes:

[0025] The file name of the text file is taken as a name entity, and a containment relationship is constructed between the name entity and all the head entities in the post-processing triples of the text content;

[0026] Define the categories to which all text files belong as category entities, and build inclusion relationships between the category entities and all name entities;

[0027] Use uuid to create ids for all head entities and tail entities;

[0028] Save all head entities, tail entities, and their IDs into a csv file;

[0029] Save all head entity IDs, tail entity IDs, and the relationship between head entities and tail entities into a csv file;

[0030] Import csv files into the graph database Neo4j in batches to obtain the knowledge graph.

[0031] Furthermore, the process of implementing RAG question answering based on knowledge graph includes:

[0032] First, perform a knowledge graph search on the question to obtain the context related to the question. The specific steps for performing a knowledge graph search on the question to obtain the context related to the question are as follows:

[0033] Initialize R empty inference chains;

[0034] Use the beam search strategy to iteratively perform the inference expansion operation of each inference chain until the maximum length limit of the inference chain is reached or the termination condition specified by the adaptive chain termination strategy is reached:

[0035] The way a large language model generates answers to questions based on reasoning chains includes:

[0036] (1) Directly use the inference chain as context, then use the context and question to construct question-answering prompts and provide them to the large language model. The large language model then sorts out the answers to the questions based on the question-answering prompts.

[0037] (2) Use reasoning chains to identify text blocks that are useful for answering questions, and then use these text blocks as context: retrieve the text block to which each triple in the reasoning chain belongs, where each triple in the reasoning chain casts a vote for the text block that generated it, and rank the text blocks according to the number of votes received; select the text block with the highest ranking as the context; then use the context and the question to construct question and answer prompts, and provide them to the large language model. The large language model organizes the answer to the question based on the question and answer prompts.

[0038] Furthermore, the beam search strategy is used to iteratively perform the inference expansion operation of each inference chain until the maximum length limit of the inference chain is reached or the termination condition specified by the adaptive chain termination strategy is reached:

[0039] Use the dual encoder model to calculate the relevance score of each triple in the question and the knowledge graph, and select the top K triples with the highest scores as the candidate triple set

[0040] Each candidate triple in the candidate triple set is taken as an option; based on the context of the candidate triple and the question, a large language model is used to generate a score for each candidate triple; the score is converted into a probability using a softmax function;

[0041] Select the top P triples with the highest scores from the candidate triples in the candidate triple set; for each selected triple, add it to the current reasoning chain, and calculate the probability of the reasoning chain after adding the triple;

[0042] Based on the beam search strategy, the top R reasoning chains with the highest probability are selected from all the generated new reasoning chains as the candidate reasoning chain set for the next step.

[0043] In the second aspect, the present invention provides a knowledge graph open domain construction and RAG question-answering device, including: at least one processing unit, the processing unit is connected to a storage unit via a bus unit, the storage unit stores a computer program, and when the computer program is executed by the processing unit, it implements the knowledge graph open domain construction and RAG question-answering method.

[0044] In a third aspect, the present invention provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the knowledge graph open domain construction and RAG question-answering method.

[0045] The above technical solution provided by the embodiment of the present invention has the following advantages compared with the prior art:

[0046] The present invention proposes a knowledge graph open domain construction and RAG question-answering method, which includes the following steps: adopting a multi-path data processing strategy to parse and read an unstructured text file in a set format to obtain text content in the text file; performing text segmentation on the read text content to obtain text blocks; using a large language model to extract open domain information from each text block to obtain initial triples; post-processing the initial triples to obtain post-processed triples for constructing a knowledge graph; constructing a knowledge graph based on the post-processed triples; and implementing RAG question-answering based on the knowledge graph includes: firstly performing a knowledge graph search for a question to obtain a context related to the question, and then using the context and the question to construct a question-answering prompt word, which is provided to the large language model, and the large language model sorts out an answer to the question based on the question-answering prompt word.

[0047] The present invention utilizes a large language model to extract open domain information from each text block to obtain initial triples; extracts triples through optimized open domain information extraction prompt words, scores triples based on optimized scoring prompt words, and performs filtering and post-processing using rules and scoring results, thereby avoiding the limitations of limited domain knowledge graph construction in defining entity and relationship categories, and obtaining a more complete and standardized knowledge graph through the open domain.

[0048] The present invention uses a beam search strategy to generate R reasoning chains, and uses the reasoning chain as context, or retrieves the text block most relevant to the question based on the reasoning chain as context, to solve the problem that the information of traditional RAG retrieval is weakly relevant to the question and the multi-hop reasoning ability is limited.

[0049] The present invention solves the problem that limited domain knowledge graph construction cannot obtain a complete knowledge graph when faced with diverse entity and relationship types, as well as the problem that the information retrieved by traditional RAG has weak relevance to the question and limited multi-hop reasoning capability. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and, together with the description, serve to explain the principles of the invention.

[0051] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0052] Figure 1 A flowchart of the knowledge graph open domain construction and RAG question-answering method provided in the embodiment of the present application;

[0053] Figure 2 A flowchart of dividing the read text content into text blocks to obtain text blocks provided in an embodiment of the present application;

[0054] Figure 3 The large language model provided in the embodiment of the present application uses the large language model to extract open domain information from each text block in the first stage to obtain a flowchart of the initial triples;

[0055] Figure 4 A flowchart of post-processing the initial triples provided in the embodiment of the present application to obtain post-processed triples for constructing a knowledge graph;

[0056] Figure 5 A flowchart of constructing a knowledge graph based on post-processing triples provided in an embodiment of the present application;

[0057] Figure 6 A flowchart for implementing RAG question-answering based on a knowledge graph provided in an embodiment of the present application;

[0058] Figure 7 The flowchart provided in the embodiment of the present application first performs a knowledge graph search for a question to obtain a context related to the question;

[0059] Figure 8 Schematic diagram of the knowledge graph open domain construction and RAG question-answering device provided in the embodiment of the present application. DETAILED DESCRIPTION

[0060] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0061] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0062] Example 1

[0063] like Figure 1 As shown, the present invention provides a knowledge graph open domain construction and RAG question answering method, including:

[0064] In step S1, a multi-path data processing strategy is adopted to parse and read an unstructured text file of a set format to obtain the text content in the text file; in the specific implementation process, the unstructured text file of the set format includes pdf, doc / docx, and txt. In order to be able to obtain text content from text files of various formats, three file readers are constructed:

[0065] (1) PDF file reader: Use pdfplumber in the Python library to parse PDF text files and extract text content. If there is a table on the page of the text file, exclude the table data based on the position information of the table in the text and extract the text content;

[0066] (2) doc / docx file reader: Use the docxunstructured.partition.common Python library to parse doc / docx text files and extract text content;

[0067] (3) TXT file reader: directly use Python's read command to read the text content in TXT files;

[0068] For any text file whose text content needs to be extracted, select the corresponding file reader according to the format suffix of the text file to obtain the text content;

[0069] Use rules to clean text content, remove noise data including page numbers, table titles, and figure titles, and standardize punctuation.

[0070] In step S2, the read text content is segmented to obtain text blocks. Figure 2 As shown, the process includes:

[0071] First, determine the title of each part of the text content, and preliminarily divide the text blocks according to the scope of the text content summarized by each title;

[0072] Determine whether the length of each initially divided text block exceeds the defined length threshold. If so, continue to split the initially divided text block according to punctuation marks, and add the title information to the text block obtained by further splitting. If not, add the title information to the obtained text block.

[0073] In step S3, the large language model is used to extract open domain information from each text block to obtain initial triples, such as Figure 3 As shown, the process includes: traversing the acquired text blocks, constructing each traversed text block into an open domain information extraction prompt word, wherein the open domain information extraction prompt word includes: open domain information extraction task instructions, extraction requirements, case descriptions, and text blocks that need to be subjected to open domain information extraction; in the specific implementation process, the open domain information extraction prompt word indicates that the large language model extracts all head entities, the tail entities corresponding to the head entities, and the relationship between the paired head entities and the tail entities from the text blocks that need to be subjected to open domain information extraction.

[0074] Under the constraint of the open domain information extraction prompt word, the large language model performs open domain information extraction on the text block that needs to be subjected to open domain information extraction in the open domain information extraction prompt word to obtain an initial triple.

[0075] In step S4, the initial triples are post-processed to obtain post-processed triples for constructing the knowledge graph. Figure 4 As shown, the process includes:

[0076] Construct rules for filtering triples with irregular formats and merging tail entities with the same head entity and relationship; use rules to filter the triples of each text block;

[0077] Construct scoring prompts for scoring triples. The scoring prompts include five parts: task instructions for scoring triples, scoring method steps, case description, text blocks for extracting triples, and triples;

[0078] For the triples processed by the rules, the scoring prompt words are used to control the large language model to score the triples; the purpose is to evaluate the correlation between the text blocks extracted from the triples and the triples through the large language model, and the higher the correlation, the more points are awarded.

[0079] Triples with scores lower than a predefined threshold are filtered out to obtain post-processed triples for constructing the knowledge graph.

[0080] In step S5, a knowledge graph is constructed based on the post-processed triples, such as Figure 5As shown, the process includes:

[0081] The file name of the text file is taken as a name entity, and a containment relationship is constructed between the name entity and all the head entities in the post-processing triples of the text content;

[0082] Define the categories to which all text files belong as category entities, and build inclusion relationships between the category entities and all name entities;

[0083] Use uuid to create ids for all head entities and tail entities;

[0084] Save all head entities, tail entities, and their IDs into a csv file;

[0085] Save all head entity IDs, tail entity IDs, and the relationship between head entities and tail entities into a csv file;

[0086] Import csv files into the graph database Neo4j in batches to obtain the knowledge graph.

[0087] In step S6, implementing RAG question answering based on the knowledge graph includes: first, performing a knowledge graph search for the question to obtain the context related to the question, and then using the context and the question to construct question and answer prompt words, which are provided to the large language model. The large language model organizes the answer to the question based on the question and answer prompt words.

[0088] like Figure 6 As shown, the process of implementing RAG question answering based on knowledge graph includes:

[0089] First, perform a knowledge graph search on the question to obtain the context related to the question. Figure 7 As shown, the specific steps are as follows:

[0090] Initialize R empty inference chains;

[0091] Use the beam search strategy to iteratively perform the reasoning expansion operation of each reasoning chain until the maximum length limit of the reasoning chain is reached or the termination condition specified by the adaptive chain termination strategy is reached. The process includes:

[0092] Select candidate triples: Use the dual encoder model to calculate the relevance score of each triple in the question and knowledge graph, and select the top K triples with the highest relevance scores as the candidate triple set

[0093] The task is formulated as a multiple-choice question, where each candidate triple in the candidate triple set is considered as an option. Based on the candidate triple and the context of the question, a large language model is used to generate a score for each candidate triple, and a softmax function is used to convert the score into a probability.

[0094] Update the inference chain: Select the first P triples with the highest scores from the candidate triples in the candidate triple set; for each selected triple, add it to the current inference chain, and calculate the probability of the inference chain after adding the triple, which is equal to the original inference chain probability multiplied by the probability of the newly added triple; based on the beamsearch strategy, select the first R inference chains with the highest probability from all the generated new inference chains as the candidate inference chain set for the next step. In this way, after iteration, the R inference chains with the highest probability are finally output as the final inference chain set.

[0095] The way a large language model generates answers to questions based on reasoning chains includes:

[0096] (1) Directly use the inference chain as context, then use the context and question to construct question-answering prompts and provide them to the large language model. The large language model sorts out the answer to the question based on the question-answering prompts.

[0097] (2) Use reasoning chains to identify text blocks that are useful for answering questions, and then use these text blocks as context: retrieve the text block to which each triple in the reasoning chain belongs, where each triple in the reasoning chain casts a vote for the text block that generated it, and rank the text blocks according to the number of votes received; select the text block with the highest ranking as the context; then use the context and the question to construct question and answer prompts, and provide them to the large language model. The large language model organizes the answer to the question based on the question and answer prompts.

[0098] An exemplary adaptive chain termination strategy is to increase the number of triples in a decreasing manner. If the number of triples reaches zero, indicating that the reasoning chain is sufficient to answer the question, no new triples will be added to the reasoning chain and it will be marked as completed.

[0099] Example 2

[0100] like Figure 8 As shown, an embodiment of the present invention provides a knowledge graph open domain construction and RAG question-answering device, including: at least one processing unit, the processing unit is connected to a storage unit through a bus unit, the storage unit stores a computer program, and the processing unit executes the computer program to implement the knowledge graph open domain construction and RAG question-answering method, including:

[0101] Adopting a multi-path data processing strategy, parsing and reading unstructured text files in a set format, and obtaining the text content in the text files;

[0102] The read text content is divided into text blocks; the open domain information of each text block is extracted using a large language model to obtain initial triples;

[0103] The initial triples are post-processed to obtain post-processed triples for constructing a knowledge graph; a knowledge graph is constructed based on the post-processed triples; and RAG question answering based on the knowledge graph includes: first, a knowledge graph search is performed on the question to obtain context related to the question, and then question and answer prompt words are constructed using the context and the question, and provided to a large language model, which compiles answers to the questions based on the question and answer prompt words.

[0104] Of course, the computer program stored in the storage unit of the knowledge graph open domain construction and RAG question-answering device provided in the embodiment of the present invention is not limited to the method operations described above, and can also execute related operations in the knowledge graph open domain construction and RAG question-answering method provided in any embodiment of the present invention.

[0105] Example 3

[0106] An embodiment of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a host computer and a hardware-in-the-loop simulation test platform, the knowledge graph open domain construction and RAG question-answering method are implemented, including:

[0107] Adopting a multi-path data processing strategy, parsing and reading unstructured text files in a set format, and obtaining the text content in the text files;

[0108] The read text content is divided into text blocks; the open domain information of each text block is extracted using a large language model to obtain initial triples;

[0109] The initial triples are post-processed to obtain post-processed triples for constructing a knowledge graph; a knowledge graph is constructed based on the post-processed triples; and RAG question answering based on the knowledge graph includes: first, a knowledge graph search is performed on the question to obtain context related to the question, and then question and answer prompt words are constructed using the context and the question, and provided to a large language model, which compiles answers to the questions based on the question and answer prompt words.

[0110] A computer-readable storage medium provided in an embodiment of the present invention stores a computer program which is not limited to the method operations described above, but can also execute related operations in a knowledge graph open domain construction and RAG question-answering method provided in any embodiment of the present invention.

[0111] In the embodiments provided by the present invention, it should be understood that the disclosed methods, devices and storage media can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the description division of the circuit is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling shown or discussed can be indirect coupling through some interfaces, devices or units, which can be electrical, mechanical or other forms.

[0112] The foregoing is merely a specific embodiment of the present invention, which enables those skilled in the art to understand or implement the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features claimed herein.

Claims

1. A knowledge graph open domain construction and RAG question answering method, characterized in that: include: Adopting a multi-path data processing strategy, parsing and reading unstructured text files in a set format, and obtaining the text content in the text files; The read text content is divided into text blocks; the open domain information of each text block is extracted using a large language model to obtain initial triples; Post-process the initial triples to obtain post-processed triples for constructing the knowledge graph; Build a knowledge graph based on the post-processed triples; implement RAG question answering based on the knowledge graph, including: first, search the knowledge graph for the question to obtain the context related to the question, then use the context and the question to build question and answer prompt words, and provide them to the large language model. The large language model organizes the answer to the question based on the question and answer prompt words.

2. The knowledge graph open domain construction and RAG question answering method according to claim 1, characterized in that: A multi-path data processing strategy is adopted to parse and read unstructured text files in a set format, and the text contents in the text files include: Build a pdf file reader, a doc / docx file reader, and a txt file reader: For any text file whose text content needs to be extracted, select the corresponding file reader according to the format suffix of the text file to obtain the text content; Use rules to clean text content, remove noise data including page numbers, table titles, and figure titles, and standardize punctuation.

3. According to the knowledge graph open domain construction and RAG question answering method of claim 1, it is characterized in that: The read text content is divided into text blocks including: First, determine the title of each part of the text content, and preliminarily divide the text blocks according to the scope of the text content summarized by each title; It is determined whether the length of each initially divided text block exceeds a defined length threshold. If so, the initially divided text block is further divided according to punctuation marks, and the title information is added to the text block obtained by further division.

4. The knowledge graph open domain construction and RAG question answering method according to claim 1, characterized in that: The process of extracting open domain information from each text block using a large language model to obtain an initial triplet includes: traversing the obtained text blocks, constructing each text block into an open domain information extraction prompt word, and the open domain information extraction prompt word includes: open domain information extraction task instructions, extraction requirements, case descriptions, and text blocks that need to be subjected to open domain information extraction; Under the constraint of the open domain information extraction prompt word, the large language model performs open domain information extraction on the text block that needs to be subjected to open domain information extraction in the open domain information extraction prompt word to obtain an initial triple.

5. The knowledge graph open domain construction and RAG question answering method according to claim 1, characterized in that: The process of post-processing the initial triples to obtain post-processed triples for constructing the knowledge graph includes: Build rules for filtering triples with irregular formats and merging head entities with the same tail entity relationship; For each triple of text block, use rules to filter; Construct scoring prompts for scoring triples. The scoring prompts include five parts: task instructions for scoring triples, scoring method steps, case description, text blocks for extracting triples, and triples; For the triples processed by the rule, the scoring prompt words are used to control the large language model to score the triples; Triples with scores lower than a predefined threshold are filtered out to obtain post-processed triples for constructing the knowledge graph.

6. The knowledge graph open domain construction and RAG question answering method according to claim 1, characterized in that: The process of constructing a knowledge graph based on post-processing triples includes: The file name of the text file is taken as a name entity, and a containment relationship is constructed between the name entity and all the head entities in the post-processing triples of the text content; Define the categories to which all text files belong as category entities, and build inclusion relationships between the category entities and all name entities; Use uuid to create ids for all head entities and tail entities; Save all head entities, tail entities, and their IDs into a csv file; Save all head entity IDs, tail entity IDs, and the relationship between head entities and tail entities into a csv file; Import csv files into the graph database Neo4j in batches to obtain the knowledge graph.

7. The knowledge graph open domain construction and RAG question answering method according to claim 1, characterized in that: The process of implementing RAG question answering based on knowledge graph includes: First, perform a knowledge graph search on the question to obtain the context related to the question. The specific steps for performing a knowledge graph search on the question to obtain the context related to the question are as follows: Initialize R empty inference chains; Use the beam search strategy to iteratively perform the inference expansion operation of each inference chain until the maximum length limit of the inference chain is reached or the termination condition specified by the adaptive chain termination strategy is reached: The way a large language model generates answers to questions based on reasoning chains includes: (1) Directly use the inference chain as context, then use the context and question to construct question-answering prompts and provide them to the large language model. The large language model sorts out the answer to the question based on the question-answering prompts. (2) Use reasoning chains to identify text blocks that are useful for answering questions, and then use these text blocks as context: retrieve the text block to which each triple in the reasoning chain belongs, where each triple in the reasoning chain casts a vote for the text block that generated it, and rank the text blocks according to the number of votes received; select the text block with the highest ranking as the context; then use the context and the question to construct question and answer prompts, and provide them to the large language model. The large language model organizes the answer to the question based on the question and answer prompts.

8. The knowledge graph open domain construction and RAG question answering method according to claim 7, characterized in that: Use the beamsearch strategy to iteratively perform the inference expansion operation of each inference chain until the maximum length limit of the inference chain is reached or the termination condition specified by the adaptive chain termination strategy is reached: Use the dual encoder model to calculate the relevance score of each triple in the question and the knowledge graph, and select the top K triples with the highest scores as the candidate triple set Each candidate triple in the candidate triple set is considered as an option; based on the context of the candidate triple and the question, a score for each candidate triple is generated using a large language model; Use the softmax function to convert the scores into probabilities; Select the top P triples with the highest scores from the candidate triples in the candidate triple set; for each selected triple, add it to the current reasoning chain, and calculate the probability of the reasoning chain after adding the triple; Based on the beam search strategy, the top R reasoning chains with the highest probability are selected from all the generated new reasoning chains as the set of candidate reasoning chains for the next step.

9. A knowledge graph open domain construction and RAG question-answering device, characterized in that: include: At least one processing unit, the processing unit is connected to a storage unit via a bus unit, the storage unit stores a computer program, and when the computer program is executed by the processing unit, a knowledge graph open domain construction and RAG question answering method as described in any one of claims 1-8 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, it implements the knowledge graph open domain construction and RAG question-answering method as described in any one of claims 1 to 8.

Citation Information

Cited By

  • Fine adjustment method and device for large model in vertical field and medium

    CN120069098A

  • Knowledge graph construction method and device and medium

    CN120104608A

  • Multi-path thinking chain reasoning generation method based on fine-grained knowledge retrieval

    CN120297425A

  • A multi-path thinking chain reasoning generation method based on fine-grained knowledge retrieval

    CN120297425B

  • Customer service question and answer processing method and device

    CN120353902A