A method and system for solving the hallucination problem of large language models

By connecting two models of different parameter levels in a large language model and using prompt word engineering and context learning for verification, the hallucination problem when large language models generate content is solved, the accuracy and credibility of the results are improved, and the generalization ability of the model is enhanced.

CN119761346APending Publication Date: 2025-04-04HONG KONG UNIV OF SCI & TECH (GUANGZHOU)

Patent Information

Application Number
CN202411821649.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

Large language models are prone to hallucinations when generating content, resulting in the generated results that are inconsistent with user input, previous and subsequent texts or factual knowledge, reducing the credibility and widespread application of the model.

Method used

By connecting two large language models at different parameter levels, using prompt word engineering and context learning, problem type judgment and verification results are performed, verification questions and verification results are generated, and the basic response is analyzed and corrected to generate accurate results.

Benefits of technology

It effectively reduces the frequency of hallucination problems, improves the accuracy and credibility of output results, enables the model to be effectively applied in multi-task, multi-language and multi-field environments, and enhances the generalization ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119761346A_ABST
    Figure CN119761346A_ABST
Patent Text Reader

Abstract

The present application belongs to the technical field of large language models, and relates to a method and system for solving the hallucination problem of large language models, the method comprising: making a basic response to an initial question in a first large language model; judging and verifying the type of the basic response based on prompt word engineering and context learning in a second large language model, generating a verification question and a verification result; based on the verification result, analyzing and correcting the basic response, and generating an accurate result to solve the hallucination problem. The present application connects two large language models and an output model, implements question type judgment and verification based on prompt word engineering and context learning, and analyzes and corrects the basic response, effectively solving the hallucination problem of large language models and improving the accuracy of the results.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of large language models, and in particular to a method and system for solving the hallucination problem of large language models. Background Art

[0002] The hallucination problem is one of the key challenges that cannot be avoided in the practical application of large language models (LLMs). The hallucination problem refers to the situation that when a large language model generates content, it is irrelevant to the existing knowledge base or deviates from reality, and even generates erroneous information that violates common sense. The content generated by these problems seems reasonable, but in fact it does not match the user input, the context or factual knowledge, resulting in a reduced credibility of the generated results and weakening the reliability of LLMs in real scenarios. Solving the hallucination problem is a technical challenge in the current field of large language model technology. Most of the existing technologies for solving hallucination problems are designed for a single task, which can reduce hallucination phenomena when processing specific tasks, but the disadvantage is that it is difficult to extend to tasks of different problem types, resulting in hallucination problems in the generated results. The invention patent with application number 202410026756.7 discloses a system and method for solving the hallucination problem of large language models, which improves the authenticity and accuracy of the results and reduces the hallucination problem through two associated searches, tracking and verification. However, the disadvantage of the invention is that the associated search is only within the same LLM, resulting in the same traceability content for the secondary search and verification, and the credibility of the verification is low. How to ensure the accuracy of verification results and improve credibility during the retrieval process, thereby solving the hallucination problem, is a current problem. In addition, existing technologies are mostly performed for a single task and are deployed online, and cannot be generalized to multi-task, multi-language, and multi-domain environments, especially when confidentiality is involved, thus limiting the application of LLMs.

[0003] Therefore, the prior art still needs to be improved and developed. Summary of the invention

[0004] In view of the above-mentioned deficiencies in the prior art, the present application provides a method and system for solving the hallucination problem of large language models, aiming to solve the problems of hallucination in large language models in the prior art, resulting in low credibility of results, single usage environment, limited application, etc. The present application's method and system for solving the hallucination problem of large language models connects two large language models and an output model, implements question type judgment and verification based on prompt word engineering and context learning, and analyzes and corrects basic responses, effectively solving the hallucination problem of large language models and improving the accuracy of results.

[0005] This application is implemented through the following technical solutions:

[0006] The first aspect of the present application is to provide a method for solving the hallucination problem of a large language model, comprising the following steps:

[0007] Give a basic response to the initial question in the first large language model;

[0008] In the second large language model, type judgment and verification are performed on the basic response based on prompt word engineering and context learning, and verification questions and verification results are generated;

[0009] Based on the validation results, the basic response is analyzed and corrected to generate accurate results to solve the illusion problem.

