Multi-dimensional confidence fusion large language model uncertainty evaluation method and system

By employing a multi-dimensional confidence fusion method and combining a scoring system at the token level and semantic level, the problem of uncertainty assessment in generative tasks of large language models is solved, enabling the reliability judgment and self-repair capability of generated content. This method is suitable for generative tasks in high-precision scenarios.

CN120873147AActive Publication Date: 2025-10-31QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +3

Patent Information

Application Number
CN202511373773.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-25
Publication Date
2025-10-31
Estimated Expiration
2045-09-25

AI Technical Summary

Technical Problem

Existing large language models suffer from uncertainty issues in generative tasks, especially in high-precision scenarios where it is difficult to effectively assess the reliability of the output content. Existing methods cannot effectively identify local illusions or semantically uncertain fragments, and relying on external knowledge bases makes it difficult to cope with the heterogeneity of real-time generated content.

Method used

A multi-dimensional confidence fusion method is adopted, which combines token-level confidence information with semantic-level clustering consistency to construct a hierarchical uncertainty scoring system. Semantic relationships are judged through a natural language inference model, and the fusion weights are adaptively adjusted by a dynamic fusion strategy driven by entropy and variance to achieve reliability judgment of the generated content.

Benefits of technology

It significantly improves the ability to identify uncertainties and differences in the generation process, enhances the reliability judgment of generated content, strengthens the system's adaptability in high-reliability scenarios, and has self-repair and risk warning capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120873147A_ABST
    Figure CN120873147A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of natural language processing, provides a multi-dimensional confidence fusion large language model uncertainty evaluation method and system, designs a multi-dimensional confidence modeling mechanism, and can perform multi-dimensional confidence modeling on the basis of internal information in a large language model generation process without depending on an external knowledge base. And the reliability of the output content is effectively judged. According to the system, on the basis of a semantic clustering mechanism, a Token-level multi-dimensional confidence modeling method is innovatively introduced, a scoring system fusing factors such as probability centrality, context disturbance sensitivity, generation consistency and language rationality is constructed, the confidence structure of each part of content in model output can be evaluated from the Token level, and the evaluation efficiency is improved. And the discrimination capability of the system on the uncertainty difference in the generation process is obviously improved.
Need to check novelty before this filing date? Find Prior Art

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: 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: 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; 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. 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. 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. 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.

[0009] 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.

[0010] Furthermore, the multi-dimensional scoring results include probability score, consistency score of context perturbation, consistency score of generation, and linguistic rationality score.

[0011] 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.

[0012] Furthermore, the formula for calculating the cluster-level confidence score is as follows: , , , 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.

[0013] Furthermore, the formula for calculating the confidence fusion weight is as follows: , , , , , 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.

[0014] 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: 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. 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. 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.

[0015] A second aspect of the present invention provides a system for evaluating the uncertainty of large language models through multidimensional confidence fusion, comprising: 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. 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. 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. 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. 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.

[0016] A third aspect of the present invention provides a computer-readable storage medium.

[0017] 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.

[0018] A fourth aspect of the present invention provides a computer device.

[0019] 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.

[0020] Compared with the prior art, the beneficial effects of the present invention are: 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.

[0021] 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

[0022] 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.

[0023] Figure 1This is a flowchart of the uncertainty assessment method for large language models with multi-dimensional confidence fusion provided in this embodiment of the invention; 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

[0024] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0025] 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.

[0026] 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.

[0027] 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.

[0028] 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.

[0029] 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.

[0030] 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.

[0031] Example 1 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: 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; 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; 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.

[0032] 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. Specifically, the steps include the following: Step 201: Obtain the token sequence corresponding to each answer and the probability information of each token; 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. 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>(e.g., the start character, end character, and padding character of the model output content), only valid text tokens are retained for confidence evaluation.

[0033] For the i Each answer, its token sequence information is recorded as: , The corresponding list of token probabilities is denoted as: , in, Indicates the first The top-k generation probability of each token, or the score after normalization.

[0034] Step 202: Based on the probability of all tokens in each answer, perform multi-dimensional scoring to obtain probability score, consistency score of question perturbation, consistency score of generation and language rationality score; Specifically, the steps include the following: Step 2021: Based on the probability distribution of the Token among the top-k candidates, construct its probability score index P-score, which is used to express the confidence level of the model in generating the Token at that position. The specific calculation formula is as follows: , in, These are all control coefficients; the recommended values ​​in this embodiment are... , , , The top-1 probability value represents the highest probability value of the current token among the candidates, reflecting the model's tendency to directly select that token. The difference between top1 and top2 is used to measure the difference in selection. The larger the difference, the more confident the model is in selecting the current token. The top-k entropy value represents the degree of dispersion of the candidate distribution. The lower the entropy, the more stable the generation of the token.

[0035] in, The calculation formula is: , in, 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.

