Intelligent question answering method, device and storage medium integrating knowledge graph and large model
By obtaining knowledge paths based on search strategies for similar problems in the knowledge graph, and combining answer generation large models for logical reasoning, the problems of inaccurate information generation, prone to hallucinations and high computing costs in the existing technology are solved, and more accurate and reliable intelligent question-and-answer results are achieved.
Patent Information
- Application Number
- CN202510175026.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2045-02-18
AI Technical Summary
The existing search enhancement generation technology has shortcomings in the problems of inaccurate information generation, prone to hallucinations and high computing costs.
By obtaining the original questions to be answered, entity extraction and question rewriting are performed, searching in the knowledge graph based on a search strategy that integrates similar questions, obtaining knowledge paths, and using answer generation large models to combine knowledge for logical reasoning to generate predicted answers. At the same time, the authenticity of the predicted answer is detected and filtered to generate the target answer.
It realizes the acquisition of the most relevant information from the knowledge graph to guide answer generation, reduces the possibility that the answer generation model will generate false or irrelevant information, reduces the calculation cost, and improves the credibility and accuracy of the answers.
Smart Images

Figure CN119669428B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing technology, and in particular to an intelligent question-answering method, device and storage medium that integrates a knowledge graph and a large model. Background Art
[0002] In Retrieval-augmented Generation (RAG), existing technologies usually use similarity-based methods to extract some of the most relevant knowledge from the knowledge base as context to supplement the internal knowledge of the large model to avoid hallucinations and improve accuracy. However, the information of multiple channels retrieved by these similarity-based methods is isolated. If this information cannot be integrated, it will not be possible to achieve the ideal effect when dealing with multi-hop problems.
[0003] As a graph structure, knowledge graph uses vertices and edges to represent entities and the relationship between entities, which can well represent the complex network relationship between entities. In the question-answering task based on knowledge graph, the existing technology usually first uses a large model to extract key entities from the question, uses it as a starting point, starts searching in the knowledge graph, and then repeatedly calls the large model to determine whether the searched information is valid and whether it can answer the question, and then decides which path to follow and whether to continue searching.
[0004] However, when searching the knowledge graph, since fewer factors are included when considering the relevance of information, the most relevant information cannot be obtained from a large number of paths, resulting in inaccurate answer information generated by the large model; and repeated calls to the large model will result in high computational costs. In addition, although the knowledge obtained in the knowledge graph has been combined when the large model generates answers, this knowledge is input into the large model in the form of context, and hallucinations will occur when the large model outputs answers. One of the traditional hallucination detection methods is multi-sampling, which determines whether hallucinations occur by comparing the similarity between multiple outputs of the large model for the same question; there are also knowledge base-based detection methods, which compare the generated answer text with multiple sources. However, if the information length is too long and the density is too high, it will inevitably lead to a sharp increase in the amount of calculation, and the possibility of hallucinations in the large model cannot be ruled out, that is, the model output does not follow the original text, such as the generated information conflicts with the original information, and additional information that does not exist in the original text is generated. Summary of the invention
[0005] The present invention provides an intelligent question-answering method, device and storage medium that integrate knowledge graphs and large models to solve the problems of inaccurate information generation, easy hallucination and high computational cost in existing retrieval enhancement generation technologies.
[0006] In an embodiment of the present invention, an intelligent question answering method integrating a knowledge graph and a large model includes the following steps:
[0007] Get the original question to be answered;
[0008] Performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate similar questions to the original question;
[0009] Traversing each entity information in the entity information set, searching and screening in a preset knowledge graph based on a search strategy integrating similar questions, and obtaining a knowledge path;
[0010] Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instructions and the original question for logical reasoning;
[0011] Perform authenticity check on the predicted answers to the original questions and filter the predicted answers based on the authenticity check results to generate the target answers;
[0012] Among them, entity extraction refers to identifying the entities and key entities contained in the original question; key entities are entities related to the scene or field of the original question, and key entities are screened and determined according to entity type and context;
[0013] The similar question is a question that is substantially the same or similar to the original question but expressed differently;
[0014] The search strategy based on fusion of similar questions is a search strategy that guides the search direction by weighted summing of the relevance scores of the original question and similar questions according to each hop search result; the knowledge path is a search path that is screened by searching the original question in the knowledge graph using the search strategy based on fusion of similar questions;
[0015] The steps of acquiring the knowledge path include: taking the key entity as the starting entity, searching in the preset knowledge graph based on the search strategy of integrating similar questions, judging whether the search results obtained are beneficial to the original question and similar questions in each hop search, and calculating the relevance scores of the original question and similar questions, setting the maximum search depth, and filtering out the next hop of the search path based on the comprehensive relevance score, and stopping the search until the search path reaches the maximum search depth, generating the knowledge path of the starting entity; traversing each entity information in the entity information set as the starting entity, and repeating the search process.
[0016] Based on the same inventive concept, an intelligent question-answering device integrating a knowledge graph and a large model is also provided in an embodiment of the present invention, which is implemented based on the above-mentioned intelligent question-answering method and specifically includes the following modules:
[0017] An acquisition module, used to acquire the original question to be answered;
[0018] An enhancement module, used for performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate similar questions to the original question;
[0019] A search module, used to traverse each entity information in the entity information set, search and filter in a preset knowledge graph based on a search strategy that integrates similar questions, and obtain a knowledge path;
[0020] An answer prediction module is used to acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by performing logical reasoning based on the task instruction and the original question through a preset answer generation model combined with the acquired knowledge;
[0021] The answer detection module is used to perform authenticity detection on the predicted answer of the original question and filter the predicted answer according to the authenticity detection result to generate a target answer.
[0022] A computer-readable storage medium is also provided in an embodiment of the present invention. The computer-readable storage medium stores a computer program. When the computer program is executed by a processor, the intelligent question-answering method as described above is implemented.
[0023] Compared with the prior art, the technical effects achieved by the present invention include:
[0024] The present invention obtains the original question to be answered, extracts entities based on the original question to generate an entity information set, rewrites the original question to generate a corresponding similar question; traverses each entity information in the generated entity information set, searches and screens in a preset knowledge graph based on a search strategy that integrates similar questions to obtain a knowledge path; constructs prompt words according to the acquired knowledge path, and performs logical reasoning based on the constructed prompt words and the original question through a preset answer generation model combined with the knowledge path to generate a predicted answer to the original question, thereby achieving the most relevant information obtained from the knowledge graph to guide the answer generation model to use external knowledge to answer, reducing the possibility that the answer generation model generates false or irrelevant information and reducing the computational cost; finally, a triple authenticity test is performed on the predicted answer to the original question, and the predicted answer is filtered according to the triple authenticity test result to generate a target answer, thereby ensuring the factual consistency of the generated answer, alleviating the illusion problem of the answer generated by the large model, and improving the credibility and accuracy of the answer. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0026] Figure 1 It is a flowchart of an intelligent question-answering method integrating a knowledge graph and a large model provided in one embodiment of the present invention;
[0027] Figure 2 is a schematic diagram of implementing the correlation score and weighted score provided in one embodiment of the present invention;
[0028] Figure 3 is a schematic diagram of a pre-generation stage provided in one embodiment of the present invention;
[0029] Figure 4 It is a flowchart of an intelligent question-answering method integrating a knowledge graph and a large model provided by another embodiment of the present invention;
[0030] Figure 5 It is a flowchart of an intelligent question-answering method integrating a knowledge graph and a large model provided by another embodiment of the present invention;
[0031] Figure 6 It is a schematic diagram of the structure of an intelligent question-answering device integrating a knowledge graph and a large model provided by an embodiment of the present invention;
[0032] Figure 7 Schematic diagram of a computer device in an embodiment of the present invention. DETAILED DESCRIPTION
[0033] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions 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.
[0034] The intelligent question-answering method that integrates knowledge graph and large model provided by the embodiment of the present invention divides answer generation into two stages for processing, to ensure the accuracy of answers generated by the large model. The pre-generation stage is based on information enhancement, question pre-analysis and a search strategy that integrates weighted relevance scores of similar questions. It obtains the most relevant information from the knowledge graph to guide the large model to use external knowledge to answer, avoiding the limitation of focusing only on the original question and effectively reducing the possibility of the large model generating false or irrelevant information. The post-generation stage generates the target answer by performing triple authenticity detection and filtering the predicted answer according to the triple authenticity detection results, thereby ensuring the factual consistency of the generated answer, alleviating the hallucination problem of the answer generated by the large model, and improving the credibility and accuracy of the answer.
[0035] The following is a detailed description of the intelligent question answering method that integrates the knowledge graph and the large model provided in this embodiment. Figure 1 As shown, the intelligent question answering method integrating the knowledge graph and the large model includes the following steps:
[0036] Step S101: Obtain the original question to be answered.
[0037] The original question refers to the question information input by the user that requires intelligent question answering.
[0038] As an example, in step S101, the present embodiment first obtains the original question to be answered, and the original question is the content of the question that the user needs to answer, in the form of but not limited to text content, voice content, etc. When the original question is text content, it can be obtained by inputting into the text input box. When the original question is voice content, it can be obtained by recording with a microphone, and the speech-to-text technology (STT for short) is used to convert the voice content into text content. This process includes but is not limited to multiple steps such as preprocessing of speech signals, feature extraction, acoustic model matching, and language model decoding.
[0039] Step S102: extract entities from the original question to generate an entity information set, and rewrite the question to generate similar questions to the original question.
[0040] Among them, entity extraction refers to identifying the entities and key entities contained in the original question; similar questions refer to questions that are essentially the same or similar to the original questions but expressed differently.
[0041] There may be multiple entities in a sentence, among which the entities related to the scenario or field of the original question are key entities; this embodiment screens and determines key entities according to entity type and context.
[0042] As an example, in step S102, this embodiment performs information enhancement processing before retrieval, and uses natural language processing technology to pre-process the original question, including extracting entities and generating similar questions, to improve the effect of knowledge retrieval. Among them, the extraction of entities is intended to identify key entities in the original question and provide accurate targets for subsequent knowledge graph search.
[0043] Step S103: traverse each entity information in the entity information set, search and filter in the preset knowledge graph based on the search strategy of integrating similar questions, and obtain the knowledge path.
[0044] Among them, the search strategy based on fusion of similar questions is a search strategy that guides the search direction by weighted summing the relevance scores of the original question and similar questions according to each hop search result; the knowledge path is a search path that uses the search strategy based on fusion of similar questions to search and filter the original question in the knowledge graph.
[0045] As an example, in step S103, each entity information in the entity information set is traversed, starting from the key entity, and a search is performed in the preset knowledge graph based on a search strategy that integrates similar questions. In each hop search, it is determined whether the search results obtained are beneficial to the original question and similar questions, and the relevance scores of the original question and similar questions are calculated. The maximum search depth is set, and the next hop of the search path is screened out based on the comprehensive relevance score. The search is stopped when the search path reaches the maximum search depth to obtain the knowledge path.
[0046] This embodiment does not limit the type of knowledge graph. The types of knowledge graphs used include but are not limited to general knowledge graphs and domain-specific knowledge graphs. Specific application scenarios can select appropriate knowledge graphs based on scenario requirements.
[0047] Step S104: Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instructions and the original question for logical reasoning.
[0048] This embodiment combines the task instructions, original questions, and acquired knowledge according to a preset prompt template, and inputs them into a preset answer generation model to guide the answer generation model to perform logical reasoning and generate answers.
[0049] In this embodiment, a knowledge set of relevant information is obtained from the knowledge graph, and the knowledge path information is converted. Specifically, the template "{head entity}'s {relationship} is {tail entity}" is used to convert the triples into natural language, and the answer is input in the form of context to generate a large model to obtain knowledge.
[0050] The composition of the prompt template is preset to include task instructions, original questions and knowledge, and restrictions are placed on the content of the generated answer in the prompt template. Specific task requirements are added to the task instructions, so that specific task requirements can be achieved by using different task instructions to guide the answer generation model to give the knowledge basis used when answering the original question, thereby reducing the possibility of hallucinations in the answer generation model. For example, the task instruction can be set to "Please generate answers to the following questions based on the provided knowledge, and give the triple basis you use", guiding the large model to use external accurate information to answer as much as possible to avoid hallucinations or redundant information as much as possible; the task instruction can also be set to "Please make sure the answer content is relevant to the question" to reduce redundant information in the output text.
[0051] As an example, in step S104, after obtaining the knowledge path from the knowledge graph, the knowledge path is processed as necessary to obtain knowledge; the original question is input into the preset answer generation model, together with the prompt words (i.e., task instructions) as the basis for reasoning; the preset answer generation model will perform logical reasoning based on the original question and the prompt words, and generate a predicted answer in combination with external knowledge (i.e., the acquired knowledge).
[0052] The above steps S101 to S104 belong to the pre-generation stage. Through information enhancement, question pre-analysis and a search strategy that integrates relevance-weighted scores of similar questions, the most relevant information is obtained from the knowledge graph to guide the answer generation. The large model uses external knowledge to answer the question, avoiding the limitation of focusing only on the original question and effectively reducing the possibility of the large model generating false or irrelevant information.
[0053] Step S105: perform triple authenticity check on the predicted answer to the original question, and filter the predicted answer according to the triple authenticity check result to generate a target answer.
[0054] The triple authenticity detection refers to verifying the authenticity of the triples on which the predicted answers are based in the knowledge graph.
[0055] As an example, in step S105, this embodiment compares and verifies the triples used by the answer generation model in the logical reasoning process with the data in the knowledge graph, including querying whether there are corresponding triples in the knowledge graph, performing similarity retrieval on the triples in the knowledge graph, and performing hallucination detection based on uncertainty values to determine whether the triples belong to real factual knowledge, filter out predicted answers with hallucinations greater than a preset threshold, and generate the target answer.
[0056] In the post-generation stage, this embodiment verifies the triple knowledge used by the large answer generation model to ensure that the generated target answer is based on real and reliable factual knowledge, thereby alleviating the hallucination problem of answers generated by the large model, improving the credibility and accuracy of the answers, and avoiding the intelligent answers from conveying wrong information, ensuring that users will not be misled.
[0057] In a further preferred embodiment of the present invention, step S102 extracts entities from the original question to generate an entity information set, and rewrites the question to generate a similar question to the original question, including the following steps:
[0058] Step S1021: perform word segmentation preprocessing on the original question, and use the entity extraction model to obtain entity information and its corresponding type in the original question;
[0059] Step S1022: Filter out key entities based on entity information and its corresponding type in combination with context;
[0060] Step S1023: rewrite the original question using the large question generation model to generate several similar questions corresponding to the original question.
[0061] In order to improve the effect of knowledge retrieval, this embodiment performs information enhancement before retrieval. First, the entity extraction model is used to extract the original question. Entity information set in , as the starting point for searching in the knowledge graph, where For the entities, , is the number of entities in the entity information set. The entity extraction model can be a BERT pre-trained language model, or a large language model, such as Qwen, GPT4, or a large model fine-tuned by instructions. The corresponding types of entities include but are not limited to movies, names of people, places, buildings, books, etc. Then, based on the entity information and its corresponding type, combined with the context, the entity information set is extracted. Key entities are screened out to guide the subsequent search process in the knowledge graph and obtain information related to the original question to improve the accuracy and pertinence of the search.
[0062] Since the reasoning logic of question-answering tasks based on knowledge graphs is implicit in the semantics of the question itself, and different expressions of the same question can be inferred from multiple aspects, in order to improve the accuracy and coverage of system search, this embodiment uses a large question generation model to rewrite the original question and generate n q Similar questions , as knowledge enhancement before retrieval. The similar questions are used to judge whether the knowledge information is relevant or helpful to answer during the search process. By fusing multiple similar questions on the basis of the original questions, the judgment process can be more comprehensive and accurate. Among them, the large question generation model includes but is not limited to generative large language models such as Qwen, GPT4, and ChatGLM.
[0063] This embodiment generates a set of similar questions that are essentially the same or similar to the original question but expressed differently, and combines the original question and the similar questions into a question set as the basis for subsequent knowledge search, which helps to improve the accuracy and comprehensiveness of knowledge search.
[0064] In another preferred embodiment of the present invention, in step S103, each entity information in the entity information set is traversed, and a search and screening is performed in a preset knowledge graph based on a search strategy that integrates similar questions. The step of obtaining a knowledge path includes:
[0065] Step S1031, taking the key entity as the starting entity, and performing a breadth-first search based on a search strategy that integrates similar problems;
[0066] Step S1032: When the path depth reaches the maximum search depth, stop searching and generate a knowledge path of the starting entity;
[0067] Step S1033, traverse each entity information in the entity information set as a starting entity, and execute the search process from step S1031 to step S1032.
[0068] In the knowledge search stage, this embodiment aims to extract the reasoning path through enhanced reasoning on the knowledge graph and build a knowledge subgraph to support answer generation. The retrieval starts from the key entity and starts the search in a breadth-first manner. When the depth of a search path reaches the maximum search depth h, the search for the path will no longer continue.
[0069] The breadth-first search based on the search strategy of integrating similar problems in step S1031 includes:
[0070] Step S310: Starting from a starting entity, obtain multiple adjacent entities of the starting entity;
[0071] Step S311, calculating the relevance scores of the starting entity, the adjacent entities, and the triplet formed by the starting entity and the adjacent entities with respect to the original question and the similar questions, and performing weighted summation of the relevance scores to obtain a weighted score;
[0072] Step S312: Acquire paths with weighted scores greater than or equal to a preset score threshold and corresponding adjacent entities, take the adjacent entities as starting entities, and continue to search for the next hop along the path.
[0073] In this embodiment, the search strategy based on the fusion of similar questions uses a weighted relevance score to guide the search direction. After determining the search depth, starting from the key entity, the key entity is used as the starting entity, and multiple entity information adjacent to the starting entity is obtained in the knowledge graph. The relevance scores of the starting entity, the adjacent entity, and the triple formed by the starting entity and the adjacent entity to the original question and similar questions are calculated in turn, and the weighted sum of the relevance scores is obtained to obtain the weighted score between the starting entity and each adjacent entity. The path and the corresponding adjacent entity whose weighted score is greater than or equal to the preset score threshold are obtained, and the obtained adjacent entity is continued as the starting entity, and the entity adjacent to the newly determined starting entity is accessed for the next hop search. When the depth of the search path reaches the maximum search depth, further search of the path is stopped.
[0074] For ease of understanding, Figure 2 This is a schematic diagram of the implementation of the relevance score and weighted score provided in the embodiment of the present invention. This embodiment uses function s to determine the entity e and relationship r i Is the question q j The answer is useful, which is specifically expressed as a function s(e,r i ,q j ), the output is 0 or 1. This function is implemented by a semantic relevance model, including but not limited to an interactive semantic similarity model and a representational semantic model. Assign weight w(q j ), used to represent entity e and relationship r i The importance of the relevance of each question in the total score. Since similar questions are generated from the original question, the original question retains more of the original intention of the questioner, so the original question has a higher weight, and several similar questions generated from the original question are assigned lower but equal weights. For example, the original question entered by the user is assigned a weight of 2, and the generated similar questions are all assigned a lower weight of 1. w(q j ) is expressed as follows:
[0075] ;
[0076] The expression of weighted score is:
[0077] ;
[0078] Among them, w(q j ) indicates the original question or a similar question q j The weight of the function s(e,r i ,q j ) represents the starting entity e and the relationship r iTo the original question or a similar question j The relevance score, , n q represents the total number of similar questions, S(r i ) indicates the starting entity e and relation r in this hop search i The weighted score of , n r Represents the number of adjacent entities of the starting entity e.
[0079] Compared to simply judging whether the searched knowledge answers the original question or not, the weighted score in this embodiment integrates the relationship between the relationship and the various reasoning paths of the original question, thereby making a more comprehensive evaluation and a more accurate judgment.
[0080] The relationship r between the starting entity e and the adjacent entities according to the weighted score i If the weighted score exceeds the preset score threshold, the relationship r is retained. i and its connected adjacent entities, which will be used as the starting entity for the next hop search; otherwise, they will be discarded. In this way, the efficiency of retrieval is improved, and irrelevant content in the retrieval information is reduced, which is conducive to improving the quality of the subsequent generated answers. Among them, this embodiment does not limit the preset score threshold and weight distribution, which can be set according to the specific scenario.
[0081] In a preferred embodiment of the present invention, step S104 obtains knowledge according to the knowledge path, and generates a predicted answer to the original question by combining the obtained knowledge with a preset answer generation model according to the task instruction and the original question for logical reasoning, including the following steps:
[0082] Step S1041: convert the knowledge path into a natural language description sentence in a preset triple form, and acquire knowledge according to the natural language description sentence;
[0083] Step S1042: Combine the task instructions, original question and acquired knowledge according to the preset prompt template and input them into the preset answer generation model, guide the answer generation model to perform logical reasoning, generate a predicted answer to the original question and output the knowledge basis used to generate the predicted answer.
[0084] Among them, the answer generation model includes but is not limited to large language models such as Qwen, GPT4, and ChatGLM. This embodiment generates content based on external knowledge. Specifically, after obtaining the knowledge path from the knowledge graph, the knowledge path is subjected to necessary conversion processing and then input into the answer generation model. For example, the knowledge path is converted into a natural language description statement in the form of a triple to ensure the readability and contextual coherence of the knowledge; then the knowledge is acquired according to the converted natural language description statement, and the acquired knowledge is used to guide the answer generation model to perform reasoning and generate answers; finally, a prompt template is constructed according to the task instruction, the original question, and the acquired knowledge, and the prompt template is input into the answer generation model, so that the answer generation model performs logical reasoning according to the received original question and task instruction, and generates a predicted answer in combination with external knowledge (i.e., the acquired knowledge), and outputs the predicted answer and the knowledge basis used. The knowledge basis is the triple based on which the answer generation model generates the predicted answer to the original question.
[0085] Optionally, this embodiment uses a template: {head entity}'s {relationship} is {tail entity}, converts the triple into a natural language description sentence, and inputs the answer in the form of context to generate a large model. It should be understood that the format of the template is not specified and can be constructed according to the actual usage scenario. For ease of understanding, Figure 3 The schematic diagram of the pre-generation stage provided for the embodiment of the present invention fully demonstrates the pre-retrieval information enhancement, the screening of knowledge during the retrieval process and the answer generation process.
[0086] In one embodiment of the present invention, step S105 performs a triple authenticity check on the predicted answer to the original question and filters the predicted answer according to the triple authenticity check result, and the step of generating the target answer includes:
[0087] Step S1051, obtaining the predicted answer to the original question and the knowledge basis on which it is based;
[0088] Step S1052: query the knowledge basis in the knowledge graph using a knowledge graph query language;
[0089] Step S1053: when the knowledge basis is found in the knowledge graph, the predicted answer is used as the target answer;
[0090] Step S1054: when the knowledge basis is not found in the knowledge graph, a similarity search is performed on the knowledge basis in the knowledge graph;
[0091] Step S1055: When a triple whose similarity with the knowledge basis is greater than a preset similarity threshold is retrieved in the knowledge graph, the predicted answer is used as the target answer; otherwise, the knowledge basis is used as the triple to be tested, hallucination detection and filtering are performed on the predicted answer to generate the target answer.
[0092] The knowledge basis is the triple based on which the answer generation model infers the predicted answer. This embodiment proposes a hallucination detection method for verifying the knowledge basis, including three detection strategies, which are executed successively, namely, querying whether the triple in the knowledge basis exists in the knowledge graph, performing similarity search on the triple in the knowledge basis in the knowledge graph, and performing hallucination detection on the triple in the knowledge basis based on uncertainty value.
[0093] After the answer generation model outputs the predicted answer, this embodiment uses a knowledge graph query language, such as SPARQL, to query whether the triples (subject, predicate, object) in the knowledge graph exist at the same time for the triples in the knowledge basis. If the query can accurately match the same triples in the knowledge graph, the triples in the knowledge basis are considered valid, and the predicted answer inferred from the knowledge basis is based on real factual knowledge and does not contain hallucinations, and the predicted answer is used as the target answer.
[0094] For triples in the knowledge basis that cannot directly query the same item in the knowledge graph, this embodiment uses a similarity-based method for indirect verification. Calculate the similarity between the triples in the knowledge basis and all triples in the knowledge graph, and compare each similarity with a preset similarity threshold. If the similarity between the triples in the knowledge basis and the triples existing in the knowledge graph is higher than the preset similarity threshold, the triples are considered to be credible and there is no hallucination phenomenon, and the predicted answer is used as the target answer. Otherwise, when the similarity between the triples in the knowledge basis and the triples existing in the knowledge graph is lower than the preset similarity threshold, the triples in the knowledge basis are considered to be unreliable. Here, the calculation method of the similarity includes but is not limited to cosine similarity and Jaccard similarity to ensure accuracy.
[0095] Furthermore, for those triples in the knowledge basis that can neither be queried in the knowledge graph nor retrieved by similarity, this embodiment uses them as triples to be tested and adopts the uncertainty value method to perform hallucination detection at the word level to perform hallucination detection and filter the predicted answer to generate the target answer.
[0096] In one embodiment of the present invention, in step S1055, the knowledge basis is used as a triple to be tested, hallucination detection and filtering are performed on the predicted answer, and the target answer is generated, including:
[0097] Step S551, obtaining the word-gram sequence corresponding to the triple to be tested and the vocabulary probability distribution output when the answer generation model generates each word-gram in the word-gram sequence, and calculating the uncertainty value of each word-gram in the word-gram sequence;
[0098] Step S552, calculating an average value of the uncertainty values of all word-grams in the word-gram sequence as the uncertainty measurement value of the triplet to be tested;
[0099] Step S553, comparing the uncertainty measurement value of the triplet to be tested with a preset measurement threshold;
[0100] Step S554: if the uncertainty metric value is greater than or equal to the preset metric threshold, obtaining a preset answer template to replace the predicted answer, and outputting the preset answer template;
[0101] Step S555: If the uncertainty metric value is less than the preset metric threshold, the predicted answer is used as the target answer.
[0102] When performing hallucination detection and filtering on the predicted answers to the original questions, this embodiment uses the triples that the predicted answers rely on as the triples to be tested. Among them, word-grams refer to the smallest units into which text data is divided before or during the processing of the answer generation model. The smallest unit can be a word, punctuation mark, subword, etc. Therefore, the word-gram sequence corresponding to the triple to be tested refers to the text sequence after the triple to be tested is divided according to the smallest unit. . The probability distribution of each word in the word-gram sequence is obtained through the answer generation model. The answer generation model generates a probability distribution for each word-gram, indicating the possibility of the word-gram appearing in a given context. The uncertainty of a word-gram reflects the degree of uncertainty of the answer generation model when generating the word-gram. The higher the uncertainty, the less certain the answer generation model is about generating the word-gram. When generating each word-gram, the answer generation model outputs a probability distribution, indicating the probability that the word-gram may be each word in the internal vocabulary of the answer generation model. The size of the vocabulary is D, that is, the vector length of the word-gram. This embodiment uses represents the probability distribution of the kth word in the word sequence. Each word includes D elements. In this embodiment, represents the probability of the dth word in the vocabulary being selected, Therefore, the uncertainty value of a word generated by the answer generation model is:
[0103] ;
[0104] ;
[0105] Among them, U represents the uncertainty function of the word unit, D is the vector length of the word unit, is the probability distribution of the kth word in the word sequence corresponding to the triple to be tested, Represents the kth word in the word sequence The uncertainty value of .
[0106] In this embodiment, the uncertainty values of all word-grams in the word-gram sequence corresponding to the triple to be tested are averaged to obtain the uncertainty measurement value of the entire triple to be tested. The calculation formula is:
[0107] ;
[0108] in, represents the uncertainty measure of the triple to be tested, and n represents the number of word units contained in the word unit sequence corresponding to the triple to be tested.
[0109] Finally, this embodiment compares the calculated uncertainty metric value of the triple to be verified with the preset metric threshold. If the uncertainty metric value of the triple to be verified is higher than or equal to the preset metric threshold, it is considered that the triple to be verified may be incorrect knowledge, and the predicted answer generated by the large answer generation model also has the risk of hallucination. At this time, a preset answer template is used to answer the question to avoid conveying wrong information. Conversely, if the uncertainty metric value of the triple to be verified is lower than the preset metric threshold, the triple to be verified is considered to be credible factual knowledge, and the predicted answer output by the large answer generation model is considered to be correct. Among them, the preset answer template is a fixed answer, such as "I'm sorry, I can't provide an accurate answer at the moment", "The professional knowledge involved in this question is beyond my ability, and it is recommended that you consult experts or professionals in related fields" to avoid the large answer generation model outputting incorrect answer content.
[0110] After completing the verification of the triplet to be tested and the hallucination detection, this embodiment will make a corresponding response according to the detection result. The intelligent question answering method of this embodiment may further include the steps of:
[0111] Step S106: associate the original question and its corresponding entity information set, knowledge path, and target answer and store them in the memory pool.
[0112] This embodiment sends the predicted answers that are verified to be true and without hallucinations to the user, and stores the original question, entity information set, knowledge path, and generated predicted answers in the memory pool for quick response to similar questions in the future. For answers that may be hallucinated, a preset security response strategy will be triggered to ensure that the user is not misled. It can be seen that the intelligent answering method that integrates knowledge graphs and large models provided by this embodiment can not only efficiently generate predicted answers but also effectively prevent hallucinations, greatly improving the user experience and the credibility of the system.
[0113] Multi-hop reasoning about questions is the main challenge of question answering tasks based on knowledge graphs. In existing search methods, it is usually necessary to repeatedly use large models to determine whether all the content currently searched can answer the question in order to decide whether to continue searching, which results in low search efficiency.
[0114] As an example of the present invention, in order to further improve the efficiency of generating predicted answers, this embodiment can use a large task planning model to retrieve whether there is a knowledge path in the memory pool and set the maximum search depth. Figure 4 This is a flowchart of an implementation of an intelligent question-answering method that integrates knowledge graphs and large models provided in another embodiment of the present invention. Figure 4 In the method, the intelligent question answering method integrating the knowledge graph and the large model includes:
[0115] Step S201: obtaining the original question to be answered;
[0116] Step S202: extracting entities from the original question to generate an entity information set, and rewriting the question to generate similar questions to the original question;
[0117] Step S203: Pre-search the memory pool according to the original question to obtain historical questions, entity information sets, knowledge paths and target answers related to the original question;
[0118] Step S204: taking the historical questions, entity information sets, knowledge paths and target answers related to the original question as input information, using a preset task planning model to perform autonomous analysis to determine whether to perform a knowledge path search;
[0119] Step S205: Obtain the output result of the task planning model. If the output result is yes, set the maximum search depth of the original question in the preset knowledge graph according to the number of search hops in the output result, and execute step S206; if the output result is no, perform logical reasoning to generate a predicted answer to the original question, and jump to step S207;
[0120] Step S206, traverse each entity information in the entity information set, search and filter in the preset knowledge graph based on the search strategy of integrating similar questions, obtain the knowledge path, and return to step S204;
[0121] Step S207: Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instruction and the original question for logical reasoning;
[0122] Step S208: Perform triple authenticity check on the predicted answer to the original question and filter the predicted answer according to the triple authenticity check result to generate a target answer.
[0123] Among them, steps S201-S202 are respectively the same as steps S101-S102 in the above embodiment, and steps S206-S208 are respectively the same as steps S103-S105 in the above embodiment. Please refer to the description of the above embodiment for details, which will not be repeated here.
[0124] In this embodiment, the memory pool refers to a database for storing historical intelligent question and answer information, which stores historical questions and their corresponding entity information sets, knowledge paths, and target answers.
[0125] After receiving the original question, this embodiment performs a pre-search in the memory pool to obtain the history related to the original question, including but not limited to the historical questions and the entity information set, knowledge path and target answer corresponding to the historical questions. In this way, rich context information is collected to provide support for the subsequent autonomous planning of the task planning model.
[0126] The historical questions, entity information sets, knowledge paths and target answers related to the original question are integrated as input information, and the preset task planning model is used for autonomous analysis. The task planning model is used to evaluate and determine whether to search for knowledge paths. The task planning model determines whether the original question is a simple question or a complex question based on the input information. If it is a simple question, a direct reply is selected to save unnecessary computing resources; if it is a complex question with relatively scattered information or requiring multiple reasonings, a deeper search strategy is required, and the search depth is generated and output to ensure that enough relevant information can be obtained to build a high-quality predicted answer. It should be understood that the task planning model is not completed in one go when planning the search depth, but is continuously and dynamically adjusted as the search of the knowledge path progresses. In this embodiment, the knowledge path obtained by the knowledge search in step S206, the historical questions, entity information sets, knowledge paths and target answers related to the original question are used as new input information, and the task planning model is returned to step S204 to continue autonomous analysis, continuously evaluate the correlation between the obtained knowledge path and the original question, and the impact of this information on the quality of the predicted answer, and decide whether to continue searching.
[0127] In this embodiment, the simplicity and complexity of the problem are analyzed independently by the task planning big model, and the task planning big model learns a lot of knowledge during the training process, including the original questions raised by the user. Therefore, the task planning big model determines that the questions that have been learned, high-frequency questions, questions with similar problems in the memory pool, and questions that the big model has answered many times are simple questions. For time-sensitive questions, such as those involving the latest data or information, since the training of the big model ends at a specific time and does not have the latest knowledge, the task planning big model determines them as complex questions. For professional questions, such as those involving professional knowledge or information in a specific field, the big model does not fully cover these fields during the training process, and the task planning big model determines them as complex questions. For multi-step reasoning problems, multiple triples or multi-step logical reasoning are required to get the answer, and the task planning big model determines them as complex problems.
[0128] As another example of the present invention, this embodiment can also identify the number of search hops for the original question and then limit the search scope by the number of search hops to reduce the number of calls to the large model and improve the search efficiency. Figure 5 This is a flowchart of an implementation of an intelligent question-answering method that integrates knowledge graphs and large models provided in another embodiment of the present invention. Figure 5 In the method, the intelligent question answering method integrating the knowledge graph and the large model includes:
[0129] Step S301: obtaining the original question to be answered;
[0130] Step S302: extracting entities from the original question to generate an entity information set, and rewriting the question to generate similar questions to the original question;
[0131] Step S303: Identify the search hop count of the original question, and set the maximum search depth of the original question in a preset knowledge graph according to the search hop count;
[0132] Step S304: traverse each entity information in the entity information set, search and filter in the preset knowledge graph based on the search strategy of integrating similar questions, and obtain the knowledge path;
[0133] Step S305: Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instruction and the original question for logical reasoning;
[0134] Step S306: Perform triple authenticity detection on the predicted answer to the original question and filter the predicted answer according to the triple authenticity detection result to generate a target answer.
[0135] Among them, steps S301-S302 are respectively the same as steps S101-S102 in the above embodiment, and steps S304-S306 are respectively the same as steps S103-S105 in the above embodiment. Please refer to the description of the above embodiment for details, which will not be repeated here.
[0136] In this embodiment, identifying the search hop count of the original question in step S303, and setting the maximum search depth of the original question in the preset knowledge graph according to the search hop count includes:
[0137] Step S3031: Encode the original question based on the fine-tuned pre-trained language model;
[0138] Step S3032: using the pre-trained linear classifier to predict the number of search hops required for the encoded original question;
[0139] Step S3033: Set the maximum search depth of the original question in the preset knowledge graph as the number of search hops.
[0140] Given a maximum hop number H, all possible hop numbers constitute the set , the recognition of hop count is a classification task, and the set of hop counts is the set of classification labels. This embodiment first uses a fine-tuned pre-trained language model to encode the original question, and then uses a linear classifier to determine the classification label according to the probability distribution. The mathematical expression of the above steps is as follows:
[0141] ;
[0142] ;
[0143] Among them, PLM represents the fine-tuned pre-trained language model, Indicates the original problem, The vector representation of the encoded original problem is represented, and argmax is used to determine the search hop count h with the highest probability.
[0144] After obtaining the search hop count, the search hop count will be set to the maximum search depth of the original question when searching in the knowledge graph. When the depth of a search path reaches the search hop count, the search for the path will no longer continue without any other judgment.
[0145] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0146] In one embodiment, the present invention further provides an intelligent question-answering device integrating knowledge graph and large model, and the intelligent question-answering device integrating knowledge graph and large model corresponds one-to-one to the intelligent question-answering method integrating knowledge graph and large model in the above embodiment. Figure 6 As shown, the intelligent question-answering device integrating the knowledge graph and the large model includes an acquisition module 61, an enhancement module 62, a search module 63, an answer prediction module 64, and an answer detection module 65. The detailed description of each functional module is as follows:
[0147] An acquisition module 61 is used to acquire the original question to be answered;
[0148] An enhancement module 62 is used to extract entities from the original question to generate an entity information set, and to rewrite the question to generate a similar question to the original question;
[0149] A search module 63, used to traverse each entity information in the entity information set, search and filter in a preset knowledge graph based on a search strategy integrating similar questions, and obtain a knowledge path;
[0150] The answer prediction module 64 is used to acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by performing logical reasoning based on the task instruction and the original question through a preset answer generation model combined with the acquired knowledge;
[0151] The answer detection module 65 is used to perform authenticity detection on the predicted answer of the original question and filter the predicted answer according to the authenticity detection result to generate a target answer.
[0152] Optionally, the enhancement module 62 includes:
[0153] An entity extraction unit, used to perform word segmentation preprocessing on the original question, and use an entity extraction large model to obtain entity information and its corresponding type in the original question;
[0154] A screening unit, configured to screen out key entities according to the entity information and its corresponding type in combination with the context;
[0155] The question rewriting unit is used to rewrite the original question by using a large question generation model to generate a plurality of similar questions corresponding to the original question.
[0156] Optionally, the device further includes a search judgment module, and the search judgment module includes:
[0157] A pre-retrieval unit, configured to perform a pre-retrieval in a memory pool according to the original question, and obtain historical questions, entity information sets, knowledge paths, and target answers related to the original question;
[0158] A history search unit, used to take the history questions, entity information sets, knowledge paths and target answers related to the original question as input information, use a preset task planning model to perform autonomous analysis, and determine whether to perform a knowledge path search;
[0159] An execution unit is used to obtain the output result of the task planning large model. If the output result is yes, the maximum search depth of the original question in the preset knowledge graph is set according to the number of search hops in the output result, and the search and screening is performed in the preset knowledge graph based on the search strategy of integrating similar questions; if the output result is no, logical reasoning is performed to generate a predicted answer to the original question.
[0160] Optionally, the search module 63 includes:
[0161] A search unit, which is used to perform a breadth-first search based on a search strategy integrating similar problems, taking the key entity as the starting entity;
[0162] A path generation unit, configured to stop searching and generate a knowledge path for the starting entity when the path depth reaches the maximum search depth;
[0163] Traverse each entity information in the entity information set as the starting entity and repeat the above steps.
[0164] Optionally, the searching unit includes:
[0165] An adjacent entity acquisition subunit, used to acquire multiple adjacent entities of the starting entity starting from the starting entity;
[0166] A weighted summation subunit, used to calculate the relevance scores of the starting entity, the adjacent entities, and the paths formed by the relationship between the two with respect to the original question and the similar questions, and to perform weighted summation of the relevance scores to obtain a weighted score;
[0167] The path acquisition subunit is used to acquire the path with a weighted score greater than or equal to a preset score threshold and the corresponding adjacent entity, and to continue the next hop search along the path with the adjacent entity as the starting entity.
[0168] Optionally, the answer prediction module 64 includes:
[0169] A conversion unit, used to obtain a knowledge set of relevant information from the knowledge graph, convert the knowledge path into a natural language description statement in the form of a preset triple, and obtain knowledge according to the natural language description statement;
[0170] The answer prediction unit is used to combine the task instructions, original questions and acquired knowledge according to the preset prompt template and input them into the preset answer generation model, guide the answer generation model to perform logical reasoning to generate the predicted answer to the original question and output the knowledge basis used to generate the predicted answer.
[0171] Optionally, the answer detection module 65 includes:
[0172] A basis acquisition unit, used to acquire the predicted answer to the original question and the knowledge basis based thereon;
[0173] A query unit, configured to query the knowledge basis in the knowledge graph using a knowledge graph query language; when the knowledge basis is found in the knowledge graph, the predicted answer is used as a target answer;
[0174] A retrieval unit, configured to perform a similarity search on the knowledge basis in the knowledge graph when the knowledge basis is not found in the knowledge graph; and to use the predicted answer as the target answer when a triple whose similarity to the knowledge basis is greater than a preset similarity threshold is found in the knowledge graph;
[0175] The hallucination detection unit is used to perform hallucination detection and filtering on the predicted answer by taking the knowledge basis as the triple to be tested, and generate a target answer.
[0176] Optionally, the hallucination detection unit comprises:
[0177] A first calculation unit is used to obtain a word-gram sequence corresponding to the to-be-tested triple and a vocabulary probability distribution outputted when the answer generation model generates each word-gram in the word-gram sequence, and calculate an uncertainty value of each word-gram in the word-gram sequence;
[0178] A second calculation unit, configured to calculate an average value of the uncertainty values of all word-grams in the word-gram sequence as an uncertainty measurement value of the triple to be tested;
[0179] A comparing unit, used for comparing the uncertainty measurement value of the triple to be tested with a preset measurement threshold;
[0180] A result output unit is used to obtain a preset answer template to replace the predicted answer and output the preset answer template if the uncertainty metric value is greater than or equal to the preset metric threshold; if the uncertainty metric value is less than the preset metric threshold, use the predicted answer as the target answer.
[0181] Optionally, the device further includes a hop count setting module, and the hop count setting module includes:
[0182] A question encoding unit, configured to encode the original question based on the fine-tuned pre-trained language model;
[0183] A hop count prediction unit, used for predicting the required search hop count for the encoded original question using a pre-trained linear classifier;
[0184] A hop count setting unit is used to set the maximum search depth of the original question in a preset knowledge graph as the search hop count.
[0185] For the specific definition of the intelligent question-answering device that integrates the knowledge graph and the large model, please refer to the definition of the intelligent question-answering method that integrates the knowledge graph and the large model in the above text, which will not be repeated here. Each module in the above-mentioned intelligent question-answering device that integrates the knowledge graph and the large model can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0186] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 7 As shown, it includes a memory, a processor and a computer program stored in the memory and executable on the processor. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the processor executes the computer program, the following steps are implemented:
[0187] Get the original question to be answered;
[0188] Performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate similar questions to the original question;
[0189] Traversing each entity information in the entity information set, searching and screening in a preset knowledge graph based on a search strategy integrating similar questions, and obtaining a knowledge path;
[0190] Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instruction and the original question for logical reasoning;
[0191] The predicted answer to the original question is subjected to authenticity check and the predicted answer is filtered according to the authenticity check result to generate a target answer.
[0192] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0193] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. An intelligent question answering method integrating knowledge graph and large model, characterized in that: The following steps are involved: Get the original question to be answered; Performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate similar questions to the original question; Traversing each entity information in the entity information set, searching and screening in a preset knowledge graph based on a search strategy integrating similar questions, and obtaining a knowledge path; Acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by combining the acquired knowledge with a preset answer generation model according to the task instructions and the original question for logical reasoning; Perform authenticity check on the predicted answers to the original questions and filter the predicted answers based on the authenticity check results to generate the target answers; Among them, entity extraction refers to identifying the entities and key entities contained in the original question; key entities are entities related to the scene or field of the original question, and key entities are screened and determined according to entity type and context; The similar question is a question that is substantially the same or similar to the original question but expressed differently; The search strategy based on fusion of similar questions is a search strategy that guides the search direction by weighted summing of the relevance scores of the original question and similar questions according to each hop search result; the knowledge path is a search path that is screened by searching the original question in the knowledge graph using the search strategy based on fusion of similar questions; The steps of acquiring the knowledge path include: taking the key entity as the starting entity, searching in the preset knowledge graph based on the search strategy of integrating similar questions, judging whether the search results obtained are beneficial to the original question and similar questions in each hop search, and calculating the relevance scores of the original question and similar questions, setting the maximum search depth, and screening the next hop of the search path based on the comprehensive relevance score, until the search path reaches the maximum search depth, stopping the search, and generating the knowledge path of the starting entity; traversing each entity information in the entity information set as the starting entity, and repeating the search process; Performing authenticity check on the predicted answer to the original question and filtering the predicted answer according to the authenticity check result to generate the target answer includes the following steps: Get the predicted answer to the original question and the knowledge basis on which it is based; Using the knowledge graph query language to query the knowledge basis in the knowledge graph; When the knowledge basis is found in the knowledge graph, the predicted answer is used as the target answer; When the knowledge basis is not found in the knowledge graph, a similarity search is performed on the knowledge basis in the knowledge graph; When a triple whose similarity with the knowledge basis is greater than a preset similarity threshold is retrieved in the knowledge graph, the predicted answer is used as the target answer; otherwise, the knowledge basis is used as the triple to be tested, hallucination detection and filtering are performed on the predicted answer to generate the target answer.
2. The intelligent question-answering method according to claim 1, characterized in that: Performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate a similar question to the original question, includes the following steps: Perform word segmentation preprocessing on the original question, and use an entity extraction model to obtain entity information and its corresponding type in the original question; According to the entity information and its corresponding type, key entities are screened out in combination with the context; The original question is rewritten using a large question generation model to generate several similar questions corresponding to the original question.
3. The intelligent question-answering method according to claim 1, characterized in that: Generating a predicted answer to the original question involves the following steps: Obtain a knowledge set of relevant information from the knowledge graph, convert the knowledge path into a natural language description statement in the form of a preset triple, and obtain knowledge based on the natural language description statement; According to the preset prompt template, the task instructions, the original question and the acquired knowledge are combined and input into the preset answer generation model, guiding the answer generation model to perform logical reasoning, generate the predicted answer to the original question and output the knowledge basis used to generate the predicted answer; The composition of the prompt template is preset to include task instructions, original questions and knowledge, restrictions are placed on the content of the generated answers in the prompt template, and specific task requirements are added to the task instructions.
4. The intelligent question-answering method according to claim 1, wherein: Before acquiring the knowledge path, the intelligent question answering method further includes the following steps: According to the original question, pre-search is performed in the memory pool to obtain historical questions, entity information sets, knowledge paths and target answers related to the original question; Taking the historical questions, entity information sets, knowledge paths and target answers related to the original question as input information, using the preset task planning model to perform autonomous analysis to determine whether to perform knowledge path search; Get the output result of the task planning model. If the output result is yes, set the maximum search depth of the original question in the preset knowledge graph according to the number of search hops in the output result, and search and filter in the preset knowledge graph based on the search strategy of integrating similar questions to obtain knowledge; if the output result is no, perform logical reasoning to generate a predicted answer to the original question.
5. The intelligent question-answering method according to claim 4, characterized in that: The search strategy based on integrating similar questions is a breadth-first search in the preset knowledge graph, which specifically includes the following steps: Starting from the starting entity, obtaining a plurality of adjacent entities of the starting entity; Calculating the relevance scores of the starting entity, the adjacent entities, and the triplet consisting of the starting entity and the adjacent entities with respect to the original question and the similar questions, respectively, and performing weighted summation of the relevance scores to obtain a weighted score; A path with a weighted score greater than or equal to a preset score threshold and a corresponding adjacent entity are obtained, and the adjacent entity is used as a starting entity to continue the next hop search along the path.
6. The intelligent question-answering method according to claim 1, wherein: Taking the knowledge basis as the triple to be tested, hallucination detection and filtering are performed on the predicted answer to generate a target answer, including: Obtain the word-gram sequence corresponding to the triple to be tested and the vocabulary probability distribution output when the answer generation model generates each word-gram in the word-gram sequence, and calculate the uncertainty value of each word-gram in the word-gram sequence; Calculating an average value of the uncertainty values of all word-grams in the word-gram sequence as an uncertainty measurement value of the triplet to be tested; Comparing the uncertainty measurement value of the triplet to be tested with a preset measurement threshold; If the uncertainty metric value is greater than or equal to a preset metric threshold, obtaining a preset answer template to replace the predicted answer, and outputting the preset answer template; If the uncertainty metric value is less than a preset metric threshold, the predicted answer is used as the target answer; Among them, a word-gram is the smallest unit into which text data is divided before or during processing by the large answer generation model, and the smallest unit is a word, punctuation mark or subword; the word-gram sequence corresponding to the triple to be tested is the text sequence after the triple to be tested is divided according to the smallest unit, and the probability distribution of each word-gram in the word-gram sequence is obtained by the large answer generation model.
7. An intelligent question-answering device integrating knowledge graph and large model, characterized in that: The intelligent question-answering method according to any one of claims 1 to 3 is implemented, and the intelligent question-answering device includes the following modules: An acquisition module, used to acquire the original question to be answered; An enhancement module, used for performing entity extraction on the original question to generate an entity information set, and performing question rewriting to generate similar questions to the original question; A search module, used to traverse each entity information in the entity information set, search and filter in a preset knowledge graph based on a search strategy that integrates similar questions, and obtain a knowledge path; An answer prediction module is used to acquire knowledge according to the knowledge path, and generate a predicted answer to the original question by performing logical reasoning based on the task instruction and the original question through a preset answer generation model combined with the acquired knowledge; The answer detection module is used to perform authenticity detection on the predicted answer of the original question and filter the predicted answer according to the authenticity detection result to generate a target answer.
8. The intelligent question-answering device according to claim 7, characterized in that: The answer detection module comprises: A basis acquisition unit, used to acquire the predicted answer to the original question and the knowledge basis based thereon; A query unit, configured to query the knowledge basis in the knowledge graph using a knowledge graph query language; when the knowledge basis is found in the knowledge graph, the predicted answer is used as a target answer; A retrieval unit, configured to perform a similarity search on the knowledge basis in the knowledge graph when the knowledge basis is not found in the knowledge graph; and to use the predicted answer as the target answer when a triple whose similarity to the knowledge basis is greater than a preset similarity threshold is found in the knowledge graph; The hallucination detection unit is used to perform hallucination detection and filtering on the predicted answer by taking the knowledge basis as the triple to be tested, and generate a target answer.
9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the intelligent question-answering method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
Steel industry intelligent question and answer method and device based on large model and medium
CN118051587A
Large model illusion correction method and device based on iterative evaluation algorithm
CN118709777A