[0010] Specifically, the method of performing type judgment and verification on the basic response based on prompt word engineering and context learning in the second large language model, generating verification questions and verification results, comprises the steps of:

[0011] Based on the prompt word engineering, judging the question type according to the initial question and the basic response, and generating a verification question list;

[0012] Based on the context learning and according to the question type, a workflow is executed to answer the verification question and generate the verification result.

[0013] Specifically, the question types include factual questions, multiple-choice questions, and long text questions.

[0014] Specifically, the prompt word project includes prompt word templates for different types of databases, including entity templates, sentence templates and long text templates.

[0015] Specifically, the prompt word engineering, judging the question type according to the initial question and the basic response, and generating a verification question list include:

[0016] Splitting the initial question, and extracting valid variables according to the prompt word template;

[0017] The valid variables are searched and compared to generate a number of verification questions to form the verification question list.

[0018] Specifically, the learning based on the context, executing the workflow according to the question type, answering the verification question, and generating the verification result include:

[0019] According to the type of question, a context weighting mechanism is set;

[0020] Call and retrieve a database corresponding to the question type, and generate the verification result corresponding to each verification question.

[0021] Specifically, based on the verification result, the basic response is analyzed and corrected to generate an accurate result to solve the hallucination problem, including:

[0022] Using a conditional probability algorithm to score and sort the verification results, with higher scores being ranked first;

[0023] A plurality of verification results are screened and compared with the basic response, and the basic response is optimized and adjusted according to the verification results to generate the accurate result.

[0024] Specifically, the first large language model is a large language model enhanced by retrieval generation, and the parameter level is 4 billion to 9 billion.

[0025] Specifically, the second large language model is a large language model enhanced by retrieval generation, with a parameter level of 70 billion.

[0026] A second aspect of the present application is to provide a system for solving the hallucination problem of a large language model, comprising:

[0027] A response module, for making a basic response to an input question in the first large language model;

[0028] A verification module, used for performing type judgment and verification on the basic response based on prompt word engineering and context learning in a second large language model, and generating verification questions and verification results;

[0029] The output module is used to analyze and correct the basic response based on the verification result to generate an accurate result to solve the hallucination problem.

[0030] A third aspect of the present application is to provide a storage medium, which is a non-transitory computer-readable storage medium, storing a program for a method for solving the hallucination problem of a large language model, and when the program is executed by a processor, the following steps are implemented:

[0031] Give a basic response to the initial question in the first large language model;

[0032] In the second large language model, type judgment and verification are performed on the basic response based on prompt word engineering and context learning, and verification questions and verification results are generated;

[0033] Based on the validation results, the basic response is analyzed and corrected to generate accurate results to solve the illusion problem.

[0034] Compared with the prior art, this application mainly has the following beneficial effects:

[0035] (1) Improve the accuracy of output results: By improving the context learning algorithm, the model can generate content that is closer to user expectations and effectively reduce the frequency of hallucination problems, especially the illusion of conflict between input and facts.

[0036] (2) Offline retrieval compatibility: By embedding an external offline knowledge base, the model can perform fact comparison and correction without an online connection, ensuring the reliability of the output and consistency with reality. This also enables the model to still have strong knowledge retrieval and verification capabilities in an offline environment.

[0037] (3) Multi-domain adaptability: The solution proposed in this paper can be effectively applied in different tasks, multi-language and multi-domain environments, enhancing the generalization ability of the model and adapting to complex and changing real-world scenarios.

[0038] (4) Scalability and compatibility: This solution is not only applicable to the current LLMs architecture, but also has good scalability and is compatible with future technology upgrades and knowledge base expansion, providing flexible technical support for subsequent algorithm optimization. BRIEF DESCRIPTION OF THE DRAWINGS

[0039] In order to more clearly illustrate the embodiments of the present application 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, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0040] Figure 1 The present invention is a flowchart of a method for solving the large language model hallucination problem according to an embodiment of the present application.

[0041] Figure 2 This is a flowchart of a verification process in a method for solving the hallucination problem of a large language model according to an embodiment of the present application.

[0042] Figure 3 An architectural diagram of an embodiment of the present application for solving the hallucination problem of large language models.

[0043] Figure 4 This is a principle framework diagram of a method for solving the hallucination problem of large language models according to an embodiment of the present application.

[0044] Figure 5 This is a composition diagram of a system for solving the large language model hallucination problem in the present application.

