A text hallucination detection method and device based on large language model

Through the text hallucination detection method based on large language models, using prompt engineering and Agent to identify keywords and intentions, and combining the knowledge base and external tools to organize query results, the problem of hallucinations generated by large language models is solved, and the authenticity and authenticity of text content are achieved. Accuracy, suitable for a variety of application scenarios.

CN118535684BActive Publication Date: 2024-10-15SHANDONG INSPUR SCI RES INST CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202410992975.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-24
Publication Date
2024-10-15
Estimated Expiration
2044-07-24

AI Technical Summary

Technical Problem

Large-scale language models can easily introduce imprecise or fictitious information during the text generation process, leading to model hallucination problems. It is difficult to completely eliminate this problem with existing technology.

Method used

Using a text hallucination detection method based on a large language model, the prompt project generates prompt words, identifies keywords, constructs query questions, uses the Agent to perform intent analysis, calls the local knowledge base and external tools for query, organizes the text content, locates and repairs it The hallucination part.

Benefits of technology

It can effectively identify and repair the hallucination content generated by the model to ensure the authenticity and semantic integrity of the information. It has the advantages of simplicity, efficiency and wide application.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535684B_ABST
    Figure CN118535684B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and device for detecting text hallucinations based on a large language model, and relates to the technical field of natural language processing. The device of the present invention constructs a prompt word based on a prompt project to call a large language model for keyword extraction and query question generation, then calls an agent for intent recognition, determines the tools that need to be called, and obtains relevant factual content, and finally performs consistency verification and hallucination repair based on the large model. The present invention utilizes a large language model and Agent, RAG related technologies to solve the problem of hallucinations generated by large model texts, and ensures the authenticity of the content while ensuring that the original semantic information is not lost, and has the advantages of being simple and efficient, simple to maintain, and having a wide range of application scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention discloses a text hallucination detection method and device based on a large language model, and relates to the technical field of natural language processing. Background Art

[0002] In today's rapidly developing field of artificial intelligence, the problem of model hallucination is gradually evolving into a difficult problem that urgently needs to be solved. The so-called model hallucination refers to the fact that when artificial intelligence models process and generate text content, they sometimes create information or statements that are contrary to the real world. This phenomenon is particularly prominent in the application of large language models (LLMs), because they may introduce inaccurate or fictitious information in the text generation process, which has a profound impact on the evaluation and practical application of the model. Although academia and industry are actively seeking effective detection and correction strategies, current solutions still cannot completely eliminate the problem of model hallucination. Summary of the invention

[0003] In view of the problems of the prior art, the present invention provides a method and device for detecting text hallucination based on a large language model, and the technical solution adopted is:

[0004] In a first aspect, a text hallucination detection method based on a large language model comprises:

[0005] S1, generating prompt words by using the prompt engineering, and identifying and extracting keywords from the prompt words;

[0006] S2, constructing a query question based on the keyword, and using the query tool required for the query question as factual evidence;

[0007] S3, forming text content by arranging the factual evidence shown; the arranging includes removing duplicate information and integrating data from different sources;

[0008] S4, according to the text content, locate and identify the hallucination part; and repair according to the hallucination part.

[0009] In some implementations, in S1, generating prompt words by using prompt engineering includes selecting an optimal prompt template through a large language model.

[0010] In some implementations, S2 further includes an intent recognition module, which performs intent analysis through the Agent constructed by the large language model to obtain a query question, wherein the query question includes the user's real needs;

[0011] The Agent is used to identify the user's intention by determining the tool to be called based on the prompt project.

[0012] In some implementations, in S2, the tool query module uses the query tool required for the query question as factual evidence, specifically including:

[0013] Call local knowledge bases and use external tools and APIs to conduct extensive queries to obtain evidence and information related to the query question.

[0014] In a second aspect, an embodiment of the present invention provides a text hallucination detection device based on a large language model, comprising:

[0015] A keyword extraction module, used to generate prompt words using the prompt project, and to identify and extract keywords from the prompt words;

[0016] A query question generating module, used for constructing a query question according to the keywords;

