A dynamic bias-aware hybrid reconstruction expert long tail distribution out detection method
Patent Information
- Application Number
- CN202611022587.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-09
- Publication Date
- 2026-10-16
AI Technical Summary
本发明的目的是针对现有技术的不足之处,提出一种动态偏差感知的混合重建专家长尾分布外检测方法,以解决现有方法在实际应用中存在的以下三个主要技术缺陷:1)真实场景中往往无法获取高质量、与任务对齐的辅助OOD数据,极大限制了现有方法的实际落地应用;2)传统的专家混合架构直接应用于长尾分布时,其路由机制极易被头部类别主导,导致尾部样本难以被有效分配和重建;3)缺乏一种统一的机制来同时纠正底层的专家路由偏差与顶层的分类决策边界偏差
[0014]有益效果:采用本发明公开的方法,相比于现有技术实现了以下技术进步:(1)降低了对辅助数据的依赖与分布偏移风险:本发明利用多专家重建架构直接在分布内数据上挖掘并重构长尾多样性特征,无需额外获取或生成辅助的分布外(OOD)数据。这降低了数据准备成本,并有效避免了因引入外部伪样本而可能造成的分布偏移问题,提升了模型在真实未知场景下的适用性。(2)有效缓解了长尾场景下的专家路由偏差:针对混合专家模型在长尾分布中易受头部类别主导的问题,本发明通过将可学习的动态类偏差信号直接注入门控路由决策过程,显式地干预并矫正了专家的分配机制。该机制平衡了底层专家门控信号,使得尾部类别样本也能获得相匹配的重建资源,改善了长尾分布下的路由分配失衡现象。(3)实现了路由分配与决策边界的协同优化:本发明的技术方案中,动态类偏差信号既用于在底层网络指导专家的资源分配,又在顶层网络用于自适应地校准分类器的决策边界。这种长尾表示学习与分布外检测的统一设计,增强了模型在低置信度区间区分尾部已知样本与真实分布外样本的能力,提高了整体系统的检测精度。
Smart Images