[0045] Figure 6 This is a schematic diagram of a prompt word template in the customer feedback and product problem analysis model of an embodiment of the present application. DETAILED DESCRIPTION

[0046] The following will be combined with the implementation methods of this application to clearly and completely describe the technical solutions in the implementation methods of this application. Obviously, the described implementation methods are only part of the implementation methods of this application, not all of the implementation methods. Based on the implementation methods in this application, all other implementation methods obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0047] It should be understood that the terms used in this specification of the embodiments of the present application are only for the purpose of describing specific embodiments and are not intended to limit the embodiments of the present application. As used in the specification of the embodiments of the present application and the appended claims, unless the context clearly indicates otherwise, the singular forms of "a", "an" and "the" are intended to include plural forms.

[0048] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0049] Existing large language models (LLMs) usually respond and verify the initial question directly in a large language model, and the generated results do not consider the type of the initial question, or can only solve a single type of initial question, resulting in serious hallucination problems. Therefore, this application considers connecting two large language models with different parameter levels, improving the conventional large language model with a smaller parameter level as the basic response, and then using a large language model with a larger parameter level based on prompt word engineering and context learning as verification, and then comparing and analyzing the verification results and the basic response and correcting them, and finally generating a final result with high accuracy, effectively solving the hallucination problem.

[0050] like Figure 1 As shown, the first aspect of the present application is to provide a method for solving the hallucination problem of a large language model, comprising the following steps:

[0051] S1, basic response to the initial question in the first large language model;

[0052] S2, performing type judgment and verification on the basic response based on prompt word engineering and context learning in a second large language model, generating verification questions and verification results;

[0053] S3. Based on the verification result, the basic response is analyzed and corrected to generate accurate results to solve the hallucination problem.

[0054] Specifically, the first large language model and the second large language model in this application are embedded in multiple databases, including text vector database, graph database and Internet search. Among them, the text vector database vectorizes the text, and then calculates the Euclidean distance to screen out several texts with the highest relevance; the graph database is based on Cyber ​​language, and uses knowledge graph search to perform multi-hop reasoning search; Internet search calls the Google search API for search. In other words, the knowledge bases of the first large language model and the second large language model are consistent, but the parameter levels and logical architectures are different.

[0055] Regarding parameter level settings, since the larger the parameter, the more complex the reasoning steps, the higher the degree of cross-validation to ensure answer consistency, the integration of model sizes at different parameter levels can enhance the reduction of hallucinations. Therefore, the parameter level of the first large language model of the present application is 4 billion to 9 billion, which is only used to generate basic responses, while the parameter level of the second large language model is 70 billion, and it is necessary to further reduce the hallucination problem by superimposing the effect of the first large language model and verifying its results. In addition, the present application also embeds a deep learning model after the second large language model, with a parameter level of 5 billion, which is used to analyze and correct the basic response and generate accurate results to solve the hallucination problem.

[0056] In a large language model (LLM), parameters are internal variables used by the model to understand and generate language. They are the basis for the model to learn knowledge about language structure, grammar, word meaning, and contextual relationships. They are automatically learned by algorithms on large data sets. Types include: weights, biases, attention parameters, embedding matrices, initial hidden state parameters, etc. Generally speaking, they mainly refer to weights and biases. The number (level) of parameters is the main factor affecting the performance of large models. The higher the parameter level and the larger the number, the stronger the LLM's ability to handle complex contexts and language structures, and the more natural and fluent the generated text. In addition, the higher the parameter level and the larger the number, the more details and features the model can remember, making it more intelligent and flexible when generating content.

[0057] In one embodiment, the present application sets two large language models with different parameter magnitudes, the first large language model with a small parameter magnitude gives a basic response, the second large language model verifies the basic response, and then scores and sorts the verification results through a conditional probability algorithm based on a deep learning model, and finally outputs an accurate result by comparing and correcting the verification results with higher scores with the basic response. The present application can not only improve the response speed, but also effectively improve the accuracy and solve the problem of hallucination.

[0058] Specifically, the first large language model is a large language model based on the Transformer architecture after retrieval-augmented generation (RAG), with a parameter level of 4 billion to 9 billion, which is used to make basic responses and basic verifications to the initial questions. The first large language model is based on RAG, which updates the database in real time, constructs a vector database, allows the first large language model to learn new knowledge through RAG, and increases the context window.