[0017] The tool query module receives the query questions raised by users, and then uses the large language model technology to conduct in-depth analysis of the question content to identify the key points and requirements of the question. Based on the analysis results, it determines which type of query tool needs to be used to obtain the answer;

[0018] The fact and evidence collection module first receives raw data and information from multiple sources, then performs preliminary screening through a series of automated tools to eliminate irrelevant or duplicate content, conducts in-depth analysis of the remaining data, identifies and integrates information from different channels to eliminate inconsistencies between information, and converts data into a structured text format to form text content;

[0019] The consistency verification module is used to locate and identify the hallucination part according to the text content; the hallucination repair module is used to repair according to the hallucination part.

[0020] In some implementations, in the keyword extraction module, generating prompt words by using prompt engineering includes selecting the best prompt template through a large language model.

[0021] In some implementations, the device further includes an intention recognition module, which is used to perform intention analysis through the Agent constructed by the large language model to obtain a query question, wherein the query question includes the user's real needs;

[0022] The Agent is used to identify the user's intention by determining the tool to be called based on the prompt project.

[0023] In some implementations, in the query question generating module, the query tool required for the query question is used as factual evidence, specifically including:

[0024] The tool query module is used to call the local knowledge base and use external tools and APIs to perform extensive queries to obtain evidence and information related to the query question.

[0025] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein when the one or more computer instructions are executed by the processor, the method described in the first aspect above is implemented.

[0026] In a fourth aspect, an embodiment of the present invention provides a computer storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it is used to implement the method described in the first aspect.

[0027] One or more embodiments of the present invention can at least bring the following beneficial effects: the device of the present invention constructs a prompt word based on the prompt project to call a large language model to extract keywords and generate query questions, then calls the Agent to perform intent recognition, determines the tools that need to be called, and obtains relevant factual content, and finally performs consistency verification and hallucination repair based on the large model. The present invention uses a large language model and Agent and RAG related technologies to solve the problem of hallucination generated by large model texts, and ensures the authenticity of the content without losing the original semantic information. It has the advantages of being simple and efficient, simple to maintain, and having a wide range of application scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0029] Figure 1 It is a block diagram of a text hallucination detection method and device based on a large language model provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0030] The technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents the selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present invention.

[0031] Embodiment 1:

[0032] This embodiment provides a text hallucination detection method based on a large language model, including:

[0033] S1, generating prompt words by using the prompt engineering, and identifying and extracting keywords from the prompt words;

[0034] S2, constructing a query question based on the keyword, and using the query tool required for the query question as factual evidence;

[0035] S3, forming text content by arranging the factual evidence shown; the arranging includes removing duplicate information and integrating data from different sources;

[0036] S4, according to the text content, locate and identify the hallucination part; and repair according to the hallucination part.

[0037] Specifically, in S1, the generating of prompt words by using prompt engineering includes selecting the best prompt template through a large language model.

[0038] Specifically, S2 also includes an intention recognition module, which performs intention analysis through the Agent constructed by the large language model to obtain a query question, and the query question includes the user's real needs;

[0039] The Agent is used to identify the user's intention by determining the tool to be called based on the prompt project.

[0040] According to S2, the collected factual evidence materials are systematically organized and analyzed according to the factual evidence shown, and converted into clear and coherent text content. In this process, the module first conducts a comprehensive review of the input data, identifies and removes duplicate information to avoid redundancy and confusion. Then, it carefully integrates the remaining information, organically combines data from different sources, and forms a unified and consistent perspective.

[0041] Specifically, in S2, the tool query module uses the query tool required for the query question as factual evidence, specifically including:

[0042] Call local knowledge bases and use external tools and APIs to conduct extensive queries to obtain evidence and information related to the query question.

[0043] Responsible for accurately matching query questions with corresponding query tools; these tools include but are not limited to local knowledge bases, online databases, fact-checking websites, academic resources, news archives, etc. We carefully select the most appropriate query tools based on the specific type and content of the question to ensure that factual evidence can be retrieved efficiently.

[0044] In addition, the module is equipped with a powerful tool library, which includes a variety of query tools and their corresponding access interfaces. This design is intended to simplify the query process and ensure that users can quickly and accurately obtain the required information.