Figure CN122929263A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence, machine learning and computer vision technology, and specifically relates to a hybrid reconstruction expert long-tail distribution out-of-distribution detection method with dynamic deviation perception, which is particularly suitable for image recognition and other demand scenarios in open-world environments. Background Technology
[0002] In traditional machine learning and computer vision tasks, out-of-distribution (OOD) detection techniques are typically based on the assumption that training data exhibits a class-balanced distribution. However, in real-world open-world applications, real-world data often exhibits a long-tail distribution, meaning that a few "head" classes constitute the vast majority of training samples, while a large number of "tail" class samples are scarce. This long-tail setting presents corresponding technical challenges: class imbalance can easily cause model representations and decision boundaries to skew towards head classes, exacerbating the confusion between in-distribution tail samples and true out-of-distribution samples, thus affecting the accuracy of the detector.
[0003] Existing technologies typically mitigate these issues by introducing external auxiliary data or generating pseudo-OOD samples for anomaly exposure training. However, this approach has significant limitations in practical applications: First, acquiring highly relevant auxiliary data is costly, and manually constructed auxiliary data often fails to fully cover the real unknown distribution during the testing phase, easily leading to distribution shifts and limiting the model's generalization ability in complex scenarios. Second, when dealing with long-tail distributions, the traditional gating routing mechanism in Hybrid Expert (MoE) architectures is susceptible to the influence of high-frequency features of the head class. This long-tail prior bias leads to unbalanced routing allocation, making it difficult for tail class samples to obtain sufficient reconstruction resources, thus affecting the model's ability to distinguish between tail samples and samples outside the real distribution.
[0004] In summary, how to overcome the expert routing bias caused by long-tail distribution without relying on external auxiliary data, and to construct a detection mechanism that can effectively separate known samples at the tail from samples outside the distribution, is a technical problem that needs to be solved in this field. Summary of the Invention
[0005] Purpose of the Invention: In this invention, long-tail distribution refers to an unbalanced distribution of the number of samples in each category in the training set, where a few head categories occupy the majority of samples, while the majority of tail categories have sparse samples. The purpose of this invention is to address the shortcomings of existing technologies by proposing a dynamic bias-aware hybrid reconstruction expert long-tail distribution out-of-target (OOD) detection method. This addresses the following three main technical deficiencies of existing methods in practical applications: 1) In real-world scenarios, high-quality, task-aligned auxiliary OOD data is often unavailable, greatly limiting the practical application of existing methods; 2) When traditional expert hybrid architectures are directly applied to long-tail distributions, their routing mechanism is easily dominated by head categories, making it difficult to effectively allocate and reconstruct tail samples; 3) There is a lack of a unified mechanism to simultaneously correct the expert routing bias at the lower level and the classification decision boundary bias at the upper level.
[0006] Technical solution: A hybrid reconstruction method for detecting the long-tail distribution of experts based on dynamic bias perception, the specific steps of which are as follows:
[0007] Step S1: Obtain training images, construct and initialize a shared feature encoder and a hybrid reconstruction expert module containing multiple expert decoders, as well as a dynamic class bias module;
[0008] Step S2: Extract latent feature representations of the training images using the shared feature encoder, and assign the latent feature representations to the corresponding expert decoders for feature reconstruction using a gated routing mechanism, and calculate the reconstruction error;
[0009] Step S3: Using the dynamic class bias module, a learnable dynamic class bias signal is generated based on the class label. The dynamic class bias signal is used for the following two sub-tasks simultaneously:
[0010] (1) Guiding the routing decisions of the gated routing mechanism;
[0011] (2) Calibrate the prediction boundary of the classifier;
[0012] Step S4: Construct a multi-task joint total loss function that includes reconstruction loss, dynamic class bias regularization loss, and bias-aware classification loss, and perform end-to-end joint training on the model;
[0013] Step S5: Input the test image into the trained model, calculate the out-of-distribution confidence score based on the reconstruction error of the hybrid reconstruction expert module, compare it with the preset threshold, and perform out-of-distribution sample identification and closed set classification.
[0014] Beneficial effects: Compared with the prior art, the method disclosed in this invention has achieved the following technical progress: (1) Reduced dependence on auxiliary data and risk of distribution shift: This invention utilizes a multi-expert reconstruction architecture to directly mine and reconstruct long-tail diversity features on in-distribution data without the need to acquire or generate auxiliary out-of-distribution (OOD) data. This reduces data preparation costs and effectively avoids the distribution shift problem that may be caused by the introduction of external pseudo-samples, improving the applicability of the model in real unknown scenarios. (2) Effectively alleviates expert routing bias in long-tail scenarios: In response to the problem that hybrid expert models are easily dominated by the head class in long-tail distributions, this invention explicitly intervenes in and corrects the expert allocation mechanism by directly injecting learnable dynamic class bias signals into the gating routing decision process. This mechanism balances the gating signals of the bottom-level experts, so that the tail class samples can also obtain matching reconstruction resources, improving the imbalance of routing allocation in long-tail distributions. (3) Achieves collaborative optimization of routing allocation and decision boundary: In the technical solution of this invention, the dynamic class bias signal is used both to guide the resource allocation of experts in the bottom-level network and to adaptively calibrate the decision boundary of the classifier in the top-level network. This unified design of long-tail representation learning and out-of-distribution detection enhances the model's ability to distinguish known samples at the tail from true out-of-distribution samples in low-confidence intervals, thereby improving the overall detection accuracy of the system. Attached Figure Description
[0015] Figure 1 This is a flowchart of the hybrid reconstruction expert long-tail distribution out-of-range detection method for dynamic deviation perception in an embodiment of the present invention.
[0016] Figure 2 This is a diagram illustrating the overall architecture and working principle of the long-tailed distribution external detection method described in this embodiment of the invention.
[0017] Figure 3 This is a visualization of the routing distribution of reconstruction experts across different categories in an embodiment of the present invention. Detailed Implementation
[0018] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments: Figure 1 and Figure 2 As shown, the hybrid reconstruction expert long-tail distribution out-of-distribution detection method with dynamic deviation perception includes the following steps in a specific embodiment:
[0019] Step S1: Construct a hybrid reconstruction expert module. Obtain the training images and construct the hybrid reconstruction expert module using a shared encoder-multi-expert decoder architecture. For input sample x... i Extracting latent representation z using a shared encoder i This input is then fed into E parallel reconstruction expert decoders. Each expert independently reconstructs the input and outputs... Calculate the reconstruction loss for each expert using the mean squared error (MSE). The formula is defined as:
[0020]
[0021] Where N is the total number of training samples.
[0022] Step S2: Construct a dynamic class bias module to generate a learnable dynamic class bias signal. To explicitly model the long-tailed distribution prior, for each class label y... i Maintain a learnable embedding vector And a scalar bias term b(y) is generated through a multilayer perceptron (MLP). i The bias term is subject to task-adaptive frequency-aware prior compensation regularization, i.e., dynamic class bias regularization loss. The formula is defined as:
[0023]
[0024] Wherein, P(y i ) represents category y i In the training set, σ is the sigmoid function, representing the empirical frequencies. This design places greater optimization pressure on low-frequency tail classes, thus compensating for their insufficient gradient updates in long-tail scenarios.
[0025] Step S3: The latent features are assigned to the corresponding expert decoders using a gated routing mechanism, and the dynamic class bias signal generated in step S2 is used simultaneously to guide routing decisions and calibrate the classifier's prediction boundaries. Specifically, this is designed as a dual routing mechanism encompassing both instance-level and class-level routing.
[0026] Step S3.1, Instance-level routing: Calculate the reconstruction quality score Basic scores of gating networks The formula is:
[0027]
[0028] Where ε is the numerical stability constant and θ is the gated network parameter. Adding the two together yields the instance-level routing intermediate score.
[0029] Step S3.2, Class-level routing: The dynamic class deviation b(y) generated in step S2 is used for routing. i Introducing a routing process to calculate the final expert gating weights.
[0030]
[0031] This step explicitly increases the probability of assigning tail category samples to experts with stronger reconstruction capabilities.
[0032] Step S4: Design a joint loss function for end-to-end training. To stabilize expert utilization, a route regularization loss is introduced. It consists of balance loss and sparsity loss:
[0033]
[0034] in,
[0035]
[0036] Combining the weighted reconstruction loss, we obtain the total expert loss for hybrid reconstruction.
[0037]
[0038] Furthermore, the dynamic class deviation b(y) i Shared data is used to calibrate the classifier, constructing a bias-aware classification loss.
[0039]
[0040] Among them, fy i (x i ) represents the classifier for category y i The output of logits, where η is the intensity adjustment coefficient.
[0041] Ultimately, the model minimizes the total loss function. Perform end-to-end training:
[0042]
[0043] Where α and β are equilibrium hyperparameters.
[0044] Step S5: Use the reconstruction score for open set identification and classification. In the inference stage, use the expert's reconstruction performance as the out-of-distribution confidence score.
[0045]
[0046] If the OOD-Score of the test sample is greater than the preset threshold τ, it is determined to be an unknown class; otherwise, the sample is a known class, and the classifier outputs the final specific category. In practical applications, an appropriate threshold needs to be defined according to the task scenario.
[0047] Of course, the above description is only a preferred embodiment of the present invention. The present invention is not limited to the above-described embodiments. It should be noted that any equivalent substitutions or obvious modifications made by those skilled in the art under the guidance of this specification fall within the scope of this specification and should be protected by the present invention.
Claims
1. A hybrid reconstruction method for detecting long-tailed distributions of experts based on dynamic bias perception, characterized in that, The method includes the following steps: Step S1: Acquire training images, construct and initialize a shared feature encoder and a hybrid reconstruction expert module containing multiple expert decoders, as well as a dynamic class bias module; Step S2: Extract latent feature representations of the training images using the shared feature encoder, and assign the latent feature representations to the corresponding expert decoders for feature reconstruction using a gated routing mechanism, and calculate the reconstruction error; Step S3: Using the dynamic class bias module, a learnable dynamic class bias signal is generated based on the class label. The dynamic class bias signal is used for the following two sub-tasks simultaneously: (1) Guiding the routing decisions of the gating routing mechanism (2) Calibrate the prediction boundary of the classifier Step S4: Construct a multi-task joint total loss function that includes reconstruction loss, dynamic class bias regularization loss, and bias-aware classification loss, and perform end-to-end joint training on the model; Step S5: Input the test image into the trained model, calculate the out-of-distribution confidence score based on the reconstruction error of the hybrid reconstruction expert module, compare it with the preset threshold, and perform out-of-distribution sample identification and closed set classification.
2. The method for detecting the long-tailed distribution of expert systems based on dynamic deviation perception in hybrid reconstruction according to claim 1, characterized in that: In step S2, for the input image x in the training set i Extracting latent representation z using a shared encoder i The latent representation is then fed in parallel into E independent expert decoders to capture diverse reconstruction patterns; the reconstruction loss for each expert is calculated. The feature is that the reconstruction loss uses mean squared error to measure the difference between the original input and the reconstructed output, and the formula is defined as: in, Let N be the reconstructed output of expert e for sample i, and N be the number of training samples.
3. The method according to claim 1, characterized in that, In step S3, for each category y i Maintaining learnable embedding vectors And generate the scalar deviation term b(y) i Entropy regularization constraint is applied to the bias term to make it learn the long-tailed prior, and its dynamic class bias regularization loss is... Defined as: Wherein, P(y i ) represents category y i The empirical frequency, σ is the Sigmoid function.
4. The method for detecting the long-tailed distribution of experts in hybrid reconstruction based on dynamic deviation perception according to claim 1, characterized in that: The gated routing mechanism in step S2 is specifically a dual-gated routing mechanism; the subtask (1) in step S3 guides the routing decision of the gated routing mechanism, and the specific calculation process is as follows: Calculate the reconstruction quality score of the sample-expert pair. Simultaneously, a base score is obtained by processing latent features using an independent gated network. Summing the two yields the instance-level route intermediate score, which is unaffected by category distribution. The formula is: Where ε is the numerical stability constant. The dynamic class deviation term b(y) is described above. i The routing process is combined with instance-level score aggregation to calculate the final expert gating weight score. The formula is:
5. The method for detecting the long-tailed distribution of expert systems based on dynamic deviation perception in hybrid reconstruction according to claim 4, characterized in that: In step S4, the routing regularization loss is defined. To balance the losses With sparsity loss The sum, the formula is: Among them, the balancing loss is used to penalize uneven expert load, and the sparsity loss is used to encourage the gated network to make more deterministic routing decisions. The specific formula is as follows:
6. The method for detecting the long-tailed distribution of expert systems based on dynamic deviation perception in hybrid reconstruction according to claim 5, characterized in that: In step S4, the multi-task joint total loss function For bias perception classification loss Weighted Hybrid Reconstruction Expert Loss Regularization loss with dynamic class bias The linear combination of these is given by the formula: Where α and β are the balancing hyperparameters controlling the multi-task learning objective, and Includes reconstruction loss weighted by route weights With routing regularization loss The formula is:
7. The method for detecting the long-tailed distribution of expert systems based on dynamic deviation perception in hybrid reconstruction according to claim 6, characterized in that: The subtask (2) in step S3, which calibrates the prediction boundary of the classifier, specifically involves adjusting the scalar bias term b(y). i The bias-aware classification loss is injected into the standard cross-entropy classification loss to adaptively adjust the decision boundary. Specifically defined as: Among them, f y (x i ) represents the logits output prediction of the linear classifier for category y, and η is the adjustment coefficient for controlling the bias calibration intensity.
8. The method for detecting the long-tailed distribution of experts in hybrid reconstruction based on dynamic deviation perception according to claim 1, characterized in that, In step S5, the specific process of identifying samples outside the open set distribution is as follows: during the inference phase, extract the test sample x from each reconstruction expert's analysis. t Reconstruction loss And utilize gating weights The weighted summation yields the overall out-of-distribution anomaly score (OOD-Score) for the test samples, calculated using the following formula: After obtaining the anomaly score, it is compared with the pre-calibrated discrimination threshold τ on the in-distribution validation set; if the OOD-Score is greater than the preset threshold τ, the test sample is determined to be an unknown out-of-distribution sample and rejected; otherwise, it is classified as a known in-distribution sample, and the classifier outputs the category with the highest probability.