A large language model hallucination detection post-processing method, system, device and medium based on adaptive order statistics aggregation
Patent Information
- Application Number
- CN202610789810.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-03
- Publication Date
- 2026-08-18
AI Technical Summary
[0004]1.全局均值池化(Mean Pooling):会将这一个错误点的信号稀释在499个正常词中,导致漏检(Signal Dilution)
[0026] The beneficial effects of this invention are as follows: This invention achieves accurate extraction of sparse hallucination signals by independently aggregating adaptive dynamic windows and sequential statistics. It avoids the signal dilution problem caused by global mean pooling and solves the false detection problem caused by transient noise interference in global maximum pooling, significantly improving the detection signal-to-noise ratio. Employing a scale-invariant linear scaling strategy, the sampling window can be adaptively adjusted according to the response sequence length, balancing the statistical significance of short texts with the ability to focus on high-risk regions of long texts, achieving universal and robust processing of texts of different lengths.
Smart Images

Figure CN122595033A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence and data mining technology, specifically relating to a post-processing method, system and device for hallucination detection based on adaptive order statistics aggregation of large language models. Background Technology
[0002] In the RAG (Retrieval Enhancement Generation) task, illusion errors exhibit extremely high sparsity. For example, in a 500-word response, there might only be one incorrect year.
[0003] Existing aggregation strategies exhibit significant biases:
[0004] 1. Global Mean Pooling: This dilutes the signal from the error point among 499 normal words, leading to missed detections.
[0005] 2. Global Max Pooling: It is highly susceptible to instantaneous noise interference, leading to false alarms.
[0006] Furthermore, the hallucination dataset naturally suffers from an imbalance between positive and negative samples, leading to low recall rates for conventional classifiers. Therefore, this invention proposes an adaptive aggregation and dynamic calibration scheme. Summary of the Invention
[0007] To address the shortcomings of existing technologies, the present invention aims to provide a post-processing method, system, and device for hallucination detection based on adaptive order statistics aggregation of large language models, thereby overcoming the aforementioned deficiencies in existing technologies.
[0008] To achieve the above objectives, the present invention provides the following technical solution:
[0009] A post-processing method for hallucination detection based on adaptive order statistics aggregation in a large language model includes the following steps:
[0010] Steps for obtaining time-series feature data: Obtain the response sequence generated by the large language model for a specific query text, and extract the time-series feature matrix corresponding to the response sequence. The time-series feature matrix includes the time step length and the preset feature dimension.
[0011] Local salient feature aggregation step: dynamically calculate the sampling window size according to the time step length, independently extract the elements with the highest numerical ranking for each preset feature dimension of the time series feature matrix to form an order statistic, and calculate the mean of the order statistic as the local salient feature of the corresponding preset feature dimension.
[0012] Hybrid feature vector construction steps: Calculate the global statistical moments of the time-series feature matrix under the predetermined statistical dimensions, and concatenate the global statistical moments with the local salient features corresponding to each predetermined feature dimension to obtain the response-level hybrid feature vector;
[0013] Dynamic threshold truncation classification steps: Input the response-level mixed feature vector into a pre-trained tree model classifier to obtain the predicted probability distribution, perform a binarization truncation operation on the predicted probability distribution using a pre-optimized dynamic decision threshold based on the target evaluation index, and output the hallucination judgment result of the response sequence.
[0014] Preferably, in the local salient feature aggregation step, the process of dynamically calculating the sampling window size adopts a scale-invariant linear scaling strategy; a linear mapping relationship is established between the sampling window size and the time step length of the response sequence; by introducing a sensitivity coefficient that characterizes the expected coverage ratio of high-risk signals in the time domain, and a minimum sampling lower bound parameter to ensure statistical significance under short text responses, the maximum value of the combination of the two is calculated as the final sampling window size, while ensuring adaptive adjustment of long and short response sequences.
[0015] Preferably, in the local salient feature aggregation step, the processing logic for independently extracting the elements with the highest numerical ranking to form the order statistics for each preset feature dimension includes: sorting the time-series vector elements corresponding to the current preset feature dimension in the time-series feature matrix in descending order to obtain a sorted vector; extracting the elements in the sorted vector that are in the preceding position and whose number is equal to the size of the sampling window to form the order statistics for this dimension, and calculating the arithmetic mean of the order statistics. By decoupling the selection index in each feature dimension, abnormal peaks on different feature dimensions are allowed to appear in asynchronous time steps.
[0016] Preferably, in the hybrid feature vector construction step, the global statistical moments of the time-series feature matrix under a predetermined statistical dimension include the global mean, global standard deviation, and global maximum value. The global mean is used to characterize the baseline level of the internal state of the model, the global standard deviation is used to characterize the degree of uncertainty fluctuation in the model inference process, and the global maximum value is used to capture and calculate instantaneous extreme outliers.
[0017] Preferably, in the dynamic threshold truncation classification step, the method for obtaining the pre-optimized dynamic decision threshold based on the target evaluation index includes: during the training phase of the classification model, using a grouped cross-validation strategy based on the document identifier of the data source to divide the training data subset and the validation data subset; obtaining the predicted probability output by the tree model classifier on the validation data subset; systematically traversing the candidate truncation thresholds within the global probability interval; calculating the comprehensive evaluation index score corresponding to each candidate truncation threshold; and establishing the candidate truncation threshold that maximizes the comprehensive evaluation index score as the optimal dynamic decision threshold.
[0018] Preferably, in the dynamic threshold truncation classification step, the tree model classifier employs a gradient boosting framework with a regularization term; the gradient boosting framework receives the response-level mixed feature vector as input and directly processes the unnormalized heterogeneous feature set containing probability type, distance type, and divergence type data formed by the feature concatenation process; by performing feature mapping on the unnormalized heterogeneous feature set, it outputs an uncalibrated predicted probability distribution representing that the current response sequence belongs to the hallucination content category.
[0019] A post-processing system for hallucination detection based on adaptive order statistics aggregation in a large language model includes:
[0020] The temporal feature data acquisition module is used to acquire the response sequence and temporal feature matrix generated by the large language model, and dynamically calculate the sampling window size parameter in real time based on the time step length of the response sequence.
[0021] The local salient feature aggregation module is used to independently sort the values for each preset feature dimension of the time-series feature matrix and extract the first elements to form an order statistic, and then calculate the mean of the order statistic as a local salient feature.
[0022] The hybrid feature vector construction module is used to calculate the global statistical moments of the time-series feature matrix respectively, and to concatenate the local salient features with the global statistical moments to construct the response-level hybrid feature vector;
[0023] The dynamic threshold truncation classification module is used to feed the response-level mixed feature vector into a pre-trained tree model classifier to extract the predicted probability distribution, and to perform binarization truncation classification using a dynamic decision threshold established based on maximizing the comprehensive evaluation index of the validation set, and output the corresponding hallucination detection judgment result.
[0024] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the steps of the post-processing method for large language model illusion detection based on adaptive order statistics aggregation as described in any one of claims 1 to 6.
[0025] A computer-readable storage medium storing computer program execution instructions, which, when read and executed by a computer processor, cause the computer processor to implement the entire process operation of a large language model illusion detection post-processing method based on adaptive sequential statistics aggregation.
[0026] The beneficial effects of this invention are as follows: This invention achieves accurate extraction of sparse hallucination signals by independently aggregating adaptive dynamic windows and sequential statistics. It avoids the signal dilution problem caused by global mean pooling and solves the false detection problem caused by transient noise interference in global maximum pooling, significantly improving the detection signal-to-noise ratio. Employing a scale-invariant linear scaling strategy, the sampling window can be adaptively adjusted according to the response sequence length, balancing the statistical significance of short texts with the ability to focus on high-risk regions of long texts, achieving universal and robust processing of texts of different lengths.
[0027] This invention constructs a multi-view response-level feature vector that fuses local salient features with global statistical moments, simultaneously representing local anomaly information and global distribution features, enhancing the completeness and discriminative power of feature representation, and improving the reliability of classification decisions. Employing a gradient boosting tree classifier, it can directly handle heterogeneous features such as probability, distance, and divergence without requiring normalization preprocessing, exhibiting strong adaptability, high computational efficiency, and excellent generalization performance.
[0028] By employing grouped cross-validation and dynamic threshold calibration based on F1 maximization, this invention effectively avoids document-level information leakage, alleviates the imbalance between positive and negative samples in hallucination detection datasets, and optimizes the balance between model precision and recall. Experiments show that this invention can improve the detection AUROC to 0.7947, significantly outperforming traditional pooling strategies. It can be seamlessly integrated into existing hallucination detection systems as a general post-processing module, effectively improving the reliability assurance system of RAG systems and meeting the high-precision, low-latency detection requirements in the practical deployment of large language models. Attached Figure Description
[0029] Figure 1 This is an overall flowchart of the present invention;
[0030] Figure 2 This is a block diagram of the hardware structure of the electronic device of the present invention. Detailed Implementation
[0031] The present invention will be described in detail below with reference to the accompanying drawings and embodiments. The present invention provides a post-processing method, system, and device for hallucination detection based on a large language model using adaptive sequential statistics aggregation. Its core idea is to address the inherent characteristics of highly sparse and localized hallucination signals in retrieval-enhanced generation scenarios by using an adaptive sampling window mechanism to focus on extracting high-risk temporal segments, and to construct a more discriminative response-level feature vector through multi-order statistical fusion. Finally, hallucination determination is completed through the collaborative use of gradient boosting decision trees and dynamic decision thresholds. The entire processing flow proceeds sequentially through four stages: temporal feature acquisition, local salient feature aggregation, hybrid feature vector construction, and dynamic threshold truncation classification. There are clear data dependencies and logical progression relationships between each stage.
[0032] In practical implementation, when the large language model generates a response for a specific query text, the system synchronously records the internal state variables corresponding to each generation time step during the decoding phase, forming a temporal feature matrix X corresponding to the response sequence r. This matrix satisfies... Where T represents the total number of time steps in the response sequence, i.e., the number of generated tokens, and D represents the number of predefined feature dimensions. Each row in the temporal feature matrix represents the feature value of a generation time step t in D feature dimensions, and each column represents the temporal change trajectory of the same feature dimension throughout the entire response generation process. These features can cover multiple types of internal state signals, including log-odds deviation reflecting the difference between context-aware and context-free reasoning paths, trajectory divergence measuring the degree of divergence of the hidden state space trajectory layer by layer, and inter-layer consistency signals obtained through layer-by-layer probability projection. Since different types of features have different dimensional ranges, the collected heterogeneous feature sets are directly entered into subsequent processes without normalization processing, and their dimensional compatibility is naturally guaranteed by the tree model used in the classification stage.
[0033] After obtaining the temporal feature matrix, the next step is to aggregate local salient features. The core motivation for this stage stems from the sparsity inherent in the retrieval of enhanced hallucination signals: in a response sequence containing a large number of words, the words that generate hallucinations are usually only a small minority and concentrated in specific local locations, such as misnamed entities or relational verbs. If the feature values of the entire sequence are directly averaged globally, the signals from these local anomalies will be diluted by a large amount of background signal from normal words, leading to a significant decrease in detection sensitivity; if only the maximum value of the entire sequence is taken, it is easily affected by isolated noise points, generating a large number of false alarms. To resolve this contradiction, this implementation introduces an adaptive sparse aggregation mechanism based on sequence statistics.
[0034] Calculating the sampling window size K is the primary task in this stage. For response sequences of different lengths, a fixed number of samples can lead to unstable statistics for short texts and an imbalance in the coverage ratio for long texts. Therefore, this invention employs a scale-invariant linear scaling strategy to establish a linear mapping relationship between the sampling window size and the time step length T of the response sequence. The calculation formula is as follows:
[0035]
[0036] Where ρ is the sensitivity coefficient, and its value range is (0, 1]. Its physical meaning is the expected coverage ratio of high-risk signals in the time domain. For example, ρ=0.1 means to focus on the top 10% of words in each feature dimension. The minimum sampling lower bound parameter is a positive integer used to ensure that when the response sequence is extremely short, the number of candidate samples obtained after linear scaling is still not lower than this lower bound, thus ensuring that the arithmetic mean of the order statistics remains statistically stable and reliable. For longer response sequences, the number of samples ρ·T increases linearly to maintain a fixed proportion of attention; for shorter sequences, This safety net ensures that the aggregation operation has sufficient sample support. The maximum of the two values is the final sampling window size K, thereby achieving adaptive adjustment for response sequences of varying lengths and ensuring that the extraction logic does not produce systematic deviations as the sequence length changes.
[0037] After determining the sampling window size K, the extraction of order statistics is performed independently for each preset feature dimension d of the time-series feature matrix X. Specifically, firstly, the time-series vector corresponding to the current feature dimension d in the time-series feature matrix is processed. Sort all T elements in descending order to obtain the sorted vector. Then, extract the elements in the sorted vector that are in the preceding order and whose number is exactly equal to the sampling window size K, forming the set of order statistics for this dimension; finally, calculate the arithmetic mean of this set of order statistics as a local salient feature of this feature dimension d. The calculation formula is as follows:
[0038]
[0039] in, This represents the i-th largest feature value after feature dimension d is sorted in descending order, and K is the sampling window size. This represents the locally significant feature value obtained by aggregating this dimension. The advantage of using the arithmetic mean here compared to directly taking the maximum value is that the mean operation has a smoothing effect on single-point extreme noise, while the truncation operation excludes background noise words. The combination of the two allows the final feature value to capture the overall intensity of the local high-risk interval without being dominated by individual noise points.
[0040] It is particularly noteworthy that the aforementioned sequential statistics extraction operation is performed completely independently for different feature dimensions. At a certain time step t, conflict-type feature signals may reach their peak, while at another time step t', instability-type feature signals may reach their peak; the time steps at which the two peaks occur do not necessarily coincide. If it is forced that each feature dimension use the same set of time steps for aggregation, key signals of some dimensions will inevitably be lost. By decoupling the selection index for each feature dimension, that is, allowing abnormal peaks on different feature dimensions to appear in asynchronous time steps, the aggregation method of this invention essentially constitutes a multi-channel soft max pooling, which can capture the union of abnormal signals on all feature dimensions without being limited by their temporal alignment.
[0041] After extracting local salient features for each feature dimension, the next step is to construct a hybrid feature vector. The goal of this stage is to complementarily fuse local signals with global distribution information to form a response-level feature representation that can simultaneously reflect both the local intensity of the hallucination signal and the overall inference state of the model.
[0042] The calculation of global statistical moments is performed on the entire time-series feature matrix X, and is carried out in parallel with the calculation of local salient features. Specifically, global statistical moments include three types of statistics. The first type is the global mean, which is the arithmetic mean of all elements of the time-series feature matrix along the time-step dimension, i.e., the first-order raw moment. Its physical meaning is to reflect the baseline level of the internal state of the model during the entire response sequence generation process, representing the central trend of the feature signal. The second type is the global standard deviation, which is the root mean square deviation of all elements of the time-series feature matrix along the time-step dimension relative to the global mean, i.e., the square root of the second-order central moment. It is used to quantify the degree of fluctuation of the internal state of the model during the entire inference process. A larger standard deviation suggests that the model has higher internal uncertainty when processing the query. The third type is the global maximum, which is the infinite norm of the time-series feature matrix along the time-step dimension. It is used to capture instantaneous extreme anomalies that occur during the calculation process. It has the ability to preserve peak values at a single time step without loss, complementing the local salient features.
[0043] After obtaining the local salient features and global statistical moments corresponding to each feature dimension, all statistics are concatenated to form a response-level mixed feature vector. Let the original feature dimensions be D. Each dimension generates a locally significant feature value. Simultaneously, global statistical moments are calculated on all D dimensions, resulting in a global mean vector, a global standard deviation vector, and a global maximum vector, each of length D. The locally significant features and the three types of global statistical moments are concatenated along the feature dimensions, and then the number of time steps T, representing the overall length of the sequence, is added as a supplementary feature, ultimately forming a response-level hybrid feature vector of dimension 4D+1. This vector contains both locally high-risk signals extracted through adaptive sparse aggregation and a statistical summary reflecting the global state distribution, achieving an organic unity between local anomaly perception and overall risk perception.
[0044] After the response-level mixed feature vector is constructed, the dynamic threshold truncation classification step is initiated to complete the final hallucination detection decision. This stage involves three interconnected steps: selection of the classification model, optimization of the training strategy, and optimization of the decision threshold.
[0045] The classification model employs a gradient boosting framework with a regularization term, specifically the gradient boosting decision tree ensemble algorithm represented by XGBoost. The reason for choosing this type of model is closely related to the heterogeneity of the feature set itself: the response-level mixed feature vector simultaneously contains probability features with values limited to a probability interval, distance features with Euclidean distance between two points, and divergence features with non-negative unbounded divergence. The dimensions and distributions of these three types of features differ significantly. The ensemble model built based on the decision tree partitioning mechanism can directly handle such unnormalized heterogeneous feature sets. By adaptively splitting the numerical interval, it automatically captures the nonlinear interaction relationships between features of different dimensions without requiring normalization or standardization preprocessing of the input features. The gradient boosting framework, by introducing a regularization term to constrain the complexity of the tree, effectively suppresses overfitting under conditions of relatively limited hallucination annotation data, making it particularly suitable for low-resource scenarios with less than ten thousand data points. The final output of the classifier is an uncalibrated predicted probability value representing that the current response sequence belongs to the hallucination content category. This probability value is then transformed into the final binary judgment result after subsequent dynamic decision thresholding.
[0046] During the training phase of the classification model, to address the potential for high similarity among response samples from documents of different sources in the illusion dataset, and to prevent different responses from the same document from falling into the training and validation sets respectively and causing data leakage, this invention employs a grouped cross-validation strategy based on the document identifiers of the data source to divide the training and validation data subsets. Specifically, all samples with the same identifier are always placed within the same fold partition, thereby ensuring strict isolation between the validation and training sets at the document level. This grouping strategy can more realistically evaluate the model's generalization ability on unseen documents.
[0047] Decision threshold The determination of the threshold is closely coordinated with the training process of the classification model, rather than being set independently after training. After completing the training process of grouped cross-validation, the out-of-fold prediction probability values output by the classification model on all validation data subsets are collected. A series of candidate cutoff thresholds are systematically traversed within the global probability interval [0, 1]. For each candidate cutoff threshold τ, samples with a prediction probability greater than τ are judged as hallucinations, and samples with a prediction probability less than or equal to τ are judged as non-hallucinations. Then, a comprehensive evaluation index score is calculated on the labeled data subset. The comprehensive evaluation index adopts the harmonic mean form of the F1 score, and its calculation formula is:
[0048]
[0049] in, This represents the set of true labels for a subset of the validation data. This represents the set of out-of-bounds predicted probabilities output by the classification model on the same subset of validation data. This is an indicator function; it takes a value of 1 when the condition within the parentheses is true, and a value of 0 otherwise. τ is the current candidate cutoff threshold. This function calculates the F1 score given the true and predicted labels. After traversing all candidate thresholds across the entire interval, the candidate cutoff threshold that maximizes the F1 score is selected as the final dynamic decision threshold. This optimization process incorporates the trade-off between precision and recall into the objective function of threshold selection. In cases of class imbalance where the number of hallucination samples is far less than the number of normal samples, it can significantly improve the model's recall capability for the hallucination category compared to directly using the default 0.5 cutoff point, thereby improving the false negative rate performance of the detection system in actual deployment.
[0050] After completing the above training and threshold optimization, the mixed feature vector of the response sequence to be detected is generated during the inference stage. The algorithm takes a pre-trained gradient boosting decision tree classifier as input and obtains an uncalibrated predicted probability distribution. Then, it uses a pre-optimized dynamic decision threshold τ* based on the target evaluation metric to perform a binarization truncation operation on this probability value. Probabilities greater than τ* are classified as hallucinations, while probabilities less than or equal to τ* are classified as reliable content. The computational overhead of the inference phase consists of only one forward inference of the decision tree and one scalar comparison, resulting in a constant time complexity. This is far lower than black-box consistency detection methods that require multiple repeated samplings, and also lower than the quadratic complexity of self-attention decoding processes, making real-time deployment feasible.
[0051] In summary, the method provided by this invention achieves the perception of sparsity of hallucination signals through an adaptive sampling window, achieves the coverage of multi-source heterogeneous asynchronous peak signals through the aggregation of independent sequential statistics of each dimension, achieves a multi-perspective description of the response risk state through the splicing of multi-order statistical moments and local salient features, and achieves targeted processing of the class imbalance problem through dynamic threshold calibration based on grouped cross-validation. Finally, it achieves an effective balance between high signal retention rate and low false positive rate in the hallucination detection task.
[0052] This invention also provides a post-processing system for hallucination detection in a large language model based on adaptive order statistics aggregation. Corresponding to the aforementioned method, this system comprises four functional modules that collaborate in a pipeline manner. The temporal feature data acquisition module receives internal state information from the large language model decoding process, organizes it into a temporal feature matrix, and calculates the sampling window size parameter K in real time based on the time step length T of the current response sequence, providing the required dynamic window value for subsequent aggregation modules. The local salient feature aggregation module receives the temporal feature matrix and the sampling window size parameter, independently performs a descending numerical sorting for each preset feature dimension of the matrix, extracts the top K largest elements to form order statistics, and calculates their mean to obtain the local salient features for that dimension. Parallel processing of multiple dimensions is achieved through decoupling index selection. The hybrid feature vector construction module calculates the global mean, global standard deviation, and global maximum value across all time steps of the temporal feature matrix, and concatenates the three types of global statistical moments with the local salient features from the local salient feature aggregation module to output a fixed-dimensional response-level hybrid feature vector. The dynamic threshold truncation classification module loads the pre-trained gradient boosting decision tree classifier weights and the dynamic decision threshold obtained from the validation set optimization. The input mixed feature vector is used for tree inference to obtain the predicted probability, which is then compared with... After comparing and completing the binarization truncation, output the hallucination detection result.
[0053] This invention also provides an electronic device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the various steps of the method described in this invention. The memory can be of various storage formats, such as random access memory or non-volatile memory, and is used to persistently store classifier model parameters, dynamic decision threshold parameters, and processing logic code. The processor can be a general-purpose central processing unit or a graphics processing unit. When executing the computer program, it sequentially schedules each functional unit according to the aforementioned order of temporal feature acquisition, adaptive sparse aggregation, hybrid feature vector construction, and dynamic threshold truncation classification to complete end-to-end hallucination detection inference.
[0054] This invention also provides a computer-readable storage medium storing computer program execution instructions. When these instructions are read and executed by a computer processor, the processor implements all the process operations of the method described in this invention. The computer-readable storage medium can be in various forms such as a disk, optical disk, solid-state drive, or flash memory card. After being loaded by the processor, the program code stored thereon runs according to the adaptive sequential statistics aggregation logic, hybrid feature vector construction logic, and dynamic threshold calibration logic disclosed in this invention, completing the hallucination detection task for the response sequence of a large language model.
[0055] The above are merely preferred embodiments of the present invention and are not intended to limit the invention. Any modifications, equivalent substitutions, and improvements made to the present invention without departing from its spirit and principles should be included within the scope of protection of the claims of the present invention.
Claims
1. A post-processing method for hallucination detection based on adaptive order statistics aggregation in a large language model, characterized in that, Includes the following steps: Steps for obtaining time-series feature data: Obtain the response sequence generated by the large language model for a specific query text, and extract the time-series feature matrix corresponding to the response sequence. The time-series feature matrix includes the time step length and the preset feature dimension. Local salient feature aggregation step: dynamically calculate the sampling window size according to the time step length, independently extract the elements with the highest numerical ranking for each preset feature dimension of the time series feature matrix to form an order statistic, and calculate the mean of the order statistic as the local salient feature of the corresponding preset feature dimension. Hybrid feature vector construction steps: Calculate the global statistical moments of the time-series feature matrix under the predetermined statistical dimensions, and concatenate the global statistical moments with the local salient features corresponding to each predetermined feature dimension to obtain the response-level hybrid feature vector; Dynamic threshold truncation classification steps: Input the response-level mixed feature vector into a pre-trained tree model classifier to obtain the predicted probability distribution, perform a binarization truncation operation on the predicted probability distribution using a pre-optimized dynamic decision threshold based on the target evaluation index, and output the hallucination judgment result of the response sequence.
2. The post-processing method for hallucination detection based on adaptive order statistics aggregation of a large language model according to claim 1, characterized in that, In the local salient feature aggregation step, the process of dynamically calculating the sampling window size adopts a scale-invariant linear scaling strategy; a linear mapping relationship is established between the sampling window size and the time step length of the response sequence. By introducing a sensitivity coefficient that characterizes the expected coverage ratio of high-risk signals in the time domain, and a minimum sampling lower bound parameter to ensure statistical significance under short text responses, the maximum value of the combination of the two is calculated as the final sampling window size while ensuring adaptive adjustment of long and short response sequences.
3. The post-processing method for hallucination detection based on adaptive order statistics aggregation of a large language model according to claim 1, characterized in that, In the local salient feature aggregation step, the processing logic for independently extracting the elements with the highest numerical ranking to form the order statistics for each preset feature dimension includes: sorting the time-series vector elements corresponding to the current preset feature dimension in the time-series feature matrix in descending order to obtain a sorted vector; extracting the elements in the sorted vector that are in the preceding position and whose number is equal to the size of the sampling window to form the order statistics for this dimension, and calculating the arithmetic mean of the order statistics. By decoupling the selection index in each feature dimension, abnormal peaks on different feature dimensions are allowed to appear in asynchronous time steps.
4. The post-processing method for hallucination detection based on adaptive order statistics aggregation of a large language model according to claim 1, characterized in that, In the hybrid feature vector construction step, the global statistical moments of the time-series feature matrix under a predetermined statistical dimension include the global mean, global standard deviation, and global maximum value. The global mean is used to characterize the baseline level of the internal state of the model, the global standard deviation is used to characterize the degree of uncertainty fluctuation in the model inference process, and the global maximum value is used to capture and calculate instantaneous extreme outliers.
5. The post-processing method for hallucination detection based on adaptive order statistics aggregation of a large language model according to claim 1, characterized in that, In the dynamic threshold truncation classification step, the method for obtaining the pre-optimized dynamic decision threshold based on the target evaluation index includes: during the training phase of the classification model, using a grouped cross-validation strategy based on the data source document identifier to divide the training data subset and the validation data subset; obtaining the predicted probability output by the tree model classifier on the validation data subset; systematically traversing the candidate truncation thresholds within the global probability interval; calculating the comprehensive evaluation index score corresponding to each candidate truncation threshold; and establishing the candidate truncation threshold that maximizes the comprehensive evaluation index score as the optimal dynamic decision threshold.
6. The post-processing method for hallucination detection based on adaptive order statistics aggregation of a large language model according to claim 1, characterized in that, In the dynamic threshold truncation classification step, the tree model classifier adopts a gradient boosting framework with a regularization term; the gradient boosting framework receives the response-level mixed feature vector as input and directly processes the unnormalized heterogeneous feature set containing probability type, distance type, and divergence type data formed by the feature concatenation process; by performing feature mapping on the unnormalized heterogeneous feature set, it outputs an uncalibrated predicted probability distribution representing that the current response sequence belongs to the hallucination content category.
7. A post-processing system for hallucination detection based on adaptive order statistics aggregation in a large language model, characterized in that, include: The temporal feature data acquisition module is used to acquire the response sequence and temporal feature matrix generated by the large language model, and dynamically calculate the sampling window size parameter in real time based on the time step length of the response sequence. The local salient feature aggregation module is used to independently sort the values for each preset feature dimension of the time-series feature matrix and extract the first elements to form an order statistic, and then calculate the mean of the order statistic as a local salient feature. The hybrid feature vector construction module is used to calculate the global statistical moments of the time-series feature matrix respectively, and to concatenate the local salient features with the global statistical moments to construct the response-level hybrid feature vector; The dynamic threshold truncation classification module is used to feed the response-level mixed feature vector into a pre-trained tree model classifier to extract the predicted probability distribution, and to perform binarization truncation classification using a dynamic decision threshold established based on maximizing the comprehensive evaluation index of the validation set, and output the corresponding hallucination detection judgment result.
8. An electronic device, characterized in that, The method includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the computer program, implements the various steps of the large language model hallucination detection post-processing method based on adaptive order statistics aggregation as described in any one of claims 1 to 6.
9. A computer-readable storage medium storing computer program execution instructions thereon, characterized in that, When the computer program execution instructions are read and executed by the computer processor, the computer processor performs all the process operations of the large language model hallucination detection post-processing method based on adaptive sequential statistics aggregation as described in any one of claims 1 to 6.