[0045] Embodiment 2:

[0046] Figure 1 A block diagram of a text hallucination detection device based on a large language model is shown, Figure 1 As shown, the text hallucination detection device based on the large language model provided in this embodiment includes:

[0047] A keyword extraction module, used to generate prompt words using the prompt project, and to identify and extract keywords from the prompt words;

[0048] A query question generating module, used for constructing a query question according to the keywords;

[0049] Tool query module,The tool query module is an important part of the intelligent system. Through a series of carefully designed steps, it ensures that users can obtain accurate and reliable information. First, the module receives the query questions raised by the user, and then uses the large language model technology to conduct an in-depth analysis of the question content to identify the key points and requirements of the question. Next, based on the analysis results, the module determines what type of query tool needs to be used to obtain the answer. After determining the type of query tool, the module searches in the built-in tool library and selects the tool that best suits the current query needs. Once a suitable query tool is found, the module activates the tool, uses its functions to conduct in-depth queries on the question, and provides the query results to the user as factual evidence. In this way, users can not only get answers to their questions, but also these answers are based on reliable query tools and have a high degree of credibility. The whole process is both efficient and accurate, ensuring that users can obtain high-quality information services.

[0050] The fact and evidence collection module is a key component of the information processing system. Its main task is to ensure that the collected information is highly accurate and reliable. The module first receives raw data and information from multiple sources, and then uses a series of automated tools to perform preliminary screening to eliminate irrelevant or duplicate content. Next, the module will conduct an in-depth analysis of the remaining data, identify and integrate information from different channels to eliminate inconsistencies between information. In order to improve the readability and practicality of the information, the module will also convert the data into a structured text format to form text content, which may include summaries, detailed descriptions, and data charts. In addition, the fact and evidence module will interact with the query tool module and use the tools provided by the latter to further collect and verify information, thereby ensuring that the final output text content is not only comprehensive but also accurate and correct, providing decision makers with a solid factual basis.

[0051] The consistency verification module is used to locate and identify the hallucination part according to the text content; the hallucination repair module is used to repair the hallucination part.

[0052] When the device of the present invention works, first, through a carefully designed prompt engineering, a set of efficient prompt word generation mechanism is constructed, and these prompt words are input into the keyword extraction module, which is responsible for accurately identifying and extracting key information from the generated text. Subsequently, these keywords are sent to the query question generation module, which can intelligently construct targeted query questions based on keywords, laying a solid foundation for subsequent information retrieval. Among them, the prompt word generation mechanism is mainly designed and collected by multiple artificial and large models, such as the instruction "help me find the key information in the following article and output it according to comma separation", and then select the best prompt template based on the large language model or the traditional deep learning model; in the keyword extraction module, the large model obtains the key information in the content based on the best prompt template input by the prompt word generation mechanism, and displays the keywords in the form of strings. In the question generation module, based on the output obtained by the large language model and the keyword extraction module, by constructing prompts, such as "help me build as comprehensive query questions as possible based on the following prompt words, each question contains no more than 3 keywords, and all keywords have corresponding questions", relevant query questions are generated for the downstream tool query module to obtain relevant factual evidence.

[0053] In the intention recognition module, the device of the present invention uses the Agent constructed by the large language model to conduct in-depth intention analysis, accurately determine the real needs of the user, and determine the query tool that needs to be called. Among them, the Agent mainly determines the tools that need to be called and recognizes the user's intention based on the prompt project. It can ensure the directionality and accuracy of information retrieval, thereby improving the efficiency of subsequent factual content acquisition.

[0054] The tool query module can not only call the local knowledge base, but also use external tools and APIs to conduct extensive queries to obtain evidence and information closely related to the query question. The acquisition of this information provides a solid foundation for subsequent fact checking and hallucination detection.

[0055] The factual evidence collection module is used to systematically organize and analyze the various types of factual evidence materials collected based on the factual evidence shown, and convert them into clear and coherent text content. In this process, the module will first conduct a comprehensive review of the input data, identify and eliminate duplicate information to avoid redundancy and confusion. Then, it will carefully integrate the remaining information, organically combining data from different sources to form a unified and consistent perspective.

