A Method and System for Uncertainty Assessment of Large Language Models Using Multidimensional Confidence Fusion
By employing a multi-dimensional confidence fusion method that combines token-level probabilistic information and semantic-level clustering, the uncertainty problem in generative tasks of large language models is solved, enabling the determination of the reliability of generated content and making it suitable for applications in high-reliability scenarios.
Patent Information
- Application Number
- CN202511373773.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-25
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2045-09-25
AI Technical Summary
Existing large language models suffer from uncertainty issues in generative tasks, especially in high-precision scenarios such as medicine, law, and finance. Existing methods struggle to effectively identify local illusions or semantic uncertainties in the model output, and methods that rely on external knowledge bases are ill-equipped to handle the heterogeneity and fine-grained localization of real-time generated content.
A multi-dimensional confidence fusion method is adopted to construct a hierarchical uncertainty scoring system by using token-level probability information and semantic-level clustering consistency. This system combines natural language inference models to judge semantic relationships and dynamically adjusts the fusion weights to achieve reliability judgment of generated content.
It significantly improves the ability to identify uncertainties and differences in the generation process, enhances the reliability and stability of the generated content, and is suitable for high-reliability scenarios, especially in fields such as question-and-answer systems, intelligent assistants, medical prediction, and legal assistance.
Smart Images