[0059] Specifically, constructing the vector library includes establishing an instruction data set from the data set, then labeling the instruction data set, sending the labeled instruction data set to the large language model for fine-tuning, and adding a context window, thereby improving the speed of the basic response of the first large language model and the effect of basic verification.

[0060] Specifically, the second large language model is also a large language model processed by retrieval generation enhancement (RAG), with a parameter level of 70 billion. The second large language model has the same architecture as the first large language model, but has more reasoning layers. A verification mechanism is set up in the second large language model to verify the basic response output by the first large language model. A verification chain based on prompt engineering and in-context learning is used, combined with a deep learning model, to verify the basic response, solve the hallucination problem and generate accurate results.

[0061] like Figure 3 As shown, it is an architectural diagram of a method for solving the hallucination problem of a large language model of the present application. Before inputting the problem into the first large language model, the present application firstly enhances the RAG, adds a context window, and fine-tunes the knowledge of the model to preliminarily implement the optimization of the first large language model and the second large language model. The first large language model based on the basic language large model gives a basic response, and then calls the API through a verification chain method based on prompt word engineering and workflow function calls (based on context learning), connects to the application, accurately reduces the probability of hallucination problems, and improves the accuracy of the final output results.

[0062] Specifically, Figure 2 As shown, step S2, performing type judgment and verification on the basic response based on prompt word engineering and context learning in the second large language model, generating verification questions and verification results, includes the following steps:

[0063] S21, based on the prompt word project, judging the question type according to the initial question and the basic response, and generating a verification question list;

[0064] S22. Based on the context learning and according to the question type, execute the workflow, answer the verification question, and generate the verification result.

[0065] Specifically, in one embodiment, the question types include factual questions, multiple-choice questions, and long text questions.

[0066] In one embodiment, according to the method of solving the hallucination problem of large language models in this application, a large model solution for customer feedback and product problem analysis is set up to monitor and analyze customer feedback and product failures. In this large model solution, the underlying architecture adopts the framework design of two large language models in this application, and through prompt word templates and context management technology, efficient customer feedback processing and failure cause analysis are achieved.

[0067] Several different types of questions and agents to handle these questions are set up. Different agents represent different API calls, which can retrieve and analyze the information in the database. For example, after generating a basic response, the second large language model must first determine the type of question based on the initial question and the basic response, access different prompt word templates based on the question type, and call different databases based on the prompt word templates.

[0068] Correspondingly, according to the question type setting, the prompt word project includes prompt word templates for different types of databases, including entity templates, sentence templates and long text templates.

[0069] like Figure 6 As shown, it is a schematic diagram of the prompt word template of the present application in one embodiment. The user inputs the question "How to deal with damaged goods?", the customer feedback and product problem analysis model determines that the question is a long text question, calls the "customer problem analysis agent", and follows the steps given by the prompt word template to retrieve the product return rate data, return reason statistics, product sales volume and other contents, gradually analyze the main return reasons and their distribution, and finally generate a processing report and display it on the main screen.

[0070] This diagram shows the processing of prompt word engineering in different problem scenarios in the customer feedback and product problem analysis model.

[0071] For graph databases, the large language model calls the "entity" prompt word template and uses the Cyber ​​search language to perform entity search on the graph database. For text vector databases, the large language model performs an approximate search on text vectors by calculating the Euclidean distance, sorts vectors with a high degree of similarity, screens out the top five text vectors, and outputs them to the next model. For initial questions that cannot be judged, the large language model directly inputs all the content into the large language model, and outputs it based on the model's own performance, and then processes the results and outputs them to the next model. Therefore, a method for solving the hallucination problem of large language models in the present application can realize multi-task and multi-field processing, such as processing of images or text.

[0072] Specifically, step S21, based on the prompt word project, according to the initial question and the basic response, determines the question type and generates a verification question list, including the following steps:

[0073] S211, splitting the initial question and extracting valid variables according to the prompt word template;

[0074] S212: Search and compare the valid variables to generate a number of verification questions to form the verification question list.

[0075] Compared with the prior art of directly searching and analyzing the initial question, the present application improves the reaction process of the verification chain by first determining the question type, effectively splitting the valid variables in the initial question, and then calling different types of databases through context learning, thereby ensuring a higher processing process and optimizing the reaction time while improving the accuracy of the results.