[0056] Responsible for the detailed collation and analysis of the results obtained by the tool query module, including removing duplicate content, merging information from different sources, etc., to ensure the integrity and consistency of factual evidence. This step is an indispensable part of the hallucination detection process and provides accurate factual support for the final hallucination correction.

[0057] The consistency verification module calls the big model based on the big language model prompt project, conducts in-depth analysis of the collected evidence, verifies the consistency of the text content, and identifies and marks potential errors and hallucinations. On this basis, the hallucination repair module is also based on the hallucination repair related prompt project, calls the big model to take effective measures to accurately remove these potential hallucination problems or replace them with factual information to ensure the authenticity and credibility of the text content.

[0058] In summary, the model hallucination detection and correction method and device of the present invention utilizes the powerful generation and language understanding capabilities of the large language model, and through these six carefully designed modules, forms a complete closed loop from text generation to hallucination detection and correction, which not only improves the accuracy of text content, but also provides a new direction for the development of text generation technology, and provides users with convenient and reliable text content hallucination detection and correction services. At the same time, the system also has good scalability and can be applied to different fields and scenarios.

[0059] Embodiment three:

[0060] This embodiment further provides an electronic device, including a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein the one or more computer instructions implement the method of embodiment 1 when executed by the processor;

[0061] In practical applications, the processor can be an application specific integrated circuit (ASIC), a digital signal processor (DSP), a digital signal processing device (DSPD), a programmable logic device (PLD), a field programmable gate array (FPGA), a controller, a microcontroller unit (MCU), a microprocessor or other electronic components to execute the methods in the above embodiments.

[0062] The method implemented in this embodiment is as follows:

[0063] S1, generating prompt words by using the prompt engineering, and identifying and extracting keywords from the prompt words;

[0064] S2, constructing a query question based on the keyword, and using the query tool required for the query question as factual evidence;

[0065] S3, forming text content by arranging the factual evidence shown; the arranging includes removing duplicate information and integrating data from different sources;

[0066] S4, according to the text content, locate and identify the hallucination part; and repair according to the hallucination part.

[0067] Specifically, in S1, the generating of prompt words by using prompt engineering includes selecting the best prompt template through a large language model.

[0068] Specifically, S2 also includes an intention recognition module, which performs intention analysis through the Agent constructed by the large language model to obtain a query question, and the query question includes the user's real needs;

[0069] The Agent is used to identify the user's intention by determining the tool to be called based on the prompt project.

[0070] Specifically, in S2, the tool query module uses the query tool required for the query question as factual evidence, specifically including:

[0071] Call local knowledge bases and use external tools and APIs to conduct extensive queries to obtain evidence and information related to the query question.

[0072] Responsible for accurately matching query questions with corresponding query tools; these tools include but are not limited to local knowledge bases, online databases, fact-checking websites, academic resources, news archives, etc. We carefully select the most appropriate query tools based on the specific type and content of the question to ensure that factual evidence can be retrieved efficiently.

[0073] In addition, the module is equipped with a powerful tool library, which includes a variety of query tools and their corresponding access interfaces. This design is intended to simplify the query process and ensure that users can quickly and accurately obtain the required information.

[0074] Embodiment 4:

[0075] This embodiment further provides a computer storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by one or more processors, the method of the first embodiment is implemented;

[0076] Among them, the computer-readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0077] The method implemented in this embodiment is as follows:

[0078] S1, generating prompt words by using the prompt engineering, and identifying and extracting keywords from the prompt words;

[0079] S2, constructing a query question based on the keyword, and using the query tool required for the query question as factual evidence;

[0080] S3, forming text content by arranging the factual evidence shown; the arranging includes removing duplicate information and integrating data from different sources;

[0081] S4, according to the text content, locate and identify the hallucination part; and repair according to the hallucination part.

[0082] Specifically, in S1, the generating of prompt words by using prompt engineering includes selecting the best prompt template through a large language model.

[0083] Specifically, S2 also includes an intention recognition module, which performs intention analysis through the Agent constructed by the large language model to obtain a query question, and the query question includes the user's real needs;