[0036] 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.

[0037] 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: Keep the first ji tokens, denoted as . , where i is a random positive integer in this system, between 1 and 5; 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. ; 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: , 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. .

[0038] Ultimately, the overall C-score of this generated content is the average of the scores from the three positions, calculated using the following formula: , 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.

[0039] 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.

[0040] 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: , 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: , 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. , 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.

[0041] 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.

[0042] 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: 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.

[0043] 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: 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: Given the question: {Question_i}; Standard answer: {Answer_i}; 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.

[0044] 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].

[0045] 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.

[0046] Step 203: Combine the multi-dimensional scoring results to perform a weighted calculation to obtain the Token-level confidence score; The formula for calculating the token-level confidence score is: , 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; Considering the characteristics and significance of the scores for each dimension, as shown in Table 1: Table 1. Characteristics and significance of scoring in each dimension

[0047] In this embodiment, the weight ratios are set as follows: Finally, the TCS was calculated.

[0048] 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. Specifically, the steps include the following: 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; 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)". 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.

[0049] Step 302: Based on each semantic cluster obtained by clustering, combine adaptive weight fusion to obtain a cluster-level confidence score; 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: , in, for TCS score, For each semantic cluster The answer in the text; 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.

[0050] 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: , 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: , in, ,for The probability of cluster occurrence has been normalized in the above formula to ensure the final score. .

[0051] 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: , , 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 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.

[0052] 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. 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: 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; The specific calculation formula is as follows: , in, The distribution entropy can measure the degree of dispersion of confidence among samples; , 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; 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: , , 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.

[0053] 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: , 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.

[0054] Step 5: Obtain the uncertainty score based on the confidence score, determine the type of interval 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; 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: , 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: 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. 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. 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; In this embodiment, the first threshold can be 0.25 and the second threshold can be 0.6.

[0055] 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.

[0056] The above method can be achieved using a prompt. A feasible prompt is shown below: Prompt: "As the output module of the uncertainty assessment system, your task is to output the final answer based on the following information;" [Information related to uncertainty scores] Uncertainty score (U): {U}; Confidence interval: {Confident interval / Doubtful interval / Unconfident interval}; [Supporting information for answering related questions] Question: {Question} Answer at low temperatures: {Answer}; The semantic cluster closest to the low-temperature response is: {S0, S1, ..., Sn}; [Repair Information] Number of repairs: {0, 1, 2, 3}; Number of high-temperature samples n: {n}; High-temperature sampling update factor m_t: { } [Output Strategy] 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; 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: ...". 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." 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.

[0057] Example 2 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: 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. 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. 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. 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. 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.

[0058] 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.

[0059] Example 3 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.

[0060] Example 4 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.

[0061] 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.

[0062] 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.

[0063] 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.

[0064] 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.

[0065] 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.

[0066] 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 assessing uncertainty in large language models using multidimensional confidence fusion, characterized in that, include: 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; 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. 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. 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. 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.

2. The method for assessing uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, The step of 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.

3. The method for assessing uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, The multi-dimensional scoring results include probability score, consistency score of context perturbation, consistency score of generation, and linguistic rationality score.

4. The method for evaluating uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, 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.

5. The method for evaluating uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, The formula for calculating cluster-level confidence scores is: , , , 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, where λ represents the adaptive weight. for TCS score, For each semantic cluster The answer in the middle, This represents the semantic cluster with the largest number of samples.

6. The method for evaluating uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, The formula for calculating the confidence fusion weight is: , , , , , 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.

7. The method for evaluating uncertainty in large language models using multidimensional confidence fusion as described in claim 1, characterized in that, The process of determining the credibility of the large model output based on the interval type in which the uncertainty score is located and adopting corresponding response strategies includes: 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. 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. 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.

8. A device for evaluating the uncertainty of a large language model using multidimensional confidence fusion, characterized in that, include: 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. 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. 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. 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. 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.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the method for evaluating uncertainty of large language models with multidimensional confidence fusion as described in any one of claims 1-7.

10. A computer device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps in the method for evaluating uncertainty of a large language model with multidimensional confidence fusion as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Multi-task automatic driving perception model-oriented expected function safety quantification method

    CN119337711A

  • Multi-level track disease identification system based on vehicle body vibration data

    CN119669869A

  • Credibility evaluation method based on large model knowledge generation

    CN119721203A

  • Power distribution equipment state monitoring system and monitoring method based on Internet of Things technology

    CN119936522A

  • Child-oriented text grading method and system based on artificial intelligence

    CN120067322A

Cited By

  • Multi-modal post-fusion method, device and equipment based on consistent auxiliary channel, medium and product

    CN121389028A

  • Method for reducing illusion of large language model

    CN121480738A

  • Fine-grained text uncertainty monitoring method and system based on semantic compression regularization

    CN121722918A