[0076] Specifically, step S22, based on the context learning and according to the question type, executing the workflow, answering the verification question, and generating the verification result, includes the following steps:

[0077] S221. Setting a context weight mechanism according to the question type;

[0078] S222: Call and search a database corresponding to the question type, and generate the verification result corresponding to each verification question.

[0079] Specifically, in step S22, by setting several layers of context weight mechanisms, the relationship between the judgment result and the basic response can be identified, reducing the input conflict illusion; by adjusting the reasoning mechanism to ensure the logic between the context and the background, the context conflict illusion is reduced.

[0080] Through the optimization and improvement of the context weight mechanism and the reasoning mechanism, the input conflict hallucination and context conflict hallucination are effectively reduced.

[0081] Specifically, step S3, based on the verification result, analyzing and correcting the basic response to generate an accurate result to solve the hallucination problem, includes the following steps:

[0082] S31, scoring and sorting the verification results using a conditional probability algorithm, with higher scores being sorted first;

[0083] S32, screening a number of verification results and comparing them with the basic response, and optimizing and adjusting the basic response according to the verification results to generate the accurate result.

[0084] Specifically, in step S31, the conditional probability algorithm specifically includes:

[0085] Use TF-IDF similarity to obtain a preliminary set of candidate documents for verification results, then score the recalled documents and retain the top documents. k-1 documents, expand these documents with hyperlinks, and then use LLM to score the expanded documents and select the top k-2 and so on until the maximum depth H is reached.

[0086] Given a query q and reasoning path c, conditional probability is used as the basis for scoring the verification results based on the LLM model, which is defined as follows:

[0087] Score q (c) = P LLM (q|τ c ),

[0088] Where P LLM (q|τ c ) is the answer τ of the given model c , the probability that the model generates question q. LLM (q|τ c ), that is, the format of the prompt after the question in the document, is closer to the format of the LLM pre-training corpus (e.g. FAQ), making the model more adaptable to this task.

[0089] The verification results are sorted by scoring, and the top N results with higher scores are screened out, and then compared with the basic response. If the basic response is within the range of the N screened verification results, the combined output is used as the final accurate result. If the basic response is not within the range of the N verification results, the basic response is modified according to the N verification results to contain the accurate information of the N verification results, and then output as the final corrected accurate result.

[0090] Specifically, N can be set according to the actual problem type.

[0091] Specifically, step S3 is based on a deep learning model, and the basic response and basic verification, the verification question list and the corresponding verification results outputted in the first two large language models are cross-validated in the deep learning model.

