Generation method and device of language illusion detection model and electronic equipment
By fine-tuning and fusion processing of multiple large language models, the object detection model is generated, which solves the illusion phenomenon when the existing language models generate text, and improves the detection accuracy and user experience.
Patent Information
- Application Number
- CN202410780312.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-17
- Publication Date
- 2024-11-01
AI Technical Summary
Existing language models are prone to produce superficially coherent but substantially distorted content when generating text, leading to hallucinations. The existing detection methods lack accuracy and reliability, making it difficult to effectively reduce user negative experience.
By acquiring multiple large language models, fine-tuning is used to fine-tuning, and the fine-tuning large language models are fused with model parameters and output results to generate an object detection model to improve the accuracy of hallucination detection.
It improves the accuracy of detection of text data hallucinations, improves the user's experience of language models, and enhances the robustness and generalization capabilities of the model.
Smart Images

Figure CN118885776A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of large language models, and in particular to a method, device and electronic device for generating a language hallucination detection model. Background Art
[0002] In recent years, the rise of large language models (LLMs) has brought about earth-shaking changes in the field of natural language processing (NLP), leading to an unprecedented leap in text generation and understanding capabilities. The breakthrough progress of this technology has greatly enhanced the effectiveness of artificial intelligence systems in performing complex reasoning and problem-solving tasks. However, the current mainstream evaluation system often focuses more on the fluency of the output rather than the accuracy when measuring model performance. This evaluation tendency causes neural networks to sometimes produce content that is seemingly coherent but actually distorted when generating text, which is the so-called "hallucination" phenomenon. In related technologies, methods such as SelfCheckGPT, MIND, and UNIHD can be used to alleviate the language hallucination phenomenon output by language models. Although the above methods have their own unique features in their respective fields, they are all limited by specific rules, structures, or generation quality, resulting in limited processing effects on language hallucination phenomena, and it is difficult to reduce the negative experience of users when receiving the "hallucination" language output by the language model. Summary of the invention
[0003] In view of this, the purpose of the present disclosure is to provide a method, device and electronic device for generating a language hallucination detection model, so as to improve the detection accuracy of hallucination phenomena in text data and enhance the user experience of using the language model.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for generating a language hallucination detection model, the method comprising: obtaining multiple large language models; fine-tuning the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data comprises text data and corresponding labels; the labels are used to indicate whether the text data is distorted; fusing the multiple fine-tuned large language models to obtain a target detection model; the fusion processing comprises model parameter fusion processing, and / or model output result fusion processing.
[0005] In a second aspect, an embodiment of the present disclosure provides a device for generating a language hallucination detection model, the device comprising: a model acquisition module for acquiring multiple large language models; a fine-tuning module for fine-tuning the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data comprises text data and corresponding labels; the labels are used to indicate whether the text data is distorted; a fusion module for fusing the multiple fine-tuned large language models to obtain a target detection model; the fusion processing comprises model parameter fusion processing, and / or model output result fusion processing.
[0006] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method for generating a language hallucination detection model.
[0007] In a fourth aspect, an embodiment of the present invention provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned method for generating a language hallucination detection model.
[0008] The embodiments of the present invention bring the following beneficial effects:
[0009] The above-mentioned method, device and electronic device for generating a language hallucination detection model obtain multiple large language models; fine-tune the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; the multiple fine-tuned large language models are fused to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing. This method improves the detection accuracy of hallucination phenomena in text data and enhances the user experience of language models.
[0010] Other features and advantages of the present disclosure will be described in the following description, and partly become apparent from the description, or understood by practicing the present disclosure. The purpose and other advantages of the present disclosure are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0011] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the specific embodiments of the present disclosure or the technical solutions in the prior art, the drawings required for use in the specific embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present disclosure. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0013] Figure 1 A flowchart of a method for generating a language hallucination detection model provided by an embodiment of the present disclosure;
[0014] Figure 2 A flowchart of another method for generating a language hallucination detection model provided by an embodiment of the present disclosure;
[0015] Figure 3 A schematic diagram of the structure of a device for generating a language hallucination detection model provided by an embodiment of the present disclosure;
[0016] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0017] In order to make the purpose, technical solution and advantages of the embodiments of the present disclosure clearer, the technical solution of the present disclosure will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are part of the embodiments of the present disclosure, rather than all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present disclosure.
[0018] In recent years, the rise of large language models has brought about earth-shaking changes in the field of natural language processing, leading to an unprecedented leap in text generation and understanding capabilities. This breakthrough in technology has greatly enhanced the effectiveness of artificial intelligence systems in performing complex reasoning and problem-solving tasks. However, the current mainstream evaluation system tends to focus more on the fluency of the output rather than the accuracy when measuring model performance. This evaluation tendency causes neural networks to sometimes produce seemingly coherent but essentially distorted content when generating text, which is the so-called "hallucination" phenomenon. Automatic identification of such hallucination content is still a major challenge facing the industry.
[0019] Although previous studies have explored the roots of hallucinations in smaller-scale language models and specific tasks, there are still significant deficiencies in understanding the specific characteristics of hallucinations that may be generated by large language models (LLMs) and their universality. In practical applications, neural models tend to generate grammatically fluent but factually incorrect outputs, and this bias exacerbates the complexity of the hallucination problem. For example, in a game question-and-answer scenario, an intelligent assistant is required to accurately answer players' questions. Wrong answers will mislead players and give them a bad experience. Therefore, it is of great practical significance and application value to detect hallucinations in content generated by large language models (LLMs) in practical applications.
[0020] Regardless of the method used, the core purpose of hallucination detection is to determine whether the content generated by the large model is consistent with the facts. The current methods are SelfCheckGPT, MIND (Modeling INternal states for hallucination Detection of Large Language Models) and UNIHD (Unified Hallucination Detection). Among them, UNIHD can use external resources as the basis for identification; MIND is an unsupervised framework; SelfCheckGPT is a sampling-based method. The three solutions are introduced as follows:
[0021] 1. SelfCheckGPT is an innovative zero-resource fact-checking method that verifies the output of black-box models without relying on external databases. If the large language model (LLM) has a full understanding of a specific concept, the responses obtained through sampling will show consistency and similarity, thereby confirming the facts stated. However, when faced with fictional or non-existent facts, randomly sampled responses may show divergent and contradictory characteristics. SelfCheckGPT uses this difference to identify fictional content, providing an effective model self-checking mechanism.
[0022] 2. MIND makes full use of the internal state of the LLM to achieve real-time hallucination detection without the need for tedious manual annotation process. This method uses unsupervised modeling to deeply explore the information of the internal state of the large language model to identify and detect possible hallucinations. The MIND framework is concise and efficient, and mainly includes two core steps: the first is the automatic generation of training data. Through this step, MIND can obtain rich and diverse data, providing a solid foundation for subsequent detection; the second is the training of the hallucination classifier. Based on the data generated in the previous step, MIND can train an accurate and efficient classifier, thereby achieving accurate detection of hallucinations.
[0023] 3. UNIHD is a specialized framework for hallucination detection in text generated by large language models (LLMs). The framework can accurately extract key claims in LLM-generated content and verify the authenticity of these claims in parallel through a set of efficient specialized tools. In this way, UNIHD can quickly and accurately identify the presence of hallucinations in text.
[0024] Although SelfCheckGPT, MIND, and UNIHD have their own unique features in their respective fields, they are all limited by specific rules, structures, or generation quality. Although these three technologies approach hallucination detection of large language models from different angles, they all have some inherent limitations. Among them, SelfCheckGPT relies heavily on the generation quality and generalization ability of the model, which have not been fully verified, which limits its practicality to a certain extent. In addition, due to the limitations of sentence-level evaluation, this method may not be able to fully capture the hallucination phenomenon in the text. At the same time, it cannot use external knowledge for verification, further weakening its accuracy. Therefore, when using SelfCheckGPT, its limitations and applicability need to be fully considered.
[0025] Although the MIND method can use the internal state of a large language model for real-time hallucination detection, this dependence may also become its limitation. If the internal state of the model is not captured enough or the model behavior changes, the accuracy of the MIND method will be seriously affected. Therefore, in practical applications, it may be necessary to combine other methods or techniques to make up for this deficiency in order to improve the accuracy and reliability of hallucination detection. In addition, for closed-source large language models, the MIND method may also face access restrictions and cost issues, which are also important factors to consider.
[0026] The UNIHD framework identifies hallucinations by extracting and verifying key statements, but this process is highly dependent on the accuracy and availability of external resources. If these resources are problematic or inaccessible, the performance of UNIHD will be greatly reduced. At the same time, increased inference costs and delays are also one of the problems that this method may face. Although UNIHD strives to cover multiple types of hallucinations, there may still be uncovered categories, which poses certain challenges to its comprehensiveness. Therefore, when using UNIHD for hallucination detection, factors such as its performance, cost, and accessibility need to be considered comprehensively.
[0027] Based on this, the embodiments of the present disclosure provide a method, device, and electronic device for generating a language hallucination detection model. This technology can be applied to various scenarios where language hallucination detection is required.
[0028] In a possible implementation, the present disclosure provides a method for generating a language hallucination detection model. Figure 1As shown, the method comprises the following steps:
[0029] Step S102, obtaining multiple large language models.
[0030] The Big Language Model (LLM) is a deep learning model trained on massive text data. The Big Language Model can not only generate natural language text, but also deeply understand the meaning of the text and handle various natural language tasks such as text summarization, question answering, translation, etc.
[0031] Common large language models include the GPT (Generative Pre-trained Transformers) series, BERT (Bidirectional Encoder Representations from Transformers) series, RoBERTa (Robustly Optimized BERT Pre-training Approach), ALBERT (A Lite BERT), Transformer-XL, ELMo (Embeddings from Language Models), etc.
[0032] Multiple of the above-mentioned large language models can be selected as base models. In the selection process, text data can be input into multiple large language models, and at the same time, a statement requesting judgment on whether the text data is distorted (i.e., the presence of hallucination phenomenon) can be input. The large language will output a reply text for the input text content. Based on whether the reply text judges whether the text content is distorted, several models that can be used as base models can be selected from multiple large language models. When the model does not judge whether the text data is distorted, but outputs irrelevant content, it can be considered that the model is not suitable as a base model. When the model judges whether the text data is distorted, it can be considered that the model can be used as a base model. If the number of large language models that can be used as base models exceeds the required number, a model whose judgment result output by the model is more consistent with whether the text data is actually distorted can also be selected as a base model.
[0033] Step S104, fine-tuning the plurality of large language models using training data to obtain a plurality of fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted.
[0034] The above training data is usually randomly extracted from a sample set. The sample set usually includes multiple text data and labels corresponding to the text data. The label can be "hallucination" or "no hallucination", or "distortion" or "no distortion"; or the label can be 1 or 0, 1 represents distortion, and 0 represents no distortion.
[0035] The labels can be manually annotated for the text data, or determined based on the detection results of other language hallucination detection models. If the labels are determined based on the detection results of other language hallucination detection models, in order to ensure the credibility of the labels, multiple language hallucination detection models can be used to detect whether the text data is distorted. If the detection results are consistent, the corresponding labels are generated for the text data; if the detection results are inconsistent, the text data is abandoned.
[0036] When fine-tuning the large language model through training data, in order to enable the large language model to better handle the task of detecting whether the text data is distorted, prompt words can be used to help the large language model. The prompt words explain the reasons for the distortion of the text data, such as non-conformity with common sense, law, etc. The prompt words can also point out the source of the text data, the field to which it belongs, etc., to help the large language model better understand the text data and the basis for judging distortion, so as to learn how to make a judgment on whether the text data is distorted.
[0037] Step S106, fusing the multiple fine-tuned large language models to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing.
[0038] A large language model usually has model parameters, and the model parameters of all fine-tuned large language models or part of the large language models can be fused. For example, the weight parameters of the large language model can be fused, which can be linear fusion or fusion achieved by difference calculation, which is not limited here.
[0039] It is also possible to fuse the output results of multiple large language models. After training, the accuracy of the large language model in detecting distortion of text data can be verified through verification data, and then the weight of the detection result of the large language model can be determined. Then, based on the weights of multiple fine-tuned large language models, a fusion model of the output results of multiple fine-tuned large language models is established, and the combination of multiple fine-tuned large language models and the fusion model can be used as a target detection model.
[0040] The above-mentioned method for generating a language hallucination detection model obtains multiple large language models; fine-tunes the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; the multiple fine-tuned large language models are fused to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing. This method improves the detection accuracy of hallucination phenomena in text data and enhances the user experience of the language model.
[0041] The following embodiment provides a specific method for fine-tuning multiple large language models through training data.
[0042] In the specific implementation, the large prediction model can be first tuned through the prompt project and the preset sample set, and then the large language model can be fine-tuned through the sample set.
[0043] In the process of tuning the large prediction model through prompt engineering, a high-quality sample set is usually required. In order to distinguish it from the sample set used in subsequent fine-tuning, this sample set is called the second sample set. The sample set includes multiple text data and corresponding labels; the label is used to indicate whether the text data is distorted. Its high quality is reflected in that the label of the text data can indicate the actual situation of whether it is distorted.
[0044] Prompt Engineering, also known as In-Context Prompting, refers to improving prompts through structured text and other methods to guide LLM to output the desired results. Prompt Engineering allows LLM to complete different types of tasks without updating the model weights. Prompt Engineering can implement a variety of prompting methods, such as few-shot prompts, few-shot chained thinking prompts (abbreviated as "thinking chain prompts"), etc.
[0045] Specifically, multiple text data and corresponding labels can be determined from a preset second sample set; prompt data can be constructed based on the determined multiple text data and corresponding labels, and the first fine-tuning processing can be performed on multiple large language models through the prompt data; the prompt data includes a small sample prompt data or a thinking chain prompt data.
[0046] When guiding LLM to judge whether there is hallucination in text data through a few sample prompts, the following text can be used: Please judge whether the content generated by the following large model is hallucination:
[0047] (a) Example 1: xxx, judgment result: exists;
[0048] (b) Example 2: xxx, judgment result: does not exist;
[0049] (c) Example 3: xxx, judgment result: exists;
[0050] (d) Example 4: xxx, please determine whether there is a hallucination.
[0051] It can be seen that the sample data that really allows the big model to judge whether there is hallucination is in the position of "Example 4". The first three directly give the label of whether there is hallucination for the big model to learn.
[0052] The prompt words for applying the thought chain are updated to:
[0053] Please judge whether the following large model generated content is an illusion:
[0054] (a) Example 1: xx, judgment result: exists because yy
[0055] (b) Example 2: xx, judgment result: does not exist, because y
[0056] (c) Example 3: xx, judgment result: exists because yy
[0057] Example 4: xx, please determine whether there is a hallucination.
[0058] After the large language model is fine-tuned, it can better understand the task of judging whether the text content is hallucinating. Then the large language model can be fine-tuned.
[0059] In a specific implementation, a first sample set can be generated based on a preset text data set and multiple large language models; wherein the text data set includes multiple text data generated by a specified model. Then, training data is determined from the first sample set, and multiple large language models are fine-tuned using the training data.
[0060] The text data in the above text data set is usually text data generated by various language models and has no corresponding labels. For the text data in the text data set, the text data is respectively input into multiple large language models to obtain the detection results output by the multiple large language models; the detection results are used to instruct the large language model to determine whether the text data is distorted. Furthermore, the label corresponding to the text data can be determined based on the detection results output by the multiple large language models.
[0061] In the process of determining the label corresponding to the text data, the label of the corresponding text data can be determined based on the ratio of distorted to undistorted text data in multiple detection results. For example, when the number of detection results that determine that the text data is distorted is greater than the number of detection results that determine that the text data is not true, the label of the text data can be determined to be a label indicating that the text data is distorted.
[0062] In a specific implementation, the following method can be used to add labels to text data: if multiple detection results for text data all indicate that the corresponding large language model determines that the text data is distorted, the label of the text data is determined to be the first label; the first label indicates that the text data is distorted; if multiple detection results for text data all indicate that the corresponding large language model determines that the text data is distorted, the label of the text data is determined to be the first label; the first label indicates that the text data is not distorted. This method ensures the consistency of reasoning between multiple large language models.
[0063] In order to ensure the consistency of reasoning of the same model under different model parameters, for each large language model, the text data can be input into the large language model to obtain the first detection result output by the large language model. Then, based on the preset model parameters, the large language model is updated; then the text data is input into the updated large language model to obtain the second detection result output by the updated large language model. The method of updating the model parameters of the large language model to obtain other detection results can be used multiple times, which is related to the model parameters required to be used and is not limited here. In the subsequent process of generating text labels, the detection results obtained by each large language model under different model parameters can also be referred to simultaneously.
[0064] Model parameters usually include the weight and bias of the model. Weight refers to the connection strength between neurons in the model, while bias refers to the output value of each neuron. These parameters are obtained by training on large-scale data sets. By continuously adjusting the values of the parameters, the model can better fit the relationship between input data and output results.
[0065] In the process of performing the second fine-tuning process on the plurality of large language models based on the second training data in the second sample set, the prompt engineering method may be adopted again, which is not limited here.
[0066] The following embodiment provides a specific method for fusing a pair of multiple fine-tuned large language models to obtain a target detection model.
[0067] One fusion method is to perform weighted processing on the model parameters of multiple fine-tuned large language models to obtain processed model parameters; then, based on the processed model parameters, generate a target detection model that is a fusion of multiple fine-tuned large language models. Weighted processing of model parameters can be achieved through linear fusion or interpolation. In the process of model fusion, it is also necessary to resolve interference issues between models by resetting parameters, resolving sign conflicts, and merging only compatible parameters.
[0068] Another fusion method can be: connect multiple fine-tuned large language models with a preset voting model to obtain a target detection model. The voting model is used to determine whether the text data is distorted based on the detection results of the text data output by multiple fine-tuned large language models, and the detection results are used to instruct the corresponding large language model to judge whether the text data is distorted. The voting model is an integrated learning model that follows the principle of minority obeys majority. It reduces the variance by integrating multiple models, thereby improving the robustness and generalization ability of the model. For the classification model: the prediction result of the hard voting method is the prediction result that appears most frequently among the prediction results of multiple models; the soft voting sums the probabilities of various test results and finally selects the class label with the largest sum of probabilities. The soft voting method takes into account the additional information of the prediction probability, so it can obtain a more accurate prediction result than the hard voting method. By forming a target detection model with multiple large language models and a voting model, the detection accuracy of the target detection model for language hallucination phenomena can be improved.
[0069] The present disclosure also provides another method for generating a language hallucination detection model. Figure 1 The method shown is implemented on the basis of
[0070] When large language models are applied to vertical fields for content creation or question-and-answer dialogues, for example, when acting as a game question-and-answer assistant, they often generate fluent but inaccurate content due to a lack of domain knowledge. In actual applications, such as medical, legal, and intelligent customer service, incorrect content guidance can have a greater social impact, so a method is needed to detect whether the content generated by the large model is consistent with the facts. This method can monitor the generated content of the large model, reduce the output of text that does not conform to the facts, and can efficiently and accurately detect whether the text generated by the large model has model hallucinations in the absence of manually annotated data for hallucination detection and lack of factual knowledge.
[0071] The method mainly includes the following points:
[0072] (1) Construction of weakly supervised training data for hallucination detection with large models. This is mainly done by constructing different prompt words and using different base models to generate responses for the same input text data. Hallucination detection training data is constructed based on the consistency of multiple sampled responses generated within a single model and the consistency of responses generated by multiple models. The content that is consistently generated is considered to be hallucination-free, while inconsistent content is considered to be hallucination-free if there are a few different contents.
[0073] (2) Fine-tuning the hallucination detection model: Use the constructed weakly supervised data to fine-tune the parameters of the hallucination detection model by task, data, and base;
[0074] (3) Large model integration: Parameter fusion is performed on the fine-tuned model to improve the accuracy of hallucination detection.
[0075] In specific implementation, the method includes five main steps, such as Figure 2 As shown. First, the effects of multiple LLMs are compared horizontally on the hallucination detection dataset, and the best performing model is selected as the base model (also called the "base model"). This is followed by a prompt engineering module, which includes three functional parts: few-sample prompts, instruction optimization, and thought chain. The third step is the label generation step, which applies the prompt engineering module to perform inference and prediction on a large-scale unlabeled dataset, while ensuring the consistency of reasoning between multiple LLMs and the consistency of reasoning for different parameters of a single LLM. In addition, the label balance of the reasoning results is ensured, and finally a labeled training set is obtained. The fourth step is model training, which uses the LoRA method to fine-tune on the constructed labeled training set. The fifth step is ensemble learning, which fuses the model at the weight level (model fusion) and the prediction level (model voting) to achieve better results.
[0076] About the prompt engineering module: After comparing the effects of multiple LLMs horizontally, the best performing "Mixtral_7Bx2_MoE" model was used as the base, which is a model with a parameter volume of 14B. Then, the design prompt engineering module was used to further improve the effect of the base model.
[0077] Few-shot prompts are a prompt engineering technology based on contextual principles. A small amount of hallucination detection example data is provided in the prompt to guide the base model to better understand and perform hallucination detection. In actual operation, a small batch of high-quality labeled data is first selected as the example set. Then, in the inference and prediction stage, a part of the data points are randomly selected from the example set as prompt samples each time, while ensuring that the number of labels "with hallucination" and "without hallucination" is equal to prevent biased prompt samples from giving LLM reasoning the wrong guidance. In the specific implementation, there are 80 data in the above example set, which is called the "experimental data set" and is also labeled with "whether there is hallucination". The label quality of the experimental data set is very high, and the label quality of the verification data set may be noisy.
[0078] The large language model can also be fine-tuned through instruction optimization. According to the different characteristics of the data points, targeted instruction optimization is performed. The overall idea of optimization describes the instructions in more detail, introducing all the valuable attributes of the data points one by one. For example, the data points to be inferred come from different NLP tasks. For machine translation task data points, three types of information can be obtained: source input, actual translation results, and target translation results. Then the instructions need to explicitly point out the task background of machine translation and the meaning and value of various types of information, and finally guide the LLM to perform hallucination detection based on the actual data point attributes.
[0079] The few-sample prompts introduced earlier are to give LLM several labeled data as examples for reference. The labels are one of "hallucination" and "no hallucination". However, directly using the conclusion of whether there is a hallucination or not to LLM will bring a certain understanding threshold to LLM. The thinking chain inputs the thinking process of judging whether there is a hallucination into LLM, making it easier for it to understand how to accurately judge whether there is a hallucination in the limited prompt samples.
[0080] The sample data of the above few-sample prompts are directly given conclusion labels. In many cases, it is difficult for the large model to learn the internal logic of "why hallucinations exist" and "why hallucinations do not exist". Therefore, the thinking chain prompt method is proposed. Simply put, it provides judgment basis after the label in the example to help the large model learn the internal judgment logic more easily.
[0081] After using hint engineering to improve the performance of the base model, the next step will be to perform inference and prediction on large-scale unlabeled data to obtain weakly supervised labels, and then use these weakly supervised data to fine-tune and optimize the base model, which is equivalent to the above process of generating the second sample set.
[0082] In the process of producing weak labels, in order to improve the reliability of labels, it is necessary to ensure the consistency of reasoning under different LLMs and model parameters. First, carefully select several sets of basic models with top results and use different model parameters to predict the results. Then, select a set of data points with consistent reasoning results under different models and parameters, and then use sampling technology to balance the proportion of categories with and without hallucinations to form the final labeled training set.
[0083] The popular lightweight fine-tuning method LoRA is used, which can effectively reduce the number of parameters to be trained, and the training effect is comparable to the full parameter training method. In the fine-tuning stage, a variety of different parameter settings were adopted, and then the most effective models were selected on the validation set, and then multi-model ensemble learning was carried out in the next step.
[0084] After fine-tuning several independent models with outstanding results, the idea of ensemble learning is then used to fuse the capabilities of multiple models to further improve the accuracy of hallucination detection. This method proposes two fusion schemes, one is model fusion, that is, fusion at the model weight level to obtain a model with completely new parameters, the effect of which is expected to be better than any of the fused models; the other is model voting, which does not create a new model, but votes at the level of inference results of multiple independent models, and the voting results are expected to be better than the predictions of any model before fusion.
[0085] The MergeKit tool supports multiple modes of model fusion, such as SLERP, TIES, and Linear. Generally speaking, Linear is the most basic fusion mode, which performs weighted averaging of weights from different models. Although intuitive, it does not always capture the complex features of the merged models. The SLERP technology alleviates this limitation. Its principle is to smoothly interpolate from two parent models and produce a hybrid model, thereby ensuring that the resulting model captures the essence of the parent model. In addition, the TIES method aims to solve interference problems by resetting parameters, resolving sign conflicts, and merging only compatible parameters. It emphasizes the importance of solving interference problems in model fusion.
[0086] In addition to model-level fusion, this proposal also explores fusion at the model reasoning probability level. First, the weighted sum of the probability values of whether "hallucination exists" for different candidate models is calculated. Second, the combination of linear weights is adjusted on different NLP tasks to determine the best combination for each task. Finally, different tasks are spliced together to obtain the final fusion result. In this way, weighted voting of models can be achieved at the reasoning result level.
[0087] In the absence of annotated data for hallucination detection, this method can automatically construct high-quality weakly supervised data for model training. Unlike other hallucination detection methods, which rely on external factual data (such as knowledge bases, Wikipedia, knowledge graphs, etc.) to verify whether the content generated by the large model is consistent with the facts, this method does not require external data reliance. This method uses a model with relatively small parameters for hallucination detection, and the effect can achieve the effect of fine-tuning a model with larger parameters, and also surpasses the effect of GPT4 using only prompt engineering.
[0088] In this way, the fine-tuned large model is expected to bring breakthrough improvements to these traditional methods when performing text hallucination detection with its deeper language understanding and wide adaptability. It can not only capture more subtle differences between texts, but also show greater flexibility and accuracy in dealing with diverse content and expressions, thus providing a new perspective and possibility for evaluating text consistency.
[0089] The fine-tuned large model combined with multiple strategy voting to obtain results significantly improves the accuracy and reliability of text processing and evaluation. Through meticulous model fine-tuning, the large model has a deeper understanding of language. At the same time, the application of multiple strategy voting makes the evaluation results more comprehensive and objective, reducing the bias that may be caused by a single strategy. This comprehensive approach not only enhances the generalization ability of the model, but also improves its adaptability to diverse text content.
[0090] For the above method embodiments, see Figure 3 A generation device of a language hallucination detection model shown, the device comprising:
[0091] A model acquisition module 302 is used to acquire multiple large language models;
[0092] A fine-tuning module 304 is used to fine-tune the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted;
[0093] The fusion module 306 is used to perform fusion processing on multiple fine-tuned large language models to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing.
[0094] The above-mentioned device for generating a language hallucination detection model obtains multiple large language models; fine-tunes the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; the multiple fine-tuned large language models are fused to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing. This method improves the detection accuracy of hallucination phenomena in text data and enhances the user experience of the language model.
[0095] The above-mentioned fine-tuning module is also used to: generate a first sample set based on a preset text data set and multiple large language models; the text data set includes multiple text data generated by a specified model; determine training data from the first sample set, and fine-tune the multiple large language models through the training data.
[0096] The above-mentioned fine-tuning module is also used for: for the text data in the text data set, inputting the text data into multiple large language models respectively, and obtaining the detection results output by the multiple large language models; the detection results are used to instruct the large language model to determine whether the text data is distorted; based on the detection results output by the multiple large language models, determining the label corresponding to the text data; the label is used to indicate whether the text data is distorted; and determining the text data and the label corresponding to the text data as the data in the first sample set.
[0097] The above-mentioned fine-tuning module is also used for: if multiple detection results for text data all indicate that the corresponding large language model judges that the text data is distorted, then the label of the text data is determined to be a first label; the first label indicates that the text data is distorted; if multiple detection results for text data all indicate that the corresponding large language model judges that the text data is distorted, then the label of the text data is determined to be the first label; the first label indicates that the text data is not distorted.
[0098] The above-mentioned fine-tuning module is also used to: for each large language model, input text data into the large language model to obtain a first detection result output by the large language model; update the large language model based on preset model parameters; input text data into the updated large language model to obtain a second detection result output by the updated large language model.
[0099] The above-mentioned device also includes: a data determination module, which is used to determine multiple text data and corresponding labels from a preset second sample set; a prompt data generation module, which is used to construct prompt data based on the determined multiple text data and corresponding labels, and to tune multiple large language models through the prompt data; the prompt data includes a small sample prompt data or a thinking chain prompt data.
[0100] The above-mentioned fusion module is also used to: perform weighted processing on the model parameters of multiple fine-tuned large language models to obtain processed model parameters; based on the processed model parameters, generate a target detection model formed by the fusion of multiple fine-tuned large language models.
[0101] The above-mentioned fusion module is also used to: connect multiple fine-tuned large language models with a preset voting model to obtain a target detection model; the voting model is used to determine whether the text data is distorted based on the detection results of the text data output by the multiple fine-tuned large language models; the detection results are used to instruct the corresponding large language model to determine whether the text data is distorted.
[0102] This embodiment also provides an electronic device, including a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the above-mentioned method for generating a language hallucination detection model, for example:
[0103] Acquire multiple large language models; fine-tune the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; perform fusion processing on the multiple fine-tuned large language models to obtain a target detection model; the fusion processing includes model parameter fusion processing, and\or model output result fusion processing.
[0104] The above method improves the detection accuracy of hallucination phenomena in text data and enhances the user experience of the language model.
[0105] Optionally, the above-mentioned step of fine-tuning multiple large language models through training data includes: generating a first sample set based on a preset text data set and multiple large language models; the text data set includes multiple text data generated by a specified model; determining training data from the first sample set, and fine-tuning the multiple large language models through the training data.
[0106] Optionally, the step of generating a first sample set based on a preset text data set and multiple large language models includes: for text data in the text data set, inputting the text data into multiple large language models respectively to obtain detection results output by multiple large language models; the detection results are used to instruct the large language model to determine whether the text data is distorted; based on the detection results output by multiple large language models, determining a label corresponding to the text data; the label is used to indicate whether the text data is distorted; and determining the text data and the label corresponding to the text data as data in the first sample set.
[0107] Optionally, the step of determining the label corresponding to the text data based on the detection results output by multiple large language models includes: if multiple detection results for the text data all indicate that the corresponding large language model judges that the text data is distorted, then determining the label of the text data to be a first label; the first label indicates that the text data is distorted; if multiple detection results for the text data all indicate that the corresponding large language model judges that the text data is distorted, then determining the label of the text data to be the first label; the first label indicates that the text data is not distorted.
[0108] Optionally, the above-mentioned step of inputting the text data into multiple large language models respectively to obtain the detection results output by the multiple large language models includes: for each large language model, inputting the text data into the large language model to obtain a first detection result output by the large language model; updating the large language model based on preset model parameters; inputting the text data into the updated large language model to obtain a second detection result output by the updated large language model.
[0109] Optionally, before fine-tuning the multiple large language models through training data, the method further includes: determining multiple text data and corresponding labels from a preset second sample set; constructing prompt data based on the determined multiple text data and corresponding labels, and tuning the multiple large language models through the prompt data; the prompt data includes a small sample prompt data or a thinking chain prompt data.
[0110] Optionally, the step of fusing multiple fine-tuned large language models to obtain a target detection model includes: performing weighted processing on model parameters of the multiple fine-tuned large language models to obtain processed model parameters; and generating a target detection model formed by fusing multiple fine-tuned large language models based on the processed model parameters.
[0111] Optionally, the above-mentioned step of fusing multiple fine-tuned large language models to obtain a target detection model includes: connecting the multiple fine-tuned large language models with a preset voting model to obtain a target detection model; the voting model is used to determine whether the text data is distorted based on the detection results of the text data output by the multiple fine-tuned large language models; the detection results are used to instruct the corresponding large language model to determine whether the text data is distorted.
[0112] See also Figure 4 As shown, the electronic device includes a processor 100 and a memory 101, wherein the memory 101 stores machine executable instructions that can be executed by the processor 100, and the processor 100 executes the machine executable instructions to implement the above-mentioned method for generating a language hallucination detection model.
[0113] Further, Figure 4 The electronic device shown further includes a bus 102 and a communication interface 103 , and the processor 100 , the communication interface 103 and the memory 101 are connected via the bus 102 .
[0114] The memory 101 may include a high-speed random access memory (RAM), and may also include a non-volatile memory, such as at least one disk storage. The communication connection between the system network element and at least one other network element is realized through at least one communication interface 103 (which may be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. may be used. The bus 102 may be an ISA bus, a PCI bus, or an EISA bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0115] The processor 100 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the hardware integrated logic circuit or software instructions in the processor 100. The above processor 100 can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in conjunction with the embodiments of the present disclosure can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module may be located in a storage medium mature in the art, such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory 101, and the processor 100 reads the information in the memory 101 and completes the steps of the method of the above embodiment in combination with its hardware.
[0116] This embodiment also provides a machine-readable storage medium, which stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the above-mentioned method for generating a language hallucination detection model.
[0117] The present disclosure provides a method, device and electronic device for generating a language hallucination detection model, including a computer-readable storage medium storing program code, wherein the program code includes instructions that can be used to execute the method described in the above method embodiments, for example:
[0118] Acquire multiple large language models; fine-tune the multiple large language models through training data to obtain multiple fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; perform fusion processing on the multiple fine-tuned large language models to obtain a target detection model; the fusion processing includes model parameter fusion processing, and\or model output result fusion processing.
[0119] The above method improves the detection accuracy of hallucination phenomena in text data and enhances the user experience of the language model.
[0120] Optionally, the above-mentioned step of fine-tuning multiple large language models through training data includes: generating a first sample set based on a preset text data set and multiple large language models; the text data set includes multiple text data generated by a specified model; determining training data from the first sample set, and fine-tuning the multiple large language models through the training data.
[0121] Optionally, the step of generating a first sample set based on a preset text data set and multiple large language models includes: for text data in the text data set, inputting the text data into multiple large language models respectively to obtain detection results output by multiple large language models; the detection results are used to instruct the large language model to determine whether the text data is distorted; based on the detection results output by multiple large language models, determining a label corresponding to the text data; the label is used to indicate whether the text data is distorted; and determining the text data and the label corresponding to the text data as data in the first sample set.
[0122] Optionally, the step of determining the label corresponding to the text data based on the detection results output by multiple large language models includes: if multiple detection results for the text data all indicate that the corresponding large language model judges that the text data is distorted, then determining the label of the text data to be a first label; the first label indicates that the text data is distorted; if multiple detection results for the text data all indicate that the corresponding large language model judges that the text data is distorted, then determining the label of the text data to be the first label; the first label indicates that the text data is not distorted.
[0123] Optionally, the above-mentioned step of inputting the text data into multiple large language models respectively to obtain the detection results output by the multiple large language models includes: for each large language model, inputting the text data into the large language model to obtain a first detection result output by the large language model; updating the large language model based on preset model parameters; inputting the text data into the updated large language model to obtain a second detection result output by the updated large language model.
[0124] Optionally, before fine-tuning the multiple large language models through training data, the method further includes: determining multiple text data and corresponding labels from a preset second sample set; constructing prompt data based on the determined multiple text data and corresponding labels, and tuning the multiple large language models through the prompt data; the prompt data includes a small sample prompt data or a thinking chain prompt data.
[0125] Optionally, the step of fusing multiple fine-tuned large language models to obtain a target detection model includes: performing weighted processing on model parameters of the multiple fine-tuned large language models to obtain processed model parameters; and generating a target detection model formed by fusing multiple fine-tuned large language models based on the processed model parameters.
[0126] Optionally, the above-mentioned step of fusing multiple fine-tuned large language models to obtain a target detection model includes: connecting the multiple fine-tuned large language models with a preset voting model to obtain a target detection model; the voting model is used to determine whether the text data is distorted based on the detection results of the text data output by the multiple fine-tuned large language models; the detection results are used to instruct the corresponding large language model to determine whether the text data is distorted.
[0127] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0128] In addition, in the description of the embodiments of the present disclosure, unless otherwise clearly specified and limited, the terms "installed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two components. For those skilled in the art, the specific meanings of the above terms in the present disclosure can be understood according to specific circumstances.
[0129] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code.
[0130] In the description of the present disclosure, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of the present disclosure. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0131] Finally, it should be noted that the above embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above embodiments, those skilled in the art should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A method for generating a language hallucination detection model, characterized in that: The method comprises: Get multiple large language models; Fine-tune the plurality of large language models using training data to obtain a plurality of fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; The multiple fine-tuned large language models are fused to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing.
2. The method according to claim 1, characterized in that The step of fine-tuning the plurality of large language models using training data comprises: Based on a preset text data set and a plurality of the large language models, a first sample set is generated; the text data set includes a plurality of text data generated by a specified model; Training data is determined from the first sample set, and a plurality of the large language models are fine-tuned using the training data.
3. The method according to claim 2, characterized in that The step of generating a first sample set based on a preset text data set and a plurality of the large language models comprises: For the text data in the text data set, the text data are respectively input into a plurality of the large language models to obtain detection results output by the plurality of the large language models; the detection results are used to instruct the large language model to determine whether the text data is distorted; Determining a label corresponding to the text data based on the detection results output by the plurality of large language models; the label is used to indicate whether the text data is distorted; The text data and the label corresponding to the text data are determined as data in the first sample set.
4. The method according to claim 3, characterized in that The step of determining a label corresponding to the text data based on the detection results output by the plurality of large language models comprises: If the plurality of detection results for the text data all indicate that the corresponding large language model determines that the text data is distorted, determining that the label of the text data is a first label; the first label indicates that the text data is distorted; If the plurality of detection results for the text data all indicate that the corresponding large language model determines that the text data is distorted, determining that the label of the text data is a first label; the first label indicates that the text data is not distorted; Based on the text data with labels, a second sample set is generated.
5. The method according to claim 3, characterized in that: The step of inputting the text data into the plurality of large language models respectively to obtain the detection results output by the plurality of large language models comprises: For each of the large language models, input the text data into the large language model to obtain a first detection result output by the large language model; Based on preset model parameters, updating the large language model; The text data is input into the updated large language model to obtain a second detection result output by the updated large language model.
6. The method according to claim 1, characterized in that Before fine-tuning the plurality of large language models using training data, the method further includes: Determine a plurality of text data and corresponding labels from a preset second sample set; Prompt data is constructed based on the determined multiple text data and corresponding labels, and multiple large language models are tuned through the prompt data; the prompt data includes a small number of sample prompt data or thought chain prompt data.
7. The method according to claim 1, characterized in that The step of fusing the multiple fine-tuned large language models to obtain a target detection model includes: Performing weighted processing on the model parameters of the plurality of fine-tuned large language models to obtain processed model parameters; Based on the processed model parameters, a target detection model formed by fusing the multiple fine-tuned large language models is generated.
8. The method according to claim 1, characterized in that The step of fusing the multiple fine-tuned large language models to obtain a target detection model includes: The multiple fine-tuned large language models are connected to a preset voting model to obtain a target detection model; the voting model is used to determine whether the text data is distorted based on the detection results of the text data output by the multiple fine-tuned large language models; the detection results are used to instruct the corresponding large language model to determine whether the text data is distorted.
9. A device for generating a language hallucination detection model, characterized in that: The device comprises: Model acquisition module, used to obtain multiple large language models; A fine-tuning module, used to fine-tune the plurality of large language models through training data to obtain a plurality of fine-tuned large language models; the training data includes text data and corresponding labels; the labels are used to indicate whether the text data is distorted; A fusion module is used to perform fusion processing on the multiple fine-tuned large language models to obtain a target detection model; the fusion processing includes model parameter fusion processing and / or model output result fusion processing.
10. An electronic device, characterized in that: It comprises a processor and a memory, wherein the memory stores machine executable instructions that can be executed by the processor, and the processor executes the machine executable instructions to implement the method for generating a language hallucination detection model according to any one of claims 1 to 8.
11. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores machine-executable instructions. When the machine-executable instructions are called and executed by a processor, the machine-executable instructions prompt the processor to implement the method for generating a language hallucination detection model according to any one of claims 1 to 8.
Citation Information
Cited By
Method and device for testing multi-round dialogue ability of large model
CN119066182A
Emergency distortion information identification method and system
CN120744342A
Knowledge cross validation question and answer method and system for reducing illusion of large language model
CN120910218A
Medical relationship extraction method and device, electronic equipment and storage medium
CN120930766A
Method, device and equipment for generating multi-modal visual language model
CN121094125A
