Anti-data drift memory retrieval method, system, electronic device, storage medium and computer program product
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN ZILONG IND CO LTD
- Filing Date
- 2026-05-14
- Publication Date
- 2026-08-07
AI Technical Summary
现有的持续学习方法,如弹性权重巩固(EWC)或记忆重放,通常依赖于复杂的正则化约束或维护有限的回放缓冲区
本申请通过构建仅增不减的历史记忆库,使得新样本的存储不覆盖已存储的旧样本,从而保留了完整的历史经验数据,实现了终身学习场景下的知识持续积累与零遗忘。同时,通过基于第一相似度召回K个历史样本,并基于第二相似度和时间戳确定距离权重与时间衰减权重,使得仅对高相关性的候选样本进行时序感知的加权投票,消除了全库检索的计算冗余,提高了检索的实时性与决策的置信度。此外,通过融合距离权重与时间衰减权重进行联合决策,使得近期且特征相似的样本具有更高的投票影响力,有效抑制了概念漂移带来的干扰,提高了识别的准确率与鲁棒性。该方法特别适用于对实时性、准确性和长期记忆能力有严格要求的智能监控、工业质检、个性化推荐等场景。
Smart Images

Figure CN122528040A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the fields of artificial intelligence and machine learning technology, specifically to a data drift-resistant memory retrieval method, system, electronic device, storage medium, and computer program product. Background Technology
[0002] Currently, in the fields of artificial intelligence and machine learning, continuous learning systems face the core challenge of catastrophic forgetting when processing continuous data streams. Existing continuous learning methods, such as Elastic Weight Consolidation (EWC) or memory replay, typically rely on complex regularization constraints or maintaining a finite replay buffer. However, when the model is trained on new data, previously learned knowledge is often overwritten or distorted, leading to a significant drop in the accuracy of recognizing old knowledge. Furthermore, when data distributions drift over time, such as due to sensor aging or changes in ambient lighting, traditional methods usually require retraining or frequent model fine-tuning, which is not only computationally expensive but also difficult to deploy on low-power edge devices. While existing memory management systems employ hierarchical storage and eviction mechanisms, they often free up space by deleting old samples, failing to achieve true zero forgetting. Summary of the Invention
[0003] To address the problems of catastrophic forgetting and difficulty in adapting to data distribution drift in existing technologies, this application proposes a data drift-resistant memory retrieval method that maintains a continuously growing historical memory bank and combines it with a time-aware weighted voting mechanism to achieve high-precision continuous reasoning with zero forgetting and drift resistance.
[0004] To achieve the above objectives, this application adopts the following technical solution: A memory retrieval method resistant to data drift includes: Obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector; Based on the first similarity, K historical samples are selected from the historical memory bank, where 5≤K≤100 and K is a positive integer. The historical memory bank does not delete the old samples that have been stored when storing new samples. Based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, the first distance weight and the first time decay weight corresponding to the K historical samples are determined respectively; Based on the first distance weight and the first time decay weight, a weighted vote is performed on the categories to which the K historical samples belong, and the category with the highest weighted vote score is taken as the identification result corresponding to the sample to be identified.
[0005] Optionally, the step of determining the first time decay weight includes: Calculate the difference between the timestamps of the K historical samples and the current time; The first-time decay weight is calculated using the formula Wt=γ^Δt; Where Wt is the time decay weight, Δt is the difference between the timestamp of the historical sample and the current time, and γ is the preset time decay factor, and 0.98≤γ≤0.998.
[0006] Optionally, the step of determining the first distance weight includes: Based on the second similarity between the K historical samples and the sample to be identified, the monotonically increasing function corresponding to the second similarity is determined as the first distance weight; or... Based on the sample distances corresponding to the second similarity between the K historical samples and the sample to be identified, the negative power function of the sample distances is determined as the first distance weight.
[0007] Optionally, the method further includes: Determine whether the highest value of the weighted voting score is lower than a preset confidence threshold; If the confidence level is lower than the confidence threshold, then the target time sub-database is determined from the historical memory database based on the feature vector of the sample to be identified. K′ historical samples are re-selected from the target time sub-database, and the corresponding second distance weight and second time decay weight are calculated. A second weighted vote is then performed, and the category corresponding to the highest score in the second vote is taken as the recognition result.
[0008] Optionally, determining the target time sub-database from the historical memory database includes: The historical memory bank is divided into several discrete time blocks according to chronological order; Based on the feature vector of the sample to be identified, calculate the distribution matching degree between the sample to be identified and each time block; The time block with the highest distribution matching degree is taken as the target time sub-library.
[0009] Optionally, the method further includes: If the highest score in the second-weighted voting score is still lower than the confidence threshold, or if the similarity between the sample to be identified and the nearest neighbor sample in the historical memory bank is lower than the minimum similarity threshold, then a rejection signal is output.
[0010] Optionally, the method further includes: Retrieve a pre-built patch memory, which is used to store a predetermined number of high-priority samples; If there is a hit sample in the patch memory whose third similarity to the feature vector of the sample to be identified exceeds a preset patch threshold, then the category to which the hit sample belongs is directly used as the identification result. If no match is found, the steps of calculating the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank, and selecting K historical samples from the historical memory bank based on the first similarity are performed.
[0011] Optionally, the method further includes: Receive the truth value category fed back based on the recognition result; If the recognition result is inconsistent with the true value category, the feature vector of the sample to be identified and its corresponding true value category are stored in the patch memory. If the storage capacity of the patch memory reaches its limit, the least recently used sample will be evicted according to the least recently used strategy.
[0012] Furthermore, this application also provides a data drift-resistant memory retrieval system, the data drift-resistant memory retrieval system comprising: The feature comparison module is used to obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector. The retrieval memory module is used to select K historical samples from the historical memory bank based on the first similarity, where 5≤K≤100 and K is a positive integer. The historical memory bank does not delete the old samples that have been stored when storing new samples. The weight calculation module is used to determine the first distance weight and the first time decay weight corresponding to the K historical samples based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, respectively. The weighted voting module is used to perform weighted voting on the categories to which the K historical samples belong based on the first distance weight and the first time decay weight, and to take the category with the highest weighted voting score as the identification result corresponding to the sample to be identified.
[0013] Optionally, the system also includes a causal reasoning module based on event co-occurrence. This module achieves time-stamp-free multi-step sequence reasoning through Hebbian edge weights and damped energy diffusion between nodes. In the 8-step sequence reasoning verification, starting from any event node, the system can correctly reason to the global endpoint, and all verifications pass.
[0014] In addition, this application also provides an electronic device, including: a processor, a memory, a communication interface, and a communication bus, wherein the processor, the memory, and the communication interface communicate with each other through the communication bus; the memory is used to store at least one executable instruction, which causes the processor to perform the steps of the anti-data drift memory retrieval method as described in any of the above schemes.
[0015] In addition, this application also provides a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the anti-data drift memory retrieval method as described in any of the above schemes.
[0016] In addition, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the anti-data drift memory retrieval method as described in any of the above solutions; One or more technical solutions proposed in this application have at least the following technical effects: This application constructs a continuously expanding historical memory bank, ensuring that new samples do not overwrite previously stored samples, thus preserving complete historical experience data and achieving continuous knowledge accumulation and zero forgetting in lifelong learning scenarios. Simultaneously, by recalling K historical samples based on a first similarity score and determining distance and time decay weights based on a second similarity score and timestamps, time-aware weighted voting is performed only on highly relevant candidate samples, eliminating computational redundancy in full-database retrieval and improving the real-time performance and decision confidence. Furthermore, by fusing distance and time decay weights for joint decision-making, recent samples with similar features have higher voting influence, effectively suppressing interference from concept drift and improving recognition accuracy and robustness. This method is particularly suitable for scenarios with strict requirements for real-time performance, accuracy, and long-term memory capabilities, such as intelligent monitoring, industrial quality inspection, and personalized recommendations. Attached Figure Description
[0017] Figure 1 This is a flowchart illustrating the first embodiment of the anti-data drift memory retrieval method of this application; Figure 2 This is a schematic diagram of the basic architecture involved in the embodiments of this application; Figure 3 This is a schematic diagram illustrating the principle of discrete-time block partitioning and target time sub-database matching in the third embodiment of the anti-data drift memory retrieval method of this application; Figure 4 This is a schematic diagram of the electronic device structure of the hardware operating environment involved in the embodiments of this application.
[0018] The realization of the purpose, functional features and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0019] It should be understood that the specific embodiments described herein are merely illustrative of this application and are not intended to limit this application.
[0020] Example 1: like Figure 1 As shown, this embodiment provides a data drift-resistant memory retrieval method. This method aims to address the problems of catastrophic forgetting and difficulty in adapting to data distribution drift in existing continuous learning models when faced with data streams. This embodiment uses handwritten digit recognition as an example scenario, but it should be understood that the method of this application is also applicable to other application scenarios requiring lifelong learning, such as image classification, text recognition, and sensor data analysis.
[0021] Before system deployment, such as Figure 2 As shown, a fixed feature extractor is first constructed. In this embodiment, the feature extractor is implemented using PCA dimensionality reduction: 200 labeled samples provided on day 1 of the digits dataset (8×8 grayscale image, 10 classes of handwritten digits) are used for PCA training, retaining 95% of the variance, mapping the original 64-dimensional image pixels into feature vectors in a low-dimensional feature space. This PCA transformation matrix is fixed after training and remains unchanged throughout the entire lifelong learning process. Using a fixed feature extractor avoids feature space drift caused by continuous model parameter updates, providing a stable benchmark for subsequent similarity calculation and retrieval.
[0022] Simultaneously, the system initializes a history memory. This history memory is initially empty and is used to store all historical samples received during subsequent learning. Each entry in the history memory contains three fields: the feature vector of the historical sample, the category label, and a timestamp. The timestamp is measured in a preset time unit—in this embodiment, "days" are used, accumulating from day 1. The history memory does not delete previously stored samples when storing new samples, employing a "growth-only" maintenance strategy. This is fundamentally different from existing cache eviction mechanisms (such as the Least Recently Used (LRU) strategy). Existing caching mechanisms typically evict the least recently accessed or earliest stored data when storage space reaches its limit, directly leading to the loss of old knowledge, i.e., "catastrophic forgetting." This embodiment, through its "growth-only" strategy, allows the physical storage space of the history memory to continuously grow with the accumulation of samples, ensuring permanent memory retention. This means that no matter how long the system runs, as long as hardware storage space allows, the earliest samples remain intact in the memory. This mechanism ensures at the physical level that old knowledge will not be overwritten by new data, thus achieving true zero forgetting.
[0023] After system deployment, it enters a lifelong learning phase. To simulate the scenario where data distribution drifts over time, this embodiment applies a rotational drift to the digits dataset: On day 1, 200 labeled samples (i.e., the original data to be processed, where 30% of the labels are randomly replaced with noise to simulate labeling errors in real-world scenarios) are provided. These samples are mapped to feature vectors using a fixed PCA feature extractor and then stored in the history memory along with their class labels and timestamps (timestamp = 1, representing day 1). Subsequently, samples are provided to the system each day after being rotated at a fixed angle (1°), with 50 labeled samples provided daily. The system extracts the feature vector of each new sample and stores it in the history memory, recording its class label and corresponding timestamp (timestamp of the sample on day n = n). Throughout this process, the history memory continuously accumulates without deleting any old samples; that is, the history memory is an explicit history memory that only increases and never decreases.
[0024] This learning process continues, and by day 10, approximately 650 historical samples have been accumulated in the historical memory bank (200 from day 1 + 50 each day from day 2 to day 10). The following example, using the input of a sample to be identified on day 10, illustrates the retrieval and identification process of this embodiment in detail.
[0025] Step S100: Obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector.
[0026] On day 10, the system received an image of a handwritten digit to be recognized. This image was first mapped into a feature vector using a fixed PCA feature extractor. Subsequently, the system calculated the first similarity between this feature vector and the feature vectors of all approximately 650 historical samples in the historical memory database.
[0027] There are various ways to calculate the first similarity score; in this embodiment, cosine similarity is used as the metric. Cosine similarity measures the directional consistency by calculating the cosine of the angle between two feature vectors, with a value ranging from -1 to 1. A larger value indicates greater similarity between the two vectors. Cosine similarity has low computational complexity, making it suitable for rapid initial screening in large-scale historical memory databases. In other embodiments, Euclidean distance, Manhattan distance, Pearson correlation coefficient, etc., can also be used to calculate the first similarity score. Those skilled in the art can choose the appropriate metric based on the specific application scenario and data characteristics.
[0028] By calculating the first similarity, the system can quickly locate the set of candidate samples most relevant to the current input in the historical memory bank, laying the foundation for subsequent fine screening and weighted voting.
[0029] Step S200: Based on the first similarity, select K historical samples from the historical memory bank, where 5≤K≤100, K is a positive integer, and the historical memory bank does not delete the old samples that have been stored when storing new samples.
[0030] After calculating the first similarity between the sample to be identified and all historical samples, the system sorts them from highest to lowest similarity and selects the K most similar historical samples as candidate neighbors. In this embodiment, the value of K is set to 80. The selection of the value of K needs to strike a balance between recognition accuracy and computational cost—a K value that is too small may lead to statistical unreliability, while a K value that is too large may introduce too many noisy samples. Experiments have verified that when K is in the range of 5 to 100, stable and significantly better accuracy than that of a baseline without time decay can be obtained.
[0031] It is important to reiterate that the historical memory bank currently stores approximately 650 samples from day 1 to day 10, including the earliest 200 samples and 50 new samples added each day. Because the historical memory bank does not delete older samples when storing new ones, the samples stored on day 1—even those with 30% label noise—are still fully preserved in the bank. This means that the selected K historical samples could come from recent periods (e.g., day 9, day 10) or earlier periods (e.g., day 1, day 2), providing the system with complete cross-temporal information.
[0032] Step S300: Based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, determine the first distance weight and the first time decay weight corresponding to the K historical samples respectively.
[0033] To more accurately assess the contribution of each candidate neighbor to the final decision, this embodiment introduces a dual weighting mechanism—a first distance weight and a first time decay weight. These two weights quantify the voting power of candidate samples from the feature space dimension and the time dimension, respectively.
[0034] It should be noted that the first similarity and the second similarity are logically related but can be different. The first similarity is used in the coarse screening and sorting in step S200 to quickly identify K candidate samples; while the second similarity is used in this step to calculate the weights more accurately. In this embodiment, the second similarity also uses cosine similarity, but in other embodiments, the first similarity can use cosine similarity, which has higher computational efficiency, while the second similarity can use Euclidean distance, which is more sensitive to distance. For example, cosine similarity can be used to screen K candidate samples from the entire database first, and then Euclidean distance can be calculated for these K candidate samples, converting the Euclidean distance into the second similarity for accurate weight calculation.
[0035] The first distance weight is determined based on the second similarity between K historical samples and the sample to be identified. The first distance weight reflects the proximity of samples in the feature space—the higher the second similarity, the closer the features of the historical sample are to the sample to be identified, and the higher the reference value of its category label; therefore, the higher the corresponding first distance weight. In this embodiment, the second similarity (cosine similarity value) is directly used as the first distance weight. For example, if the cosine similarity between a historical sample and the sample to be identified is 0.95, then its first distance weight is 0.95.
[0036] Simultaneously, the system calculates the first time decay weight for each candidate historical sample. Each historical sample is timestamped when stored in the historical memory. The system calculates the difference Δt between the current time (day 10) and the timestamp of each candidate historical sample. For example, a sample stored on day 1 has Δt = 9; a sample stored on day 9 has Δt = 1. The first time decay weight is calculated according to the formula Wt = γ^Δt, where γ is a preset time decay factor; in this embodiment, γ = 0.995. Therefore, the time decay weight for the day 1 sample = 0.995^9 ≈ 0.956, and the time decay weight for the day 9 sample = 0.995^1 ≈ 0.995.
[0037] The purpose of introducing the timestamp dimension is to distinguish the influence of old and new samples on the current decision. In scenarios where the data distribution drifts over time—such as increasing the rotation by 1° each day in this embodiment—very old samples, although retaining memory, may have distribution characteristics that deviate from the current data. The distribution of samples that were not rotated on day 1 is significantly different from that of samples that were rotated by 9° on day 10 in the feature space. By decaying the weights at the first time, the system can adaptively reduce the voting weight of old samples, making the decision rely more on recent samples that are closer to the current data distribution, thereby suppressing the interference of the old data distribution on the current identification and achieving an anti-drift effect.
[0038] Experiments have shown that when γ is in the range of 0.98 to 0.998, stable and significantly better accuracy than the baseline without time decay (i.e., γ=1, all samples are equally weighted) can be obtained.
[0039] Step S400: Based on the first distance weight and the first time decay weight, perform weighted voting on the categories to which the K historical samples belong, and take the category with the highest weighted voting score as the identification result corresponding to the sample to be identified.
[0040] After determining the first distance weight and the first time decay weight for each candidate historical sample, the system calculates a comprehensive weight for each sample. In this embodiment, the comprehensive weight = first distance weight × first time decay weight. For example, if the second similarity of a historical sample is 0.95 (first distance weight = 0.95) and it is 9 days old (first time decay weight = 0.956), then its comprehensive weight = 0.95 × 0.956 ≈ 0.908.
[0041] The system accumulates the comprehensive weights according to category. Assuming there are K=80 candidate samples, 15 samples belong to category "3", with a total comprehensive weight of 12.5; 10 samples belong to category "8", with a total comprehensive weight of 8.2; and the scores for the other categories are lower. Therefore, the system determines that category "3" has the highest weighted voting score and outputs category "3" as the identification result for the sample to be identified.
[0042] This weighted voting mechanism, combining distance and time, constructs a decision-making model that "neither forgets the past nor rejects the new": the first distance weight ensures the accuracy of identification, prioritizing the most similar neighbors; the first time decay weight ensures adaptability, prioritizing recent samples that conform to the current distribution characteristics. These two factors complement each other, enabling the system to dynamically adapt to changes in data distribution while retaining all historical memories.
[0043] After 10 days of continuous operation, this embodiment achieved an overall recognition accuracy of 88.9%. The recognition accuracy for early samples (such as categories stored from day 1 to day 5) remained unchanged, with no catastrophic forgetting—this is because the historical memory bank fully retains all historical samples, and old knowledge was never deleted. Furthermore, the introduction of the first-time decay weight allows the system to adapt to data drift caused by a 1° rotation each day, and the recognition accuracy on day 10 did not show a significant decrease compared to day 1.
[0044] Parameter tuning experiments verified that when K is between 5 and 100 and γ is between 0.98 and 0.998, stable and significantly better accuracy than the baseline without time decay (γ=1) can be achieved. When γ=1, time decay completely fails, and the system degenerates into pure distance-weighted voting, resulting in a significant drop in accuracy under data drift scenarios. This fully demonstrates the crucial contribution of the first time decay weight to combat drift effects.
[0045] Through the above steps, this embodiment achieves permanent memory of historical knowledge and dynamic adaptation to data drift without gradient training or updating model parameters, solving the technical problem of difficulty in balancing forgetting and drift in traditional continuous learning methods.
[0046] Example 2: This embodiment, based on embodiment 1, provides a detailed explanation of the specific mathematical model for determining the weights in step S300.
[0047] In step S300, the step of determining the first time decay weight includes: calculating the difference Δt between the timestamps of the K historical samples and the current time; calculating the first time decay weight according to the formula Wt=γ^Δt; where Wt is the first time decay weight, Δt is the difference between the timestamps of the historical samples and the current time, γ is a preset time decay factor, and 0.98≤γ≤0.998.
[0048] The time decay factor γ controls the rate at which old memories "fade" over time. The closer γ is to 0, the faster the decay; the closer γ is to 1, the slower the decay. In this embodiment, γ is limited to a narrow range of 0.98 to 0.998, which is the optimal parameter for balancing "anti-drift" and "anti-forgetting" defense depth, verified through extensive experiments.
[0049] Specifically, if the value of γ is too small (e.g., less than 0.98), the weight decays too quickly over time. For example, with γ=0.9, the weight of a sample only 10 time units from now has decayed to approximately 0.9^10 ≈ 0.349, and after 30 time units, it drops even further to approximately 0.9^30 ≈ 0.042, which is almost negligible. This means that the weight of earlier historical samples rapidly approaches zero during the voting process, essentially equivalent to a "soft deletion" of old memories—although the physical storage of the sample is not deleted, its influence on the decision is negligible, violating the original intention of this application to achieve zero forgetting by "only adding and not reducing".
[0050] Conversely, if γ is too large (e.g., greater than 0.998), the weight decays too slowly over time. For example, with γ=0.999, a sample from 100 time units ago still has a time decay weight of 0.999^100≈0.905, almost identical to a recent sample. In scenarios where data distributions drift over time, these older samples may represent outdated data distribution characteristics. Their excessively high weights can severely interfere with the recognition of new distribution characteristics, causing the system to be unable to adapt to the drift.
[0051] The parameter range of 0.98 ≤ γ ≤ 0.998 selected in this embodiment effectively suppresses interference from outdated data while preserving the core features of old memories, achieving a delicate balance between the two. In a 10-day rotational drift experiment simulated based on the digits dataset, when γ is 0.995, the overall recognition accuracy of the system on the 10th day reaches 88.9%, and the accuracy of old samples remains at 100% (i.e., the categories learned on the 1st day can still be correctly identified on the 10th day), fully verifying the effectiveness of this parameter range. Further experiments show that when γ is in the range of 0.98 to 0.998, stable and significantly better accuracy than the baseline without time decay (γ=1) can be obtained.
[0052] In step S300, the determination of the first distance weight includes the following two optional methods: based on the second similarity between the K historical samples and the sample to be identified, the monotonically increasing function corresponding to the second similarity is determined as the first distance weight; or, based on the sample distance corresponding to the second similarity between the K historical samples and the sample to be identified, the negative power function of the sample distance is determined as the first distance weight.
[0053] The first distance weight aims to quantify the contribution of sample proximity in the feature space to the classification decision. This embodiment provides two preferred function forms to adapt to different application scenarios.
[0054] The first approach uses a monotonically increasing function, with the second similarity as the independent variable, and the weight increases as the similarity increases. A typical example is when the second similarity is cosine similarity, the cosine similarity value is directly used as the first distance weight. For instance, if the cosine similarity between a historical sample and the sample to be identified is 0.95, then its first distance weight is directly set to 0.95; if the cosine similarity between another historical sample and the sample to be identified is 0.60, then its first distance weight is 0.60. This method is simple to calculate and has an intuitive physical meaning—the more similar the samples are, the greater their voting weight. In another variant, a sigmoid function or an exponential function can be used to perform a non-linear mapping of similarity to enhance the preference for highly similar samples.
[0055] When the second similarity metric uses Euclidean distance, the first approach can correspondingly employ a Gaussian kernel function as a monotonically increasing function—in this case, the smaller the distance, the higher the similarity, and the larger the corresponding weight. The Gaussian kernel function takes the form exp(-β×d²), where d is the Euclidean distance and β is a parameter controlling the decay rate. A characteristic of the Gaussian kernel function is that when the distance d approaches zero, the weight approaches 1; as the distance d increases, the weight smoothly decays towards 0. This function form is very sensitive to distance changes, significantly highlighting the influence of nearest neighbor samples, and is suitable for scenarios with relatively compact feature distributions and small intra-class variance.
[0056] The second approach uses a negative power function, with the distance between samples as the independent variable. A typical example is the reciprocal function, in the form 1 / (d+ε), where d is the Euclidean distance or other distance metric, and ε is a small constant to prevent the denominator from being zero. The reciprocal function is simpler and more direct to calculate, requiring no exponential operations, yet still achieving the effect of "the closer the distance, the greater the weight," making it suitable for edge device deployment scenarios where computational efficiency is critical. For example, if the Euclidean distance between a sample and the sample to be identified is 0.2, and ε=0.01, then its distance weight = 1 / (0.2+0.01)≈4.76; for another sample at a distance of 1.5, its weight = 1 / (1.5+0.01)≈0.66. The smaller the distance, the greater the weight, and the increase is non-linear. In other variations, 1 / (d²+ε) or other negative power forms can be used to further increase the penalty for samples at greater distances.
[0057] It should be understood that the above two function forms are merely examples. Those skilled in the art can choose other function forms that conform to the monotonically increasing property (first method) or the negative distance correlation property (second method) according to the actual data distribution characteristics. As long as they can achieve the mapping logic of "the more similar the features / the closer the distance, the greater the weight", they should be regarded as falling within the protection scope of this application.
[0058] After calculating the first distance weight and the first time decay weight, the system combines the two to obtain the comprehensive weight for each candidate historical sample. This embodiment uses a product form: Comprehensive Weight = First Distance Weight × First Time Decay Weight. For example, if a historical sample has a cosine similarity of 0.95 with the sample to be identified (first distance weight = 0.95) and is 9 days old (first time decay weight = 0.995^9 ≈ 0.956), then its comprehensive weight = 0.95 × 0.956 ≈ 0.908. This product form ensures that the weights of the two dimensions are independent yet work together—when the weight of either dimension approaches zero, the comprehensive weight also tends towards zero, effectively preventing "unqualified" samples from either dimension from significantly influencing the decision.
[0059] By combining the first distance weight with the first time decay weight, this embodiment constructs a comprehensive evaluation system that considers both feature similarity and timeliness. The distance dimension ensures the accuracy of identification by prioritizing the most similar neighbors; the time dimension ensures adaptability by prioritizing recent samples that conform to the current distribution characteristics. The combination of the two is simple and efficient, ensuring the accuracy and timeliness of the identification results. Furthermore, the specific functional forms and parameter ranges of each weight are supported by sufficient experimental data, making the technical solution reliable and reproducible.
[0060] Example 3: This embodiment, building upon Embodiments 1 and 2, further constructs a defense mechanism to address severe data drift. In practical applications, the degree of data distribution drift is often unpredictable. When sudden, severe drift occurs, relying solely on the continuous-time decay weighted mode described in Embodiment 2 may not yield reliable identification results. Therefore, this embodiment introduces a discrete-time block inference mode, forming a two-tiered defense system of "continuous mode—discrete mode".
[0061] Specifically, the method further includes the following steps: Step S500: Determine whether the highest value of the weighted voting score is lower than the preset confidence threshold.
[0062] After the weighted voting as described in Example 1 is completed, the system obtains a category with the highest score and its corresponding weighted voting score. Following this, the system performs a confidence level determination step: determining whether the highest value of the weighted voting score is lower than a preset confidence level threshold.
[0063] The confidence threshold is a critical value used to measure the reliability of the identification result. During the weighted voting process, if the highest score is higher than or equal to this threshold, it indicates that the voting opinions of the K historical neighbors are relatively concentrated, forming a relatively clear dominant category determination. The identification result is reliable, and the system directly outputs this category as the final identification result. Conversely, if the highest score is lower than this threshold, it indicates that the voting opinions of the K historical neighbors are seriously divergent, making it impossible to form a dominant category determination. This situation usually occurs when the sample to be identified is in a blind spot of the historical memory bank, or when the data distribution has undergone drastic shifts, causing old samples to severely interfere with the current judgment.
[0064] In this embodiment, the confidence threshold is set to 0.7. This value has been experimentally verified: when the highest weighted voting score reaches 0.7 or higher, the classification accuracy is significantly higher than when it is below 0.7. Taking a specific query as an example, after continuous-time decay weighted voting, the highest-scoring category "3" of a sample to be identified has a comprehensive score of only 0.55, which is lower than the threshold of 0.7. At this time, the system determines that the continuous-time decay weighted mode may have failed and triggers the discrete-time block inference mode to backtrack.
[0065] Step S600: If the confidence level is lower than the confidence threshold, then the target time sub-database is determined from the historical memory database based on the feature vector of the sample to be identified.
[0066] When a continuous pattern is deemed invalid, the system initiates a rollback mechanism. The core of this step lies in narrowing the search scope from the vast global historical memory to a specific local time window, thereby eliminating interference from other time blocks of data and improving the targeting and accuracy of the search.
[0067] Specifically, such as Figure 3 As shown, the process of determining the target time sub-database from the historical memory bank includes the following sub-steps.
[0068] Sub-step S601: Divide the historical memory bank into several discrete time blocks according to time sequence.
[0069] The system divides the historical memory into multiple discrete time blocks according to a preset time period based on the timestamps of historical samples. The granularity of the division depends on the characteristics of the application scenario. In the 100-day rotational drift experiment of this embodiment, the system divides the data on a "day" basis, with the samples stored on each day constituting an independent time block. The time block for day 1 contains all historical samples for that day, the time block for day 2 contains all historical samples for that day, and so on, forming a total of 100 time blocks. In another embodiment, the data can also be divided by week, month, or task cycle.
[0070] The samples within each time block represent the data distribution characteristics within that time period. As data drift continues, the data distribution characteristics of different time blocks also migrate—the samples from day 1 are not rotated, the samples from day 50 are rotated by approximately 50°, and the samples from day 100 are rotated by approximately 100°. By layering the memory by time, the system preserves the complete trajectory of data drift.
[0071] Sub-step S602: Calculate the distribution matching degree between the sample to be identified and each time block based on the feature vector of the sample to be identified.
[0072] Distribution matching degree is used to measure the degree of similarity between the sample to be identified and the distribution characteristics of the samples within each time block. In a preferred embodiment, the cluster centers or mean vectors of all sample feature vectors within each time block can be pre-calculated as representative features of that time block. Then, the distance (such as Euclidean distance or cosine distance) between the feature vector of the sample to be identified and the representative features of each time block is calculated. The smaller the distance, the better the sample to be identified matches the distribution characteristics of that time block, i.e., the higher the distribution matching degree.
[0073] In another implementation, an instance-based inference model—such as a K-nearest neighbor classifier—can be used to predict the time block to which the sample to be identified belongs. Specifically, each time block is treated as a category, and the representative features of each time block are used as a reference for that category. The K-nearest neighbor method is then used to determine which time block the sample to be identified most likely belongs to.
[0074] Sub-step S603: The time block with the highest distribution matching degree is taken as the target time sub-library.
[0075] The system compares the distribution matching degree of the sample to be identified with each time block and selects the time block with the highest matching degree as the target time sub-library. For example, in a rotational drift scenario, the time block with the highest distribution matching degree for a sample to be identified that has undergone about 50° rotation is usually the time block around day 50, because the rotation angle of the samples in that time block is closest to that of the sample.
[0076] Through the above sub-steps, the system identifies the historical data segment most relevant to the current sample to be identified. This distribution-matching-based localization method can accurately map the sample to be identified to its most likely time segment, thereby eliminating interference from irrelevant time blocks in subsequent searches and focusing on utilizing the most valuable historical information.
[0077] Step S700: Re-select K′ historical samples in the target time sub-database, calculate the corresponding second distance weight and second time decay weight, perform secondary weighted voting, and take the category corresponding to the highest score in the secondary voting as the recognition result.
[0078] After defining the target time sub-database, the system re-executes a retrieval and weighted voting process similar to steps S200 to S400 in Example 1 within the target time sub-database.
[0079] Specifically, the system calculates the similarity between the feature vector of the sample to be identified and the feature vectors of each historical sample in the target time sub-database, and selects the K′ most similar historical samples based on the similarity ranking. The value of K′ can be the same as the K value used in global retrieval (e.g., K′=80), or it can be adjusted according to the sample size of the target time sub-database (e.g., appropriately reducing the K′ value when the sample size in the sub-database is small). Then, the system calculates a second distance weight and a second time decay weight for these K′ historical samples respectively, wherein the calculation method of the second distance weight is the same as that of the first distance weight in Example 2, and the calculation method of the second time decay weight is the same as that of the first time decay weight in Example 2. Next, the system performs weighted voting by category based on the comprehensive weight (second distance weight × second time decay weight), calculates the secondary weighted voting score of each category, and outputs the category with the highest score as the secondary identification result.
[0080] Because the search scope is limited to the time block most similar to the current data distribution, the retrieved neighbor samples are highly consistent with the sample to be identified in terms of feature distribution, making them extremely valuable for reference. At the same time, limiting the search scope also eliminates interference from samples with significantly different distributions in other time blocks, thereby significantly improving the recognition accuracy in scenarios with drastic data shifts.
[0081] This embodiment constructs a discrete-time block inference mode as a fallback mechanism for the continuous-time decay weighted mode, forming a two-tiered defense system of "continuous mode - discrete mode". In a 100-day rotational drift experiment simulated based on the digits dataset, the overall recognition accuracy reached 97.0% after adopting the discrete-time block inference mode, and the sample accuracy of all old time blocks remained at 100% (i.e., Δ=0, no catastrophic forgetting occurred). In terms of storage, the daily instance library size is approximately 68KB, totaling approximately 6.8MB over 100 days, and the storage overhead is within the acceptable range for embedded devices.
[0082] Furthermore, when combining the continuous-time decay weighted mode with the discrete-time block inference mode—that is, first executing the continuous mode and then reverting to the discrete mode when the highest weighted vote score falls below the confidence threshold of 0.7—the combined strategy achieves an accuracy of 93.2% in mixed scenarios of sudden and slow drift, compared to only 86.1% for the single continuous decay strategy and 89.5% for the single discrete block strategy. The combined strategy leverages both the smooth adaptability of the continuous mode to slow drift and the rapid response capability of the discrete mode to sudden drift, achieving full coverage of multiple drift types.
[0083] Example 4: Building upon Example 3, this example further introduces a rejection mechanism to construct the final line of defense for system security. In actual deployment, the system inevitably encounters completely unfamiliar inputs—such as a brand-new sample that does not belong to any known category, or severely distorted data caused by sensor malfunction. In these extreme cases, even after two levels of inference—continuous and discrete modes—the system still cannot make a reliable judgment. Forcing a low-confidence category label at this point could lead to erroneous decisions, potentially causing serious consequences in security-critical applications (such as industrial control and medical diagnosis).
[0084] Specifically, in step S800: if the highest score in the second-weighted voting score is still lower than the confidence threshold, or the similarity between the sample to be identified and the nearest neighbor sample in the historical memory bank is lower than the minimum similarity threshold, then a rejection signal is output.
[0085] This step sets two independent rejection trigger conditions; rejection will be triggered if either condition is met.
[0086] Triggering condition 1: The highest score in the second-weighted voting is still lower than the confidence threshold.
[0087] In the rollback process of Example 3, the system has already re-executed the retrieval and weighted voting within the target time sub-database. If the highest score of the second weighted voting is still lower than the preset confidence threshold (set to 0.7 in this example), it indicates that even if the retrieval scope is narrowed to the time block that best matches the current sample, the system's judgment still has a high degree of uncertainty. The voting opinions of the K′ historical neighbors are severely dispersed, and no category can obtain more than half of the weighted scores. This situation usually indicates that the sample to be identified may belong to an unknown category—this category has never appeared in the historical memory database, so there are no highly similar samples in the database. At this time, if a slightly higher score category label is forcibly output, its reliability is extremely low, and the possibility of error is very high.
[0088] Triggering condition two: The similarity between the sample to be identified and the nearest neighbor sample in the historical memory bank is lower than the minimum similarity threshold.
[0089] Even if the highest score from the weighted voting formally reaches the confidence threshold, the system still needs to check a more fundamental data point—the absolute similarity between the sample to be identified and its nearest neighbor in the historical memory. This minimum similarity threshold is set based on the statistical distribution of distances between training samples. In this embodiment, the minimum similarity threshold is the 95th percentile of the distances between training samples. Specifically, during system initialization, the feature distances (or feature similarities) between each pair of training samples are calculated, and the 95th percentile distance value is used as the minimum similarity threshold. This means that within the training set, the distance between more than 95% of sample pairs is less than this threshold. If the distance between the sample to be identified and its nearest neighbor in the database exceeds this threshold, it indicates that the sample differs abnormally from all known samples, and is highly likely to belong to a completely new category that has never been seen before.
[0090] When any of the above conditions are met, the system outputs a rejection signal instead of a category label. In this embodiment, the rejection signal is output as a specific error code (such as "-1") or an "unknown category" marker. In other embodiments, the specific form of the rejection signal can be flexibly set according to the actual application scenario—for example, illuminating a warning light and triggering an alarm in a security monitoring scenario, sending alarm information from a smart sensor to a cloud control console, requesting manual intervention or triggering a resampling process in a robot's autonomous decision-making process. By outputting a rejection signal, the system clearly informs downstream modules or operators that the current input cannot be reliably classified and requires further processing.
[0091] In experiments where unknown category samples were mixed into the test set, after setting a minimum similarity threshold (the 95th percentile of the distance between training samples), the system could correctly reject 49% of the unknown samples (93% accuracy), while the recognition accuracy of known categories was not affected—the rejection mechanism only outputs rejection signals for abnormal samples and does not interfere with the classification process of normal samples.
[0092] By introducing a rejection mechanism, this embodiment adds a third security barrier to the existing two-tier defense system of "continuous mode - discrete mode," forming a three-tiered progressive response strategy of "continuous - discrete - rejection." The system first attempts a global continuous-time decay-weighted mode. When the confidence level is insufficient, it reverts to a local discrete-time block inference mode. When neither of the two levels of retrieval can provide a reliable judgment, the rejection mechanism prevents erroneous output. This layered progressive defense strategy ensures lifelong learning capabilities while maximizing the security, reliability, and trustworthiness of the system in actual deployment.
[0093] Example 5: Building upon the previous embodiments, this embodiment further constructs a two-layer memory architecture of "main library + patch" to achieve rapid correction of specific erroneous samples. In practical applications, although the history memory can cover the vast majority of samples, there may be some long-tailed samples or high-frequency error-prone samples. These samples may be located at the class boundary in the feature space and are easily misclassified. Directly modifying the data in the history memory or retraining the feature extractor would incur huge computational overhead and may even disrupt the stability of the feature space. Therefore, this embodiment introduces an independent patch memory mechanism.
[0094] The patch memory exists independently of the history memory. Unlike the history memory, which uses a permanent memory strategy that only adds to and never decrements, the patch memory is designed for rapid correction of recent high-frequency erroneous samples. Its storage space is typically small, with a capacity limit. In this embodiment, the patch memory's capacity is preset to 300 samples. High-priority samples typically refer to those misclassified during historical identification or key samples manually marked by the user. Due to the small data volume and high specificity of the patch memory, the retrieval speed is much faster than performing a global search in the vast history memory.
[0095] Specifically, step S900: retrieve a pre-built patch memory, which is used to store a preset number of high-priority samples.
[0096] After the feature vector of the sample to be identified is extracted, the system prioritizes searching the patch memory before querying the historical similarity database. The system calculates the third similarity between the feature vector of the sample to be identified and the feature vectors of each patch sample in the patch memory. The third similarity can be measured using the same or a different method as the first similarity; in this embodiment, cosine similarity is used.
[0097] Step S1000: If there is a hit sample in the patch memory that has a third similarity to the feature vector that exceeds a preset patch threshold, then the category to which the hit sample belongs is directly used as the recognition result.
[0098] This step establishes the retrieval priority of the patch memory. If the feature vector of the sample to be identified is highly similar to that of a sample in the patch memory—for example, the cosine similarity exceeds the preset patch threshold of 0.95—it is considered a match, and the system directly returns the correct category label corresponding to that patch sample as the identification result, without the need for subsequent complex global retrieval and weighted voting processes. This "short-circuit" mechanism can correct high-frequency errors with extremely low computational overhead.
[0099] In experiments involving noisy labels, the introduction of a patch memory improved the accuracy of queries without timestamps from 86.5% to 88.9% (on par with the benchmark with timestamps), with a patch hit rate of approximately 15%. This means that about 15% of query samples directly obtained correct identification results through the patch memory, effectively compensating for the performance loss caused by missing information.
[0100] Step S1100: If no match is found, the step of calculating the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank, and selecting K historical samples from the historical memory bank based on the first similarity is performed.
[0101] If no matching sample is found in the patch memory—for example, the highest third similarity in the patch memory is only 0.85, which does not reach the preset patch threshold of 0.95—it means that the current sample does not belong to the known error-prone category. The system will then fall back to the standard global retrieval process (i.e., steps S100 to S400 as described in Example 1) and use the historical memory for identification. This design ensures that the intervention of the patching mechanism will not negatively affect the normal identification process, and also ensures that the patch memory only applies to specific samples that it is capable of correcting.
[0102] Furthermore, in order to maintain the timeliness and effectiveness of the patch memory, the system performs dynamic maintenance on the patch memory.
[0103] Step S1200: Receive the truth category based on the recognition result.
[0104] The system's output recognition results (whether from a patch memory hit or a weighted vote from a history memory) can be verified by the user, upstream modules, or the external environment. When an external feedback mechanism provides the true category of the sample, the system compares it with its own recognition results.
[0105] Step S1300: If the recognition result is inconsistent with the true value category, store the feature vector of the sample to be recognized and its corresponding true value category into the patch memory.
[0106] When an error is detected—for example, the system misidentifies a handwritten digit "8" as "3"—the system does not modify any data in the historical memory. Instead, it stores the feature vector of the erroneous sample and its correct truth class label ("8") as a patch record in the patch memory. This "patching" method avoids disrupting the "only adding, never deleting" property of the historical memory, ensuring the stability and integrity of the core memory. The main historical memory always maintains its complete historical record, with the patch memory superimposed on top as an independent error correction module.
[0107] Step S1400: If the storage capacity of the patch memory reaches the upper limit, the least recently used sample is eliminated according to the least recently used strategy.
[0108] Due to hardware resource limitations, the patch memory has a limited capacity. When the number of samples stored in the patch memory reaches a preset limit (300 in this embodiment), if a new erroneous sample needs to be stored, the system uses the Least Recently Used (LRU) strategy to evict the least recently used old patch sample.
[0109] This contrasts sharply with the "only increase, never decrease" strategy of the historical memory bank: the historical memory bank pursues permanent memory and does not actively delete any old samples when learning new samples, thus ensuring zero forgetting; while the patch memory bank pursues dynamic error correction, automatically forgetting old errors that no longer occur frequently through the LRU strategy, freeing up space for new errors that occur more frequently now, thereby achieving efficient use of limited storage resources.
[0110] By constructing a two-layer memory architecture of "master database + patch database," this embodiment achieves rapid correction of recurring errors while maintaining the integrity of the historical database. The independent storage and priority retrieval mechanism of the patch database ensures that the error correction process does not affect the "only increase, no decrease" property of the master database; the LRU eviction policy ensures that the patch database always focuses on the most active error-prone samples. Experiments show that when the patch database capacity is 300, the accuracy of timestampless queries is improved from 86.5% to 88.9%, with a patch hit rate of approximately 15%, fully validating the effectiveness of this mechanism.
[0111] It should be understood that the maximum capacity of the patch memory, the preset patch threshold, and the eviction policy can all be adjusted according to specific application scenarios and hardware resources. For example, on devices with sufficient storage resources, the patch memory capacity can be appropriately increased to cover more long-tail samples; in scenarios with extremely high real-time requirements, the patch threshold can be appropriately increased to ensure hit accuracy.
[0112] This application also provides a data drift-resistant memory retrieval system. The data drift-resistant memory retrieval system of this application includes: The feature comparison module is used to obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector. The retrieval memory module is used to select K historical samples from the historical memory bank based on the first similarity, where 5≤K≤100 and K is a positive integer. The historical memory bank does not delete the old samples that have been stored when storing new samples. The weight calculation module is used to determine the first distance weight and the first time decay weight corresponding to the K historical samples based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, respectively. The weighted voting module is used to perform weighted voting on the categories to which the K historical samples belong based on the first distance weight and the first time decay weight, and to take the category with the highest weighted voting score as the identification result corresponding to the sample to be identified.
[0113] Optionally, the weight calculation module is further used for: Calculate the difference between the timestamps of the K historical samples and the current time; The first-time decay weight is calculated using the formula Wt=γ^Δt; Where Wt is the time decay weight, Δt is the difference between the timestamp of the historical sample and the current time, and γ is the preset time decay factor, and 0.98≤γ≤0.998.
[0114] Optionally, the weight calculation module is further used for: Based on the second similarity between the K historical samples and the sample to be identified, the monotonically increasing function corresponding to the second similarity is determined as the first distance weight; or... Based on the sample distances corresponding to the second similarity between the K historical samples and the sample to be identified, the negative power function of the sample distances is determined as the first distance weight.
[0115] Optionally, the anti-data drift memory retrieval system further includes a discrete-time block inference module, which is used for: Determine whether the highest value of the weighted voting score is lower than a preset confidence threshold; If the confidence level is lower than the confidence threshold, then the target time sub-database is determined from the historical memory database based on the feature vector of the sample to be identified. K′ historical samples are re-selected from the target time sub-database, and the corresponding second distance weight and second time decay weight are calculated. A second weighted vote is then performed, and the category corresponding to the highest score in the second vote is taken as the recognition result.
[0116] Optionally, the discrete-time block inference module is further configured to: The historical memory bank is divided into several discrete time blocks according to chronological order; Based on the feature vector of the sample to be identified, calculate the distribution matching degree between the sample to be identified and each time block; The time block with the highest distribution matching degree is taken as the target time sub-library.
[0117] Optionally, the anti-data drift memory retrieval system further includes a rejection module, which is used for: If the highest score in the second-weighted voting score is still lower than the confidence threshold, or if the similarity between the sample to be identified and the nearest neighbor sample in the historical memory bank is lower than the minimum similarity threshold, then a rejection signal is output.
[0118] Optionally, the anti-data drift memory retrieval system further includes a patch memory module, which is used for: Retrieve a pre-built patch memory, which is used to store a predetermined number of high-priority samples; If there is a hit sample in the patch memory whose third similarity to the feature vector of the sample to be identified exceeds a preset patch threshold, then the category to which the hit sample belongs is directly used as the identification result. If no match is found, the steps of calculating the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank, and selecting K historical samples from the historical memory bank based on the first similarity are performed.
[0119] Optionally, the patch memory module is also used for: Receive the truth value category fed back based on the recognition result; If the recognition result is inconsistent with the true value category, the feature vector of the sample to be identified and its corresponding true value category are stored in the patch memory. If the storage capacity of the patch memory reaches its limit, the least recently used sample will be evicted according to the least recently used strategy.
[0120] Based on the above system implementation embodiments, such as Figure 4 As shown, this embodiment also provides an electronic device. The electronic device includes: a processor 1001, a memory 1005, a communication interface (including a user interface 1003 and a network interface 1004), and a communication bus 1002. The processor, the memory, and the communication interface communicate with each other through the communication bus. The memory stores at least one executable instruction, which causes the processor to perform the steps of the anti-data drift memory retrieval method as described in the foregoing method embodiments.
[0121] Specifically, the processor is the core of the electronic device's computation and control, and can be a central processing unit, microcontroller, digital signal processor, or field-programmable gate array (FPGA). The memory includes random access memory for storing runtime data and temporary variables, and non-volatile memory for persistently storing historical and patch memory. The communication interface is used to receive sample data to be identified and output identification results. This electronic device can be deployed as an embedded vision processing unit in a smart security camera, a perception and memory module in a service robot, or an edge computing node for industrial sensors, and is particularly suitable for edge AI scenarios with limited computing power, requiring continuous local learning and unable to rely on cloud training.
[0122] Those skilled in the art will understand that Figure 4 The device structure shown does not constitute a limitation on this electronic device and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0123] like Figure 4 As shown, the memory 1005, which serves as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a data drift retrieval program.
[0124] The operating system is a program that manages and controls electronic devices and software resources, and supports the operation of the network communication module, user interface module, anti-data drift memory retrieval program, and other programs or software; the network communication module is used to manage and control the network interface 1004; and the user interface module is used to manage and control the user interface 1003.
[0125] exist Figure 4 In the electronic device shown, the processor 1001 calls the anti-data drift memory retrieval program stored in the memory 1005 and executes the operations in the various embodiments of the anti-data drift memory retrieval method described above.
[0126] This embodiment also provides a storage medium, which is a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the steps of the anti-data drift memory retrieval method as described in the foregoing method embodiments. The storage medium can be any tangible medium capable of storing a computer program, such as a read-only memory, flash memory, disk, or optical disk.
[0127] This embodiment also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the anti-data drift memory retrieval method as described in the foregoing method embodiments. This computer program product can exist in physical form, or it can be distributed and deployed as software downloads or cloud services.
[0128] Furthermore, this embodiment provides a detailed description of relevant scenarios. In a test simulating 10 days of rotational drift using a handwritten digit dataset (8×8 grayscale images, 10 classes) (increasing rotation by 1° each day), 200 labeled samples (30% of which were label noise) were provided on day 1, and only 50 labeled samples were provided each subsequent day. The weighted voting parameters were set to K=80, γ=0.995, and the distance weight used a Gaussian kernel exp(-1.5×dist²). Experimental results showed that the overall recognition accuracy reached 88.9% on day 10, while the accuracy of old samples remained unchanged. Parameter optimization verified that stable and significantly better accuracy than the baseline without time decay could be obtained when K was between 5 and 100 and γ was between 0.98 and 0.998.
[0129] In the 100-day rotational drift test, feature extraction employed principal component analysis (trained using only the data from day 1 and then frozen, retaining 95% of the variance). Time blocks were divided by day, and the instance library was stored independently for each day. The 100-day mixed test set contained 15,000 samples, achieving an overall recognition accuracy of 97.0%, with the accuracy remaining unchanged for all previous days (Δ=0). In terms of storage overhead, the instance library size was approximately 68KB per day, totaling approximately 6.8MB over 100 days.
[0130] An independent patch memory (capacity 300) is introduced on top of the continuous time decay weighted model. The patch memory improves the accuracy of timestampless queries from 86.5% to 88.9%, matching the timestamp baseline, with a patch hit rate of approximately 15%. The main history memory always maintains a "only increase, never decrease" approach, and the patch memory, as an independent error correction module, does not affect the integrity of the main memory due to its least recently used eviction policy.
[0131] When the highest class confidence score of the continuous-time decay weighted voting falls below the threshold of 0.7, it automatically reverts to the discrete-time block inference mode. In mixed scenarios of sudden drift and slow drift, the combined strategy achieves an accuracy of 93.2%, while the single continuous decay strategy achieves 86.1%, and the single discrete block strategy achieves 89.5%.
[0132] Tested on high-dimensional linearly separable synthetic data (10 classes, 256-dimensional Gaussian distribution, with inter-class mean and Euclidean distance of 10, and intra-class variance σ²=1.0), the algorithm still achieves an accuracy of over 97% even with 30% label noise, and reaches 100% after noise removal.
[0133] The distance threshold is set to the 95th percentile of the distance to the training samples. When unknown classes are mixed into the test set, the rejection mechanism can correctly reject 49% of the unknown samples (93% precision), while the accuracy of known classes remains unaffected.
[0134] It should be understood that the specific parameter values described in the above embodiments—such as the K value, time decay factor γ, distance weight function form, time unit, patch capacity, etc.—are all illustrative examples and are not intended to limit the scope of protection of this application. The core of this application lies in "a fixed feature extractor + a historical memory bank that only increases and never decreases + a retrieval voting mechanism based on time decay weighting". The specific value range of the time decay factor, 0.98 to 0.998, is the preferred implementation range of this application. In the claim of the weighting function that monotonically decreases according to the time difference, γ^(Δt) is only a preferred example. Any other function form with monotonically decreasing properties in the time decay weighted retrieval scenario—such as a linear decay function, a reciprocal decay function, etc.—should be considered to fall within the scope of protection of this application. Similarly, the calculation of distance weight is not limited to Gaussian kernel or reciprocal form. Any monotonically weighting function based on feature similarity or distance between samples is within the equivalent scope of this application. The hit standard of patch memory is also not limited to cosine similarity. Any determination method based on feature vector similarity measurement is within the equivalent scope of this application. Based on the above disclosure, those skilled in the art can make adaptive adjustments to the specific values and deployment methods of each parameter according to actual application needs and available hardware conditions. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the technical solution of this application should be included within the protection scope of this application.
[0135] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.
[0136] The sequence numbers of the embodiments in this application are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.
[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0138] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of this application.
[0139] The core of this application lies in its method steps and system architecture, and is not limited to a specific computing paradigm or hardware platform. Any technical solution that implements the method steps described in this application on classical computing, quantum computing, neuromorphic computing, or other computing paradigms should be considered to fall within the protection scope of this application.
Claims
1. A memory retrieval method resistant to data drift, characterized in that, include: Obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector; Based on the first similarity, K historical samples are selected from the historical memory bank, where 5≤K≤100 and K is a positive integer. The historical memory bank does not delete the old samples that have been stored when storing new samples. Based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, the first distance weight and the first time decay weight corresponding to the K historical samples are determined respectively; Based on the first distance weight and the first time decay weight, a weighted vote is performed on the categories to which the K historical samples belong, and the category with the highest weighted vote score is taken as the identification result corresponding to the sample to be identified.
2. The anti-data drift memory retrieval method according to claim 1, characterized in that, The steps for determining the first time decay weight include: Calculate the difference between the timestamps of the K historical samples and the current time; The first-time decay weight is calculated using the formula Wt=γ^Δt; Where Wt is the time decay weight, Δt is the difference between the timestamp of the historical sample and the current time, and γ is the preset time decay factor, and 0.98≤γ≤0.
998.
3. The anti-data drift memory retrieval method according to claim 1, characterized in that, The steps for determining the first distance weight include: Based on the second similarity between the K historical samples and the sample to be identified, the monotonically increasing function corresponding to the second similarity is determined as the first distance weight; or... Based on the sample distances corresponding to the second similarity between the K historical samples and the sample to be identified, the negative power function of the sample distances is determined as the first distance weight.
4. The anti-data drift memory retrieval method according to claim 1, characterized in that, The method further includes: Determine whether the highest value of the weighted voting score is lower than a preset confidence threshold; If the confidence level is lower than the confidence threshold, then the target time sub-database is determined from the historical memory database based on the feature vector of the sample to be identified. K′ historical samples are re-selected from the target time sub-database, and the corresponding second distance weight and second time decay weight are calculated. A second weighted vote is then performed, and the category corresponding to the highest score in the second vote is taken as the recognition result.
5. The anti-data drift memory retrieval method according to claim 4, characterized in that, The step of determining the target time sub-database from the historical memory database includes: The historical memory bank is divided into several discrete time blocks according to chronological order; Based on the feature vector of the sample to be identified, calculate the distribution matching degree between the sample to be identified and each time block; The time block with the highest distribution matching degree is taken as the target time sub-library.
6. The anti-data drift memory retrieval method according to claim 4, characterized in that, The method further includes: If the highest score in the second-weighted voting score is still lower than the confidence threshold, or if the similarity between the sample to be identified and the nearest neighbor sample in the historical memory bank is lower than the minimum similarity threshold, then a rejection signal is output.
7. The anti-data drift memory retrieval method according to claim 1, characterized in that, The method further includes: Retrieve a pre-built patch memory, which is used to store a predetermined number of high-priority samples; If there is a hit sample in the patch memory whose third similarity to the feature vector of the sample to be identified exceeds a preset patch threshold, then the category to which the hit sample belongs is directly used as the identification result. If no match is found, the steps of calculating the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank, and selecting K historical samples from the historical memory bank based on the first similarity are performed.
8. The anti-data drift memory retrieval method according to claim 7, characterized in that, The method further includes: Receive the truth value category fed back based on the recognition result; If the recognition result is inconsistent with the true value category, the feature vector of the sample to be identified and its corresponding true value category are stored in the patch memory. If the storage capacity of the patch memory reaches its limit, the least recently used sample will be evicted according to the least recently used strategy.
9. A data drift-resistant memory retrieval system, characterized in that, The anti-data drift memory retrieval system includes: The feature comparison module is used to obtain the feature vector of the sample to be identified, and calculate the first similarity between the sample to be identified and each historical sample in the pre-constructed historical memory bank based on the feature vector. The retrieval memory module is used to select K historical samples from the historical memory bank based on the first similarity, where 5≤K≤100 and K is a positive integer. The historical memory bank does not delete the old samples that have been stored when storing new samples. The weight calculation module is used to determine the first distance weight and the first time decay weight corresponding to the K historical samples based on the second similarity between the K historical samples and the sample to be identified and the timestamps of the K historical samples, respectively. The weighted voting module is used to perform weighted voting on the categories to which the K historical samples belong based on the first distance weight and the first time decay weight, and to take the category with the highest weighted voting score as the identification result corresponding to the sample to be identified.
10. An electronic device, characterized in that, include: The processor, memory, communication interface, and communication bus are provided, wherein the processor, memory, and communication interface communicate with each other via the communication bus. The memory is used to store at least one executable instruction that causes the processor to perform the steps of the anti-data drift memory retrieval method as described in any one of claims 1 to 8.
11. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the anti-data drift memory retrieval method as described in any one of claims 1 to 8.
12. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the steps of the anti-data drift memory retrieval method as described in any one of claims 1 to 8.