[0092] This application uses the verification chain method to achieve a balance between model parameters (total parameters of Embedding and Decoder) and response time, and minimize the uncertainty of the answer. This method works best in factual question answering, especially in entity extraction scenarios. Specifically, the total parameters include embedding parameters and (Transformer-Decoder parameters. The Embedding parameters are determined by the vocabulary size and model dimension, and the Decoder parameters are determined by the number of model layers and model dimension.

[0093] Specifically, the first large language model and the second large language model in this application can be deployed through localized frameworks, such as Langchain and Olama. Through local deployment, the offline application of this application can not only retrieve accurate results with lower hallucination problems in the absence of a network environment, but also adapt to the use environment that cannot be connected to the Internet, such as confidentiality and confidentiality.

[0094] like Figure 4 As shown, it is a principle framework diagram of a method for solving the hallucination problem of large language models in this application, which can be called a self-validating execution framework (SVE), which is divided into four stages:

[0095] The first stage: basic response, input the initial question into the first large language model, that is, search in the first large language model, generate a basic response, and perform basic verification, and input both the basic response and basic verification into the second large language model.

[0096] The second stage: verification judgment, based on the prompt word project, according to the initial question and the basic response, judge the question type and generate a verification question list. The verification question list includes several verification questions. The question types include factual questions, multiple choice questions, and long text questions. The prompt word project is set according to the question type, including prompt word templates for different types of databases, including entity templates, sentence templates, and long text templates.

[0097] The third stage: verification execution, based on the context learning according to the verification question list, executing the workflow according to the question type, answering the verification question, and generating the verification result. When executing the workflow, the corresponding API interface is called to query the relevant entity information or data to answer the verification question.

[0098] The fourth stage: accurate response, based on the verification results, the basic response is analyzed and corrected, and an accurate result is generated to solve the hallucination problem, and the relevance ranking is adjusted and refined to improve the accuracy to output the accurate response. The analysis and correction require the use of the initial question, the basic response and basic verification of the first large language model, and the verification question list and corresponding verification results of the second large language model.

[0099] Through the above four-stage processing, the comparison and correction between the two large language models and the output model are connected, based on prompt word engineering and context learning, question type judgment and verification are implemented, and the basic responses are analyzed and corrected, which effectively solves the hallucination problem of large language models, improves the accuracy of the results, and effectively realizes the solution to the problem of large-scale language hallucination in multi-task.

[0100] In addition, since the parameter level of the second large language model designed in this application is large enough, its own logical reasoning ability is strong and it can also have sufficient verification capabilities in a local deployment environment. Therefore, this application can be used in confidential situations, is not restricted by Internet retrieval, and can achieve localized deployment without a network environment.

[0101] In one embodiment, based on the WikiData dataset, the WikiData dataset is divided into a question-answering dataset and a polynomial dataset (also called a discriminant dataset), and the accuracy of the benchmark large language model Qwen2-7B and Qwen2-7B using the SVE framework of the present application are tested. The test results are shown in the following table.

[0102] Table 1

[0103]

[0104] As can be seen from Table 1, the large language model Qwen2-7B that adopts the SVE framework of this application has improved its accuracy from 12% to 79% in the question-answering format, and its accuracy from 5% to 75% in the discriminant format. The number of hallucination answers has been significantly reduced, effectively solving the hallucination problem of large language models.

[0105] In another embodiment, based on the reading comprehension benchmark dataset MultiSpanQA dataset, a test set consisting of 418 questions is used, and the answer to each span is short. The accuracy of the benchmark large language model Qwen2-7B and Qwen2-7B using the SVE framework of this application are also tested, and the test results are shown in the following table.

[0106] Table 2

[0107] LLM method Accuracy (based on MultiSpanQA dataset) Qwen2-7B Zero-shot 20% Qwen2-7B SVE 96%

[0108] As can be seen from Table 2, the large language model Qwen2-7B that adopts the SVE framework of this application has improved its accuracy from 20% to 96% based on the reading comprehension dataset, and the number of hallucination answers has been significantly reduced, effectively solving the hallucination problem of large language models.

[0109] A method for solving the hallucination problem of large language models in this application is based on the strategies and frameworks of localization frameworks (Langchain and Olama), and achieves improved accuracy of model output relative to a baseline model on a given text dataset.

[0110] This application adopts a four-stage self-verification enhancement framework, cross-validation of two large language models, and logical judgment based on prompt word engineering and context learning to effectively reduce the hallucination problem and improve the accuracy of the large language model. Specifically, there are three improvements:

[0111] Improved model framework: By enhancing the contextual understanding ability of the model and designing a multi-level contextual weight mechanism, the model can better identify the relationship between different input information and reduce the probability of input conflict hallucinations.

[0112] Processing flow optimization: Add question type judgment processing process, improve context processing mechanism, especially dynamic adjustment of historical information, so that the model can accurately maintain and apply the logical consistency between the context when processing long texts, and reduce the illusion of context conflict.

[0113] Fact verification: Introducing offline retrieval function and embedding external knowledge base into the generation process, so that the content generated by the model can be compared with external factual knowledge in real time, further reducing the probability of fact conflict illusion, and realizing localized deployment.

[0114] like Figure 5 As shown, the second aspect of the present application is to provide a system for solving the hallucination problem of a large language model, including a response module 10, a verification module 20 and an output module 30. The response module 10 is used to make a basic response to the input question in the first large language model; the verification module 20 is used to perform type judgment and verification based on prompt word engineering and context learning on the basic response in the second large language model, and generate a verification question and a verification result; the output module 30 is used to analyze and correct the basic response based on the verification result, and generate an accurate result to solve the hallucination problem.

[0115] The third aspect of the present application is to provide a storage medium, which is a non-transitory computer-readable storage medium, storing a program for a method for solving the hallucination problem of a large language model, and when the program is executed by a processor, the following steps are implemented:

[0116] S1, basic response to the initial question in the first large language model;

[0117] S2, performing type judgment and verification on the basic response based on prompt word engineering and context learning in a second large language model, generating verification questions and verification results;

[0118] S3. Based on the verification result, the basic response is analyzed and corrected to generate accurate results to solve the hallucination problem.

[0119] In summary, the present application provides a method and system for solving the hallucination problem of large language models, aiming to solve the problems of hallucination in large language models in the prior art, resulting in low credibility of results, single usage environment, limited application, etc. The present application provides a method and system for solving the hallucination problem of large language models by connecting two large language models with different parameter levels, making improvements on the basis of prompt word engineering and context learning, setting a context weight mechanism, adjusting the reasoning mechanism, and integrating various types of databases, which not only reduces the degree of hallucination of large language models and improves the accuracy of results, but also is suitable for use in multiple tasks, multiple scenarios, and multiple fields, and expands compatibility.

[0120] 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 they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should be included in the protection scope of the present invention.

Claims

1. A method for solving the hallucination problem of large language models, characterized in that: The following steps are involved: Give a basic response to the initial question in the first large language model; In the second large language model, type judgment and verification are performed on the basic response based on prompt word engineering and context learning, and verification questions and verification results are generated; Based on the validation results, the basic response is analyzed and corrected to generate accurate results to solve the illusion problem.

2. A method for solving the hallucination problem of large language models according to claim 1, characterized in that: The step of performing type judgment and verification on the basic response based on prompt word engineering and context learning in the second large language model, and generating verification questions and verification results, comprises the following steps: Based on the prompt word engineering, judging the question type according to the initial question and the basic response, and generating a verification question list; Based on the context learning and according to the question type, a workflow is executed to answer the verification question and generate the verification result.

3. A method for solving the hallucination problem of large language models according to claim 2, characterized in that: The question types include factual questions, multiple choice questions, and long text questions.

4. A method for solving the hallucination problem of large language models according to claim 2, characterized in that: The prompt word project includes prompt word templates for different types of databases, including entity templates, sentence templates and long text templates.

5. A method for solving the hallucination problem of large language models according to claim 4, characterized in that: The method of determining the type of question based on the prompt word engineering and generating a verification question list according to the initial question and the basic response includes: Splitting the initial question, and extracting valid variables according to the prompt word template; The valid variables are searched and compared to generate a number of verification questions to form the verification question list.

6. A method for solving the hallucination problem of large language models according to claim 2, characterized in that: The learning based on the context, executing the workflow according to the question type, answering the verification question, and generating the verification result includes: According to the type of question, a context weighting mechanism is set; Call and retrieve a database corresponding to the question type, and generate the verification result corresponding to each verification question.

7. A method for solving the hallucination problem of large language models according to claim 6, characterized in that: Based on the verification result, the basic response is analyzed and corrected to generate an accurate result to solve the hallucination problem, including: Using a conditional probability algorithm to score and sort the verification results, with higher scores being ranked first; A plurality of verification results are screened and compared with the basic response, and the basic response is optimized and adjusted according to the verification results to generate the accurate result.

8. The method for solving the hallucination problem of large language models according to claim 1, characterized in that: The first large-scale language model is a large-scale language model enhanced by retrieval generation, with a parameter level of 4 billion to 9 billion; the second large-scale language model is a large-scale language model enhanced by retrieval generation, with a parameter level of 70 billion.

9. A system for solving the hallucination problem of large language models, characterized in that include: A response module, for making a basic response to an input question in the first large language model; A verification module, used for performing type judgment and verification on the basic response based on prompt word engineering and context learning in a second large language model, and generating verification questions and verification results; The output module is used to analyze and correct the basic response based on the verification result to generate an accurate result to solve the hallucination problem.

10. A storage medium, characterized in that: The storage medium is a non-transitory computer-readable storage medium, storing a program for a method for solving the large language model hallucination problem, and when the program is executed by a processor, the following steps are implemented: Give a basic response to the initial question in the first large language model; In the second large language model, type judgment and verification are performed on the basic response based on prompt word engineering and context learning, and verification questions and verification results are generated; Based on the validation results, the basic response is analyzed and corrected to generate accurate results to solve the illusion problem.

Citation Information

Patent Citations

  • System and method for solving illusion problem of large language model

    CN117540811A

Cited By

  • RAG query method and system capable of inhibiting hallusion problem of generative large model, medium and product

    CN120744049A