[0084] The Agent is used to identify the user's intention by determining the tool to be called based on the prompt project.

[0085] Specifically, in S2, the tool query module uses the query tool required for the query question as factual evidence, specifically including:

[0086] Call local knowledge bases and use external tools and APIs to conduct extensive queries to obtain evidence and information related to the query question.

[0087] In the several embodiments provided in the embodiments of the present invention, it should be understood that the disclosed system and method can also be implemented in other ways. The system and method embodiments described above are merely illustrative.

[0088] It should be noted that, in this article, the terms "first", "second", etc. in the specification and claims of this application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. The terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a..." does not exclude the presence of other identical elements in the process, method, article or device including the element.

[0089] Although the embodiments disclosed in the present invention are as above, the above contents are only embodiments adopted for facilitating the understanding of the present invention and are not intended to limit the present invention. Any technician in the technical field to which the present invention belongs can make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in the present invention, but the patent protection scope of the present invention shall still be subject to the scope defined in the attached claims.

Claims

1. A text hallucination detection method based on a large language model, It is characterized in that include: S1, generating prompt words by using the prompt engineering, and identifying and extracting keywords from the prompt words; In S1, the generating of prompt words by using prompt engineering includes selecting the best prompt template by using a large language model; S2, constructs a query question according to the keyword, and uses the query tool required for the query question as factual evidence; S2 also includes an intention recognition module, which obtains a query question through the intention analysis performed by the Agent constructed by the large language model, and the query question includes the user's real needs, wherein the Agent is used to identify the user's intention based on the tool that needs to be called by the prompt project; In S2, the tool query module uses the query tool required for the query question as factual evidence, specifically including: calling a local knowledge base, using external tools and APIs for extensive queries; S3, forming text content by arranging the factual evidence shown; the arranging includes removing duplicate information and integrating data from different sources; S4, according to the text content, locate and identify the hallucination part; and repair according to the hallucination part.

2. A text hallucination detection device based on a large language model, It is characterized in that include: A keyword extraction module, used to generate prompt words using the prompt project, and to identify and extract keywords from the prompt words; In the keyword extraction module, the generation of prompt words by using the prompt engineering includes selecting the best prompt template through a large language model; A query question generation module is used to construct a query question according to the keyword; the device also includes an intention recognition module, which is used to perform intention analysis through the Agent constructed by the large language model to obtain a query question, wherein the query question includes the user's real needs, wherein the Agent is used to identify the user's intention based on the tool that needs to be called by the prompt project; The tool query module receives the query questions raised by users, and then uses the large language model technology to conduct in-depth analysis of the question content to identify the key points and requirements of the question. Based on the analysis results, it determines which type of query tool needs to be used to obtain the answer; The fact and evidence collection module first receives raw data and information from multiple sources, then performs preliminary screening through a series of automated tools to eliminate irrelevant or duplicate content, conducts in-depth analysis of the remaining data, identifies and integrates information from different channels to eliminate inconsistencies between information, and converts data into a structured text format to form text content; The consistency verification module is used to locate and identify the hallucination part according to the text content; the hallucination repair module is used to repair according to the hallucination part.

3. The device according to claim 2, It is characterized in that In the query question generation module, the query tools required for the query question are used as factual evidence, specifically including: The tool query module is used to call the local knowledge base and use external tools and APIs to perform extensive queries to obtain evidence and information related to the query question.

4. An electronic device, It is characterized in that It comprises a memory and a processor, wherein the memory is used to store one or more computer instructions, wherein when the one or more computer instructions are executed by the processor, the text hallucination detection method based on a large language model as described in any one of the above claims 1 is implemented.

5. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it is used to implement the text hallucination detection method based on a large language model as described in any one of the above claims 1.

Citation Information

Patent Citations

  • Method and system for solving illusion problem of large legal language model

    CN117744802A

  • Big language model illusion relieving scheme based on citation correction

    CN117910449A

  • Method and system for checking and relieving hallusion of large language model by using external knowledge base

    CN117932086A

  • Large model illusion detection method and device, computer equipment and storage medium

    CN117972033A

  • Method and device for illusion detection and restoration in text generation task

    CN117973564A