Figure CN120873147B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of natural language processing technology, and in particular relates to a method and system for uncertainty assessment of large language models with multi-dimensional confidence fusion. Background Technology
[0002] The statements in this section are merely background information related to the present invention and do not necessarily constitute prior art.
[0003] With the widespread application of Large Language Models (LLMs) in the field of natural language processing, these models have demonstrated significant advantages in tasks such as dialogue systems, question answering, and document generation, thanks to the combination of self-attention mechanisms and autoregressive structures. In recent years, conversational models represented by ChatGPT have been applied to scenarios such as multi-turn question answering and knowledge extraction, while language models represented by Claude et al. have been widely used in professional tasks such as code generation and assisted programming.
[0004] Nevertheless, the output of large language models in generative tasks still suffers from significant uncertainty, with the "hallucination" phenomenon being the most typical. This phenomenon refers to the model's output content not conforming to objective facts or contradicting the semantic logic of the context, severely affecting the accuracy and reliability of the generated text. The hallucination problem is particularly sensitive in high-precision scenarios such as medicine, law, and finance, easily leading to adverse consequences and weakening users' trust in the model's output content.
[0005] Existing technologies primarily attempt to alleviate the aforementioned problems in two directions: First, by comparing the model-generated content with external knowledge bases or combining it with retrieval enhancement mechanisms (RAG) to assess the factual consistency of the generated results; second, by using Natural Language Inference (NLI) models to determine the semantic relationships between generated answers, or by indirectly evaluating the consistency and stability of the model output through methods such as semantic clustering. For example, the Self-Entailment (SE) method generates multiple sets of candidate answers using low-temperature and high-temperature settings, and uses their semantic implication relationships to determine the confidence level of the model output.
[0006] However, existing methods still have the following limitations: On the one hand, knowledge base-based comparison methods rely on knowledge coverage and update frequency, making it difficult to cope with the heterogeneity of real-time generated content, and they are significantly inadequate in long texts and fine-grained localization. On the other hand, semantic clustering methods mostly process responses as a whole, ignoring the generation dynamics and confidence features at the token level within the model, and failing to identify local illusions or semantically uncertain fragments in the responses. Therefore, current methods have not yet established an effective hierarchical fusion mechanism, and it is still difficult to output confidence from the collaborative modeling of the token layer and semantic layer, limiting the adaptability of large language models in high-reliability scenarios. Summary of the Invention
[0007] To address at least one of the technical problems mentioned above, this invention provides a method and system for evaluating the uncertainty of large language models through multi-dimensional confidence fusion. This method combines token-level confidence information and semantic-level clustering consistency during the language model generation process to construct a hierarchical and interpretable uncertainty scoring system, thereby improving the ability to judge the reliability of generated content.
[0008] To achieve the above objectives, the present invention adopts the following technical solution:
[0009] The first aspect of the present invention provides a method for uncertainty assessment of large language models using multidimensional confidence fusion, comprising the following steps:
[0010] Based on the received user questions and the large language model, a baseline answer at a low temperature and multiple sampled answers at a set temperature are generated;
[0011] Obtain the token sequence and probability information of each token corresponding to each answer. Based on the probability of all tokens in each answer, perform multi-dimensional scoring. Combine the multi-dimensional scoring results and perform weighted calculation to obtain the token-level confidence score.
[0012] Calculate the semantic relationships among all high-temperature sampled responses, cluster the results into several semantic clusters, and obtain a cluster-level confidence score by combining adaptive weight fusion for each semantic cluster obtained from the clustering.
[0013] The distribution entropy of the confidence level at the token level and the variance of the confidence level at the cluster level are calculated respectively. The confidence fusion weight is determined based on the distribution entropy of the confidence level at the token level and the variance of the confidence level at the cluster level. The final confidence score is obtained by combining the semantic cluster aggregation score, the cluster layer confidence score and the corresponding confidence fusion weight.
[0014] The uncertainty score is obtained based on the confidence score. The confidence of the large model output is determined according to the type of interval in which the uncertainty score is located, and corresponding response strategies are adopted.
[0015] Furthermore, obtaining the token sequence and probability information of each token corresponding to each answer includes: for each answer, setting parameters during generation, and returning the generated content and the scores attribute value through the generate method in the transformers.generation.GenerateDecoderOnlyOutput class in the transformers library. The scores attribute value is the corresponding token sequence and probability information of each token generated when the large language model generates the answer.
[0016] Furthermore, the multi-dimensional scoring results include probability score, consistency score of context perturbation, consistency score of generation, and linguistic rationality score.
[0017] Furthermore, when calculating the semantic relationships between all high-temperature sampled responses, a natural language inference model is used for any two responses at high temperatures. and Perform a two-way implication judgment, that is, if and only if Contains and Contains At that time, two answers are considered semantically equivalent and regarded as members of the same semantic cluster. Several semantic clusters are obtained by constructing a list of all answers, each cluster being... This represents a potential direction for consistent responses.
[0018] Furthermore, the formula for calculating the cluster-level confidence score is as follows:
[0019] ,
[0020] ,
[0021] ,
[0022] in, For each semantic cluster The probability of clustering occurring This represents the average TCS score of all members within the cluster. Indicates low temperature response The confidence score is given by λ, which represents the adaptive weight.
[0023] Furthermore, the formula for calculating the confidence fusion weight is as follows:
[0024] ,
[0025] ,
[0026] ,
[0027] ,
[0028] ,
[0029] in, Weights for token-level confidence. The weights for cluster-level confidence. The distribution entropy of token-level confidence. The variance of the cluster level confidence score, parameter k and m This is a configurable sensitivity factor. Indicates the first 1 answer Token-level confidence score, This represents the sum of the token-level confidence scores for all responses. Indicates an answer The proportion of normalized confidence levels among all responses Indicates the first The answer generated by the large language model Indicates the first The answer generated by the large language model This represents the average confidence level at the cluster level.
[0030] Furthermore, determining the interval type in which the uncertainty score lies, determining the credibility of the large model output based on the corresponding interval type, and adopting corresponding response strategies include:
[0031] If the uncertainty score is less than the first threshold, it is considered a reliable interval, the model generates reliable data, and it is directly displayed. The output content is generated using the low-temperature sampling results.
[0032] If the uncertainty score is greater than or equal to the first threshold but less than the second threshold, the model has a moderate risk of illusion or bias. A prompt message will be displayed to the user, while output is allowed.
[0033] If the uncertainty score is greater than or equal to the second threshold, the model results are highly unreliable or at risk of illusion, triggering a repair mechanism.
[0034] A second aspect of the present invention provides a system for evaluating the uncertainty of large language models through multidimensional confidence fusion, comprising:
[0035] The answer sampling module is used to generate a baseline answer at a low temperature and multiple sampled answers at a set temperature based on the received user question and the large language model.
[0036] The confidence modeling module is used to obtain the token sequence and probability information of each token corresponding to each answer. Based on the probability of all tokens in each answer, it performs multi-dimensional scoring and combines the multi-dimensional scoring results to perform weighted calculation to obtain the token-level confidence score.
[0037] The semantic clustering module is used to calculate the semantic relationships between all high-temperature sampled answers. Based on the calculation results, several semantic clusters are formed. Based on each semantic cluster obtained by clustering, an adaptive weight fusion is combined to obtain a cluster-level confidence score.
[0038] The dynamic fusion scoring module is used to calculate the distribution entropy of the token-level confidence score and the variance of the cluster-level confidence score respectively. Based on the distribution entropy of the token-level confidence score and the variance of the cluster-level confidence score, the confidence fusion weight is determined. The final confidence score is obtained by combining the semantic cluster aggregation score, the cluster layer confidence score and the corresponding confidence fusion weight.
[0039] The uncertainty assessment module is used to obtain an uncertainty score based on the confidence score, determine the type of interval in which the uncertainty score is located, determine the confidence of the output of the large model based on the corresponding interval type, and adopt corresponding response strategies.
[0040] A third aspect of the present invention provides a computer-readable storage medium.
[0041] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps in the large language model uncertainty assessment method with multidimensional confidence fusion as described above.
[0042] A fourth aspect of the present invention provides a computer device.
[0043] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps in the large language model uncertainty assessment method with multidimensional confidence fusion as described above.
[0044] Compared with the prior art, the beneficial effects of the present invention are:
[0045] This invention designs a multi-dimensional confidence modeling mechanism that can effectively determine the reliability of output content based on internal information from the large language model generation process without relying on external knowledge bases. Building upon semantic clustering, the system innovatively introduces a token-level multi-dimensional confidence modeling method, constructing a scoring system that integrates factors such as probability concentration, sensitivity to contextual perturbations, generation consistency, and linguistic rationality. This allows for the evaluation of the confidence structure of each part of the model output at the token level, significantly improving the system's ability to identify uncertainties and differences during the generation process.
[0046] Advantages of additional aspects of the invention will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. Attached Figure Description
[0047] The accompanying drawings, which form part of this invention, are used to provide a further understanding of the invention. The illustrative embodiments of the invention and their descriptions are used to explain the invention and do not constitute an improper limitation of the invention.
[0048] Figure 1 This is a flowchart of the uncertainty assessment method for large language models with multi-dimensional confidence fusion provided in this embodiment of the invention;
[0049] Figure 2 This is a block diagram of a large language model uncertainty assessment system with multi-dimensional confidence fusion provided in an embodiment of the present invention. Detailed Implementation
[0050] The present invention will be further described below with reference to the accompanying drawings and embodiments.
[0051] It should be noted that the following detailed description is illustrative and intended to provide further explanation of the invention. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains.
[0052] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0053] This invention designs a multi-dimensional confidence modeling mechanism that can effectively determine the reliability of output content based on internal information from the large language model generation process without relying on external knowledge bases. Building upon semantic clustering, the system innovatively introduces a token-level multi-dimensional confidence modeling method, constructing a scoring system that integrates factors such as probability concentration, sensitivity to contextual perturbations, generation consistency, and linguistic rationality. This allows for the evaluation of the confidence structure of each part of the model output at the token level, significantly improving the system's ability to identify uncertainties and differences during the generation process.
[0054] First, at the semantic level, this invention combines a natural language reasoning model to determine the semantic relationships between multi-round generated results and designs semantic clustering accordingly. The system assigns weights to different clusters based on three types of relationships: "implication," "neutrality," and "contradiction," achieving explicit modeling of semantic consistency. By incorporating a confidence-weighted mechanism within each cluster, the system can effectively determine the overall semantic reliability of the clusters and exhibits good stability when handling logically complex or open-ended problems.
[0055] Secondly, regarding the fusion mechanism, this invention innovatively proposes a dynamic fusion strategy driven by entropy and variance. This strategy adaptively adjusts the fusion weights based on the concentration of token confidence distribution and the consistency fluctuations within semantic clusters, effectively improving the robustness and interpretability of the evaluation results in uncertain scenarios. Combined with a normalization mechanism to stretch and transform the fusion confidence, the system provides a clear uncertainty score in the output, which helps in constructing subsequent risk perception or response strategy modules.
[0056] Finally, by mapping the final score to different confidence intervals, this invention can effectively drive the response module to automatically perform operations such as risk warning, resampling generation, or output rejection, thereby effectively enhancing the closed-loop control capability of the system.
[0057] Example 1
[0058] like Figure 1 As shown, this embodiment provides a method for evaluating the uncertainty of a large language model through multi-dimensional confidence fusion, including the following steps:
[0059] Step 1: Based on the received user question and the large language model, generate a baseline answer at a low temperature and multiple sampled answers at a set temperature;
[0060] In this embodiment, a user question is received, input into a large language model, and the resulting answer is generated by the large language model at low temperature, as well as an answer generated at a set temperature. n The content of this answer;
[0061] In this context, "Large Language Model" refers to a large language model (LLM); "Temperature" is a coefficient in the output of the large language model, ranging from 0 to 1. It controls the creativity and diversity of the model's output. When the temperature coefficient approaches 1, the model tends to choose from a wider variety of words, resulting in more creative responses but potentially leading to errors. When the temperature coefficient approaches 0, the model is more confident in its first choice, leading to more stable and consistent output, but this may result in overly conservative or repetitive output. In this system... n The initial value is 10, meaning that the question is sampled 10 times and 10 responses are obtained.
[0062] Step 2: Obtain the token sequence and probability information of each token for each answer. Based on the probability of all tokens in each answer, perform multi-dimensional scoring and combine the multi-dimensional scoring results to perform weighted calculation to obtain the token-level confidence score.
[0063] Specifically, the steps include the following:
[0064] Step 201: Obtain the token sequence corresponding to each answer and the probability information of each token;
[0065] In this embodiment, token is a concept in natural language processing. It represents the smallest unit that the model can read / output. For example, for a sentence of Chinese, token can be a character or one of the Unicode characters of that character. For a sentence of English, token can be a word or a letter.
[0066] For each answer, parameters are set during generation. The `generate` method of the `transformers.generation.GenerateDecoderOnlyOutput` class in the `transformers` library returns the generated content and the `scores` attribute value. The `scores` attribute value represents the corresponding token sequence generated by the model during answer generation, along with the probability information for each token. The probability information is a top-k candidate probability list for each token, or equivalently, its corresponding Logits vector. To avoid interference from non-textual symbols in the scoring, the system filters out special tokens (BOS, EOS, etc.). <pad>The start character, end character, and padding character representing the output content of the model are only retained for the valid text Token to participate in the confidence evaluation.
[0067] For the first i The Token sequence information of the answer is recorded as:
[0068] ,
[0069] The corresponding Token probability list is recorded as:
[0070] ,
[0071] wherein, represents the top-k generation probability of the first Token, or the score value after normalization processing.
[0072] Step 202, based on all token probabilities of each answer, multi-dimensional scoring is performed to obtain a probability score, an up-down disturbance consistency score, a generation consistency score, and a language reasonableness score;
[0073] Specifically, the following steps are included:
[0074] Step 2021, based on the probability distribution of the Token in the top-k candidate, a probability score index P-score is constructed, which is used to express the intuitive degree of confidence of the model in generating the Token at this position. The specific calculation formula is:
[0075] ,
[0076] wherein, are control coefficients, and the recommended value in the embodiment is , , , is a top1 probability value, indicating the highest probability value of the current Token in the candidate, reflecting the direct selection tendency of the model for the Token; is the difference between top1 and top2, which is used to measure the selection difference. The greater the difference value, the more confident the model is in selecting the current Token. is a top-k entropy value, representing the dispersion degree of the candidate distribution. The lower the entropy, the more stable the generation degree of the Token.
[0077] wherein, The calculation formula of is:
[0078] ,
[0079] wherein, Indicates the th candidate among the top-k candidates The normalized probability value of each token. k The number of candidates is 5 by default in this embodiment. In this formula, the candidate entropy is used to constrain the dispersion of the probability distribution and occupies the main weight as the dominant indicator. The top-2 difference enhances the discriminative power of the model's selection confidence, while the top-1 probability represents the model's own confidence. The three together reflect the probability credibility when the current token is selected.
[0080] Step 2022: The context perturbation consistency score is used to measure the stability of the language model's probability output when generating tokens at the same location under slightly perturbed input context.
[0081] In the specific implementation process, firstly, a lightweight semantic preservation perturbation is applied to the prefix context of the original generated answer. A fixed prefix perturbation strategy is used to construct the perturbation context for the token sequence. Divided into two parts:
[0082] Keep the first ji tokens, denoted as . , where i is a random positive integer in this system, between 1 and 5;
[0083] Will A randomized strategy is used for perturbation, which includes generating equal-length sequence replacements, selecting equal-length sequence replacements in subsequent text, shuffling the sequence order, and masking the affected sequence to form a perturbation prefix. ;
[0084] The perturbation prefix is then input into the large language model to recalculate the token. The generation probability is denoted as . and the original generation probability For comparison, the specific formula is as follows:
[0085] ,
[0086] In practical implementation, to enhance stability and avoid position-dependent bias, three different token positions are randomly selected in each generated text as evaluation objects, and multiple rounds of perturbation are performed to calculate their perturbation consistency score. .
[0087] Ultimately, the overall C-score of this generated content is the average of the scores from the three positions, calculated using the following formula:
[0088] ,
[0089] in, It means in the first i The three token positions selected in the generated answer, where N represents the number of perturbations performed at each position, with a default value of 3 in this system. Indicates the first r The generation probability under the perturbation. The C-Score calculated by this formula is used to reflect the model's sensitivity to semantic perturbations in the generated sentences. If the difference in generation probability before and after the perturbation is small, it indicates that the model has a high degree of confidence in the generation.
[0090] Step 2023: Generate a consistency score to evaluate the consistency of repeated generation of tokens at a certain position in the current answer under the condition of fixed context prefix.
[0091] Specifically, for the current answer, the system randomly selects a token position j and preserves its prefix context. Using this prefix as input, the large language model is called to perform multiple generation operations. Multiple candidate tokens at position j and their generation probabilities are obtained through sampling, denoted as follows: Where N is the number of generation attempts, which is 10 by default in this system. These probabilities are then compared with the original generation probabilities. The specific calculation formula for participating in the consensus assessment is as follows:
[0092] ,
[0093] in, This is a scaling parameter that controls the sensitivity of the score to fluctuations; the default value in this system is 5.0. The variance, representing the probability value, is calculated using the following formula:
[0094] ,
[0095] Similar to C-Score, to enhance the overall stability of the evaluation, the system can select M tokens from different positions in each answer for this process, calculate the A-score for each token, and take the average as the overall generation consistency score for that answer.
[0096] ,
[0097] A-Score Calculation Formula and Score Range A higher value indicates that the token generation has higher consistency and confidence. This indicator can reflect the internal confidence stability of the model when generating the token, that is, whether it has a consistent generation preference under the same input conditions.
[0098] Step 2024: The language rationality score is used to evaluate the naturalness and rationality of the language in the text generated by the large language model. Its evaluation goal is to measure the reliability of the language in terms of grammatical fluency, word collocation and expression logic of the system output, thereby helping to build a more accurate uncertainty scoring system.
[0099] The evaluation of the naturalness and reasonableness of the generated text refers to using a language scoring model, combined with the idea of reinforcement learning (RL), to systematically pre-train a small-parameter model, specifically including:
[0100] A small parameter model (with no more than 3B parameters, such as the Llama3.2-1B model) is used as the base model. Combined with the publicly available QA dataset, the MiningZhiDaoQACorpus dataset is used in this system to construct training samples.
[0101] Extract 2000 data points from the model dataset, and use a Prompt to guide the construction of positive samples from 1000 of them. A feasible Prompt is shown below:
[0102] Prompt: "Your task is to generate multiple sets of semantically consistent expression variations (including semantic similarity, correct proper nouns, consistency with the question, and absence of grammatical errors or contextual conflicts) around a given question and standard answer. The descriptions can be inconsistent, for example: 'Question: 'Who is the author of *Journey to the West*?', Standard answer: 'Wu Cheng'en', Generated answer 1: 'The author of *Journey to the West* is Wu Cheng'en', Generated answer 2: 'Wu Cheng'en, a writer of the Ming Dynasty', Generated answer 3: 'Wu Cheng'en created *Journey to the West*'." The following is the given question and standard answer:
[0103] Given the question: {Question_i};
[0104] Standard answer: {Answer_i};
[0105] Please return the generated answers in the following list format: [ReGeAnswer_i_1, ReGeAnswer_i_2, ReGeAnswer_i_3]. If the question is incorrect or cannot be answered, return NULL.
[0106] The given standard answer and variant expressions are used as the full-mark answer (score 1) for a given question, resulting in the positive sample dataset. Using a similar method, the model is guided to generate adversarial answers (score 0) from the remaining 1000 answers, which are characterized by obvious grammatical errors, expression biases, or content confusion, serving as the negative sample dataset. The base model is then trained on the combined dataset of the two datasets to obtain a scoring model for evaluating the naturalness of language in any question-answer pair, with an output range of [0,1].
[0107] After training the scoring model, the L-Score is used to score the answers. This scoring model achieves the scoring of language rationality training only through the structure guidance of positive and negative samples without the need for manual annotation, and has high generalization and deployment efficiency.
[0108] Step 203: Combine the multi-dimensional scoring results to perform a weighted calculation to obtain the Token-level confidence score;
[0109] The formula for calculating the token-level confidence score is:
[0110] ,
[0111] in, For the first j One answer, For the first j The P-score of the answer, , and The first j The answer's C-Score, A-Score, and L-Score. These are weight parameters that take into account the meaning of the four dimensions;
[0112] Considering the characteristics and significance of the scores for each dimension, as shown in Table 1:
[0113] Table 1. Characteristics and significance of scoring in each dimension
[0114]
[0115] In this embodiment, the weight ratios are set as follows: Finally, the TCS was calculated.
[0116] Step 3: Calculate the semantic relationships between all high-temperature sampled answers, and cluster them into several semantic clusters based on the calculation results. For each semantic cluster obtained by clustering, combine adaptive weights to obtain a cluster-level confidence score.
[0117] Specifically, the steps include the following:
[0118] Step 301: Use a natural language reasoning model to calculate the semantic relationships between all high-temperature sampled answers, and form several semantic clusters based on the calculation results;
[0119] In this embodiment, based on the Natural Language Inference (NLI) model, the semantic relationship between the answers is calculated. The semantic relationship is divided into three categories: "implication (A implies B, that is, B is synonymous with A, or B can be inferred from A)", "neutrality (A is neutral to B, that is, B is not contradictory to A, but is irrelevant)", and "contradiction (A contradicts B, that is, B is contradictory to A)".
[0120] Using a natural language reasoning model, the responses to any two high-temperature conditions are analyzed. and Perform a two-way implication judgment, that is, if and only if Contains and Contains When two answers are considered semantically "equivalent," they can be regarded as members of the same semantic cluster. It is particularly important to note that the equivalence referred to here is transitive, meaning that if... equivalence , equivalence Then it is determined equivalence By constructing a transitive closure of this "semantic equivalence relation" for all answers, several semantic clusters (i.e., semantic equivalence classes) can be obtained, each cluster... This represents a potential direction for consistent responses.
[0121] Step 302: Based on each semantic cluster obtained by clustering, combine adaptive weight fusion to obtain a cluster-level confidence score;
[0122] The cluster-level confidence score is formed by fusion using an adaptive weighting method, that is, for each semantic cluster that has been clustered... The average TCS score of all members within the cluster is calculated using the following formula:
[0123] ,
[0124] in, for TCS score, For each semantic cluster The answer in the text;
[0125] Based on this, and considering that the low-temperature response reflects the model's initial confidence, the system-generated low-temperature response is introduced. Confidence score Furthermore, a dynamic weighting mechanism based on semantic consistency is constructed.
[0126] Specifically, judge With the semantic cluster with the most samples If any member in the set has a semantic implication relationship, and they mutually imply each other, it means the main output answer is supported by the main semantic cluster and is given a higher weight in the fusion process; if the relationship is neutral, it is given a medium weight; if there is a contradictory relationship, it is not accepted. This weight is denoted as λ, and its value is set according to the NLI judgment result:
[0127] ,
[0128] Finally, the semantic cluster aggregation score and the low-temperature main response confidence score are combined to form a complete clustering layer confidence index. The specific calculation formula is as follows:
[0129] ,
[0130] in, ,for The probability of cluster occurrence has been normalized in the above formula to ensure the final score. .
[0131] Optionally, to filter out anomalous clusters that lack semantic consistency, stability can be assessed based on the normalized entropy of the TCS distribution of responses within the cluster. When the entropy value of a cluster falls below a set threshold... That is, for clusters calculate:
[0132] ,
[0133] ,
[0134] in, For clusters The entropy value reflects the stability or uncertainty of the semantic cluster. To answer the question about the normalized score of the TCS score of s, For one answer within the cluster, In response Token-level confidence score
[0135] like If a cluster is deemed to have a divergent built-in confidence distribution and unstable structure, then that cluster will not participate in the final aggregation calculation. This conclusion is based on experimental results. The recommended value is 0.75.
[0136] Step 4: Calculate the distribution entropy of the token-level confidence score and the variance of the cluster-level confidence score respectively. Determine the confidence fusion weight based on the distribution entropy of the token-level confidence score and the variance of the cluster-level confidence score. Combine the semantic cluster aggregation score, the cluster layer confidence score and the corresponding confidence fusion weight to obtain the final confidence score.
[0137] In this embodiment, the fusion confidence score of the Token level and the cluster level is dynamically calculated based on entropy and variance. Specifically, it refers to fusing the Token-level confidence score (TCS) obtained in step 2 and the cluster-level confidence score in step 3, and calculating the final global confidence score (FinalConfidence) through a dynamic weighting mechanism. The specific steps include the following:
[0138] Step 401: Calculate the distribution entropy of the confidence level at the token level and the variance of the confidence level at the cluster level, respectively;
[0139] The specific calculation formula is as follows:
[0140] ,
[0141] in, The distribution entropy can measure the degree of dispersion of confidence among samples;
[0142] ,
[0143] in, Indicates an answer The proportion of normalized confidence levels among all responses Indicates all answers The sum of confidence scores. The variance represents the average confidence level at the cluster level, and can indicate the discriminative power of the consistent structure within a semantic cluster. This represents the i-th answer generated by the large language model. This indicates the j-th answer generated by the large language model;
[0144] Step 402: Based on the calculated distribution entropy of the token-level confidence and the variance of the cluster-level confidence, set the confidence fusion weights. and , which is used as the subsequent fusion weight, where:
[0145] ,
[0146] ,
[0147] in, Weights for token-level confidence. The weights for cluster-level confidence. for Distribution entropy of confidence level The variance of the confidence level for clustering is represented by the parameter. k and m The sensitivity factor is settable; in this embodiment, it is set to 2.5 and 1.0 respectively.
[0148] Step 403: Combine the semantic cluster aggregation score, the clustering layer confidence score, and the corresponding confidence fusion weights to obtain the final confidence score. The calculation formula is as follows:
[0149] ,
[0150] Fusion weights and It has dynamic fusion characteristics, if or If any item increases, its corresponding weight will decrease, resulting in a score suppression effect to prevent an item from becoming too large and causing inaccurate scoring.
[0151] Step 5: Obtain the uncertainty score based on the confidence score, determine the interval type in which the uncertainty score is located, determine the confidence of the large model output according to the corresponding interval type, and adopt the corresponding response strategy;
[0152] The uncertainty score is obtained from the final confidence level, where the uncertainty score is in the interval (0, 1), i.e., the final confidence level score obtained in step 4. The formula for uncertainty scoring is used:
[0153] ,
[0154] The uncertainty score U is obtained, since FinalConfidence has been normalized to (0, 1). Furthermore, a smaller value indicates a more reliable result. The uncertainty score is divided into three intervals, each corresponding to a different strategy, specifically including:
[0155] If uncertainty score If the value is less than the first threshold, it is considered a reliable interval. The model generates reliable data and displays it directly. The output content is generated using the low-temperature sampling results.
[0156] If uncertainty score If the value is greater than or equal to the first threshold but less than the second threshold, the model has a moderate risk of illusion or bias. A prompt message will be displayed to the user, while output is allowed.
[0157] If uncertainty score If the result is greater than or equal to the second threshold, the model result is highly unreliable or at risk of hallucination, triggering a repair mechanism such as resampling or rejection of the response;
[0158] In this embodiment, the first threshold can be 0.25 and the second threshold can be 0.6.
[0159] The aforementioned trigger repair mechanism specifically involves the system executing a repair process if the uncertainty score of the current round's generated result falls into the unreliable range: first, increasing the number of high-temperature samples, n, to the original value. Multiplied by, rounded down, i.e. In this embodiment The default value is 1.5. After updating the value of n, the system will re-execute the process from step 1 to step 4 and check the interval to which the uncertainty score U belongs. The system will make a maximum of three self-repair attempts. If it falls into the unreliable interval three times in a row, it will determine that the system cannot answer the question or cannot reliably answer it in the current context. The system will then trigger the rejection policy, return a rejection response, and suggest that the user answer the question in another way or rephrase the question.
[0160] The above method can be achieved using a prompt. A feasible prompt is shown below:
[0161] Prompt: "As the output module of the uncertainty assessment system, your task is to output the final answer based on the following information;"
[0162] [Information related to uncertainty scores]
[0163] Uncertainty score (U): {U};
[0164] Confidence interval: {Confident interval / Doubtful interval / Unconfident interval};
[0165] [Supporting information for answering related questions]
[0166] Question: {Question}
[0167] Answer at low temperatures: {Answer};
[0168] The semantic cluster closest to the low-temperature response is: {S0, S1, ..., Sn};
[0169] [Repair Information]
[0170] Number of repairs: {0, 1, 2, 3};
[0171] Number of high-temperature samples n: {n};
[0172] High-temperature sampling update factor m_t: { }
[0173] [Output Strategy]
[0174] If it is within the confidence interval, please generate a semantically consistent final answer based on the question, the answer at low temperature, or the semantic cluster that is closest to the answer at low temperature;
[0175] If the question falls within a suspicious range, please first output a risk warning, and then generate a semantically consistent final answer based on the question, the answer at low temperature, or the semantic cluster closest to the answer at low temperature. For example, "The uncertainty score for this generation is high. Please carefully judge the accuracy and reliability of the generated content! Answer: ...".
[0176] If the problem is in the unreliable range, and the number of repair attempts is less than 3, please inform the user that the current generation is in the unreliable range, and another repair will be performed, returning the next sampling number n*m_t; if the number of repair attempts is equal to 3, inform the user that the problem cannot be solved, for example, "The system-generated answer to this problem contains severe hallucinations and cannot be solved. Please try other methods to solve the problem, or describe the problem again and enter it again."
[0177] This invention demonstrates significant innovation in confidence expression, semantic structure modeling, and output control strategies. By introducing a multi-dimensional token-level scoring system, it effectively improves the expressive power of uncertainty judgment; by combining semantic clustering and soft fusion mechanisms, it addresses the problem of excessive reliance on the token level in existing methods; and by integrating low-temperature semantic support and uncertainty partitioning strategies, it enables the system to possess stronger stability and self-healing capabilities. This method is applicable to various generative task scenarios with high requirements for content accuracy and robustness, and has broad application potential and engineering promotion value, particularly in question-answering systems, intelligent assistants, medical prediction, and legal assistance.
[0178] Example 2
[0179] like Figure 2 As shown, this embodiment provides a device for evaluating the uncertainty of a large language model through multi-dimensional confidence fusion, including:
[0180] The answer sampling module 201 is used to generate a baseline answer at a low temperature and multiple sampled answers at a set temperature based on the received user question and the large language model.
[0181] The confidence modeling module 202 is used to obtain the token sequence corresponding to each answer and the probability information of each token. Based on the probability of all tokens in each answer, it performs multi-dimensional scoring and combines the multi-dimensional scoring results to perform weighted calculation to obtain the token-level confidence score.
[0182] Semantic clustering module 203 is used to calculate the semantic relationship between all high-temperature sampled answers, and to cluster several semantic clusters based on the calculation results. Based on each semantic cluster obtained by clustering, an adaptive weight fusion is combined to obtain a cluster-level confidence score.
[0183] The dynamic fusion scoring module 204 is used to calculate the distribution entropy of the confidence level at the token level and the variance of the confidence level at the cluster level, respectively. Based on the distribution entropy of the confidence level at the token level and the variance of the confidence level at the cluster level, the confidence fusion weight is determined. The final confidence score is obtained by combining the semantic cluster aggregation score, the cluster layer confidence score and the corresponding confidence fusion weight.
[0184] Uncertainty assessment module 205 is used to obtain uncertainty score based on confidence score, determine the interval type of uncertainty score, determine the confidence of large model output according to the corresponding interval type and adopt corresponding response strategies.
[0185] It should be noted that the specific implementation of the large language model uncertainty assessment system with multidimensional confidence fusion in the embodiments of the present invention is similar to the specific implementation of the large language model uncertainty assessment method with multidimensional confidence fusion in the embodiments of the present invention. For details, please refer to the description in the method section. In order to reduce redundancy, it will not be repeated here.
[0186] Example 3
[0187] This embodiment provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps in the large language model uncertainty assessment method with multidimensional confidence fusion as described above.
[0188] Example 4
[0189] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the steps in the large language model uncertainty assessment method with multidimensional confidence fusion as described above.
[0190] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0191] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0192] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0193] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0194] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The program can be stored in a computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. The storage medium can be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0195] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.< / pad>
Claims
1. A method for multi-dimensional confidence fusion large language model uncertainty evaluation, characterized in that, The method comprises the following steps: According to the received user question and the large language model, generate a benchmark answer at low temperature and a plurality of sampling answers at a set temperature; Obtain the Token sequence corresponding to each answer and the probability information of each Token, and perform multi-dimensional scoring based on the probability of all Tokens of each answer, and combine the multi-dimensional scoring results to obtain a Token-level confidence score through weighted calculation; Calculate the semantic relationship between all high-temperature sampling answers, cluster to form a plurality of semantic clusters based on the calculation results, and obtain a cluster-level confidence score based on each semantic cluster obtained by clustering and combined with adaptive weight fusion; Calculate the distribution entropy of the token-level confidence and the variance of the cluster-level confidence, determine the confidence fusion weight based on the distribution entropy of the token-level confidence and the variance of the cluster-level confidence, and obtain the final confidence score by combining the semantic cluster aggregation score, the cluster-level confidence score and the corresponding confidence fusion weight; Based on the confidence score, obtain an uncertainty score, according to the interval type where the uncertainty score is located, determine the credibility of the large model output according to the corresponding interval type and adopt the corresponding coping strategy; The multi-dimensional scoring results include probability score, up-down question disturbance consistency score, generation consistency score and language rationality score, and the language rationality score is used to evaluate the language naturalness and expression rationality of the text generated by the large language model. The cluster-level confidence score calculation formula is: , , , where, is the probability of occurrence of each semantic cluster is the probability of occurrence of each semantic cluster is the average TCS score of all members in the cluster, is the confidence score of the low temperature answer λ is the adaptive weight, is the Token level confidence score of is the Token level confidence score of is the probability of occurrence of each semantic cluster is the probability of occurrence of each semantic cluster is the semantic cluster with the most samples.
2. The method of claim 1, wherein the plurality of dimensions of confidence fusion comprises, The method for obtaining the Token sequence corresponding to each answer and the probability information of each Token comprises the following steps:
3. The method of claim 1, wherein, When computing the semantic relations between all high-temperature sampled answers, a natural language inference model is used to make bidirectional entailment judgments for any two answers at high temperatures, i.e., A entails B if and only if B entails A With A and B are considered to be semantically equivalent and are considered to be members of the same semantic cluster if and only if Entails And Entails A and B, several semantic clusters are constructed by constructing all answers, and each cluster Represents a potential consistent answer direction.
4. The method of claim 1, wherein, For each answer, set the parameters when generating, return the generated content and the scores attribute value through the generate method in the transformers.generation.GenerateDecoderOnlyOutput class in the transformers library, and the scores attribute value is the corresponding Token sequence and the probability information of each Token generated by the large language model when generating the answer. , , , , , wherein, is a weight for Token-level confidence, is a weight for Cluster-level confidence, is a distribution entropy for token-level confidence, is a variance for cluster-level confidence, parameters k and m is a settable sensitivity factor, denotes the Token-level confidence score of the answer, denotes the sum of Token-level confidence scores of all answers, denotes the Token-level confidence score of the answer, denotes the normalized confidence proportion of the answer in all answers, denotes the answer, generated by the large language model, denotes the answer, generated by the large language model, denotes the answer, represents the average value of cluster-level confidence.
5. The method of claim 1, wherein, The confidence fusion weight calculation formula is: According to the interval type where the uncertainty score is located, according to the corresponding interval type, the credibility of the large model output is determined and the corresponding coping strategy is adopted, which comprises the following steps: If the uncertainty score is less than the first threshold value, it is a credible interval, the model generates a credible result, and the low-temperature sampling result is directly displayed to generate the output content; If the uncertainty score is greater than or equal to the first threshold value and less than the second threshold value, the model has a moderate illusion or bias risk, the user is prompted, and the output is allowed; 6. A multi-dimensional confidence fusion large language model uncertainty evaluation apparatus, characterized in that, If the uncertainty score is greater than or equal to the second threshold value, the model result is highly unreliable or has an illusion risk, and the repair mechanism is triggered. The multi-dimensional confidence fusion large language model uncertainty evaluation method according to any one of claims 1-5 comprises: A response sampling module for generating a benchmark answer at low temperature and a plurality of sampling answers at a set temperature according to a received user question and a large language model; The confidence modeling module is configured to obtain a Token sequence corresponding to each answer and probability information of each Token, perform multi-dimensional scoring based on all token probabilities of each answer, and obtain a Token-level confidence score through weighted calculation combined with the multi-dimensional scoring results; The semantic clustering module is configured to calculate semantic relationships between all high-temperature sampling answers, form a plurality of semantic clusters based on a clustering result, obtain a cluster-level confidence score based on each semantic cluster obtained through clustering, and obtain a final confidence score through fusion combined with a semantic cluster aggregation score and the cluster-level confidence score and a corresponding confidence fusion weight; The dynamic fusion scoring module is configured to calculate a distribution entropy of the Token-level confidence and a variance of the cluster-level confidence, determine a confidence fusion weight based on the distribution entropy of the Token-level confidence and the variance of the cluster-level confidence, and obtain the final confidence score through aggregation combined with the semantic cluster aggregation score, the cluster-level confidence score and the corresponding confidence fusion weight. The uncertainty evaluation module is configured to obtain an uncertainty score based on the confidence score, determine an interval type in which the uncertainty score is located, determine a credibility of the large model output according to the corresponding interval type, and adopt a corresponding coping strategy.
7. A computer-readable storage medium having stored thereon a computer program, characterized in that The program is executed by the processor to implement the steps in the multi-dimensional confidence fusion large language model uncertainty evaluation method according to any one of claims 1-5.
8. A computer device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor executes the program to implement the steps in the multi-dimensional confidence fusion large language model uncertainty evaluation method according to any one of claims 1-5.
Citation Information
Patent Citations
Multi-sensing safety monitoring system for pumped storage power station
CN120162750A
Video generation method and apparatus, electronic device and medium
WO2024012289A1