A prototype contrast-based user preference classification-oriented continual learning method
By constructing a fixed-capacity memory buffer and a joint contrastive loss function based on prototype comparison, the problems of "catastrophic forgetting" and buffer growth in deep neural networks under dynamic changes in user categories are solved, achieving stable user preference classification and efficient utilization of computing resources.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING UNIV
- Filing Date
- 2026-04-28
- Publication Date
- 2026-06-05
AI Technical Summary
Existing deep neural networks are prone to "catastrophic forgetting" when faced with a continuous increase in dynamic user categories, and the memory cache capacity in traditional experience replay methods is constantly growing, making it impossible for the model to stably learn historical knowledge and new user features.
We adopt a prototype-based comparison-oriented user preference classification method. By constructing a fixed-capacity memory buffer and a joint comparison loss function, we activate the prototype of the currently active category and restrict the gradient propagation of inactive historical categories. By combining instance-level and prototype-level loss functions, we extract the global category prototype and keep the model stable.
It effectively alleviates the "catastrophic forgetting" problem, reduces storage and computing overhead, and improves classification accuracy and stability, making it suitable for dynamic user preference classification tasks in e-commerce platforms and online recommendation systems.
Smart Images

Figure CN122153541A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of artificial intelligence, machine learning, continuous learning, and contrastive learning, and particularly to a contrastive experience replay method in continuous learning. It is applicable to dynamic user preference classification tasks in various e-commerce platforms, user data surveys, and online services. Background Technology
[0002] In e-commerce platforms based on massive user data, the system stores huge amounts of user interaction data every day. User interests and preferences exhibit significant changes over different periods: user types are not static but constantly change with the passage of time and the external environment. This requires the backend classification model to continuously learn categories as user data streams arrive.
[0003] Existing deep neural networks are highly susceptible to "catastrophic forgetting" when faced with a continuous increase in dynamic user categories. This phenomenon is directly caused by the imbalance in gradient propagation between old and new category data, leading to frequent changes in network parameters. To alleviate this problem, a comparative experience replay method has been proposed. This method directly calculates the similarity between anchor samples and other samples in the current batch for comparative classification. However, when the model uses the experience replay method to calculate the loss function in continuous learning, the memory buffer used for experience replay in practical applications is extremely small. New category samples dominate in the current training batch, and the massive amount of new category data forces historical category data to be pushed away in the feature space. This results in the system overly catering to user types with new preferences while forgetting target users with whom it has long-term contact.
[0004] For systems with limited computing resources and constantly changing user preference data distribution, there is an urgent need for a user classification scheme that can extract global category prototypes to stabilize the historical knowledge learned by the model, take into account the individual characteristics of new batches of users, and fix the memory cache capacity. Summary of the Invention
[0005] Purpose of the Invention: Addressing the problems and shortcomings of existing technologies, this invention, based on the research project "Cognitive Development-Driven Sustainable Learning Theory and Methods," provides a continuous learning method for user preference classification based on prototype comparison. It aims to solve the problem of "catastrophic forgetting" of models in online business systems caused by the dynamic changes of different user types, and overcome the problem of continuously growing memory cache capacity in traditional experience replay methods. It is applicable to classification tasks where user types change over time in scenarios such as online recommendation systems.
[0006] Technical solution: A continuous learning method for user preference classification based on prototype comparison, comprising the following steps: Step 1: Acquire the user interaction behavior data stream arriving incrementally, perform standardized mapping processing on it, construct a two-dimensional matrix, and input it into the initialized feature extraction network. Extract feature vectors; simultaneously initialize prototype parameter dictionaries representing various user preference types. ; Step 2: Construct a fixed-capacity memory cache. It is used to store the representative sample features and corresponding categories of users who meet the requirements in the historical user categories; Step 3, in each online continuous learning cycle In the process, new user samples with different preferences appearing in the current batch are obtained, and a retrieval strategy is used to retrieve them from the memory cache. The search results represent a sample of users with historical preferences. Step 4: Concatenate and mix the new preference user samples with the historical preference user samples and perform data augmentation to construct the actual training batch for the current period. ; Step 5, extract the current training batch The feature vectors of the user samples, combined with the prototype parameter dictionary Construct a joint contrastive loss function that integrates instance-level and prototype-level comparisons. ; Step 6: Calculate the joint contrastive loss function. The gradient is used to update the feature extraction network using stochastic gradient descent. Parameters and prototype parameter dictionary ; Step 7: Utilize the reservoir sampling strategy, using the current training batch The memory cache is updated with new sample features. ; Step 8: Obtain the behavioral feature matrix of the user to be classified, extract its feature vectors and calculate the similarity with all known class prototypes, and output the user category with the highest probability.
[0007] Furthermore, the incrementally arriving user interaction behavior data stream obtained in step 1 is standardized and mapped to construct a two-dimensional matrix, which is then input into the initialized feature extraction network. Extracting feature vectors involves the following steps: Step 1.1: Capture the user's activity within the set time window. Sequence of historical interaction behaviors; Step 1.2, extract the data for each interaction. The feature dimensions include, but are not limited to, content dwell time and interaction type, and the dimensions are constructed as follows: initial characteristic matrix ; Step 1.3, for the initial feature matrix Each row is standardized so that its element values are mapped to... The intervals are used to form an abstract two-dimensional image with a single channel; Step 1.4: Use a Transformer network as the feature extraction network. Feature extraction is performed on the abstract two-dimensional image, and a fixed-length output is generated. 3D feature vector .
[0008] Furthermore, in step 5, the joint contrastive loss function at the instance level and the prototype level is fused. The calculation formula is defined as follows: in, For the contrastive loss based on samples and class prototypes, This is a supervised comparison loss based on similar samples and other samples. To balance the hyperparameter weights of the two loss constraints.
[0009] Furthermore, the contrastive loss based on samples and class prototypes described in step 5... The definition is, in, For training batches User samples and their category labels in the data. This is the set of indexes of user preference categories active in the current batch. The class prototype parameter corresponding to the actual preference category. For active categories The class prototype parameter, Represents cosine similarity. This is a scaling factor. The logarithm involved in this invention is assumed to be the logarithm with the natural constant as its base.
[0010] Furthermore, the supervised contrast loss based on similar samples described in step 5... The definition is, in, This indicates that the samples in this batch are similar to the anchor point samples. A set of positive samples with the same preference category The number of positive samples. Indicates that, except for the batch All other sample sets besides itself, The temperature coefficient used to adjust the smoothness.
[0011] Further, in step 6, the joint contrastive loss function is calculated. The gradient is used to update the feature extraction network using stochastic gradient descent. and class prototype parameter dictionary The mechanism is as follows: for indexes Corresponding inactive history class prototype parameters Its gradient partial derivative during backpropagation It will be strictly limited to zero; by blocking the gradient propagation of emerging categories to inactive historical categories, the classification boundary of the model on historical tasks is maintained.
[0012] Further, in step 8, the behavioral feature matrix of the user to be classified is obtained, its feature vector is extracted, and the similarity with all known cognitive class prototypes is calculated. The formula for outputting the user preference category with the highest probability is defined as follows: in, This represents user characteristics indicating unknown preference categories. It represents the set of all user categories that have been accumulated through continuous learning from the initial learning stage to the current stage.
[0013] A computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the continuous learning method for user preference classification based on prototype comparison as described above.
[0014] A computer-readable storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the steps of the continuous learning method for user preference classification based on prototype comparison as described above.
[0015] Compared with the prior art, the present invention has the following advantages: 1. This invention theoretically reduces the interference of gradient updates on the model, effectively mitigating the "catastrophic forgetting" problem. It innovatively proposes a mechanism to activate currently active category prototypes and dormant historical category prototypes. During gradient backpropagation, the partial derivatives of the gradients of inactive historical category prototypes are strictly limited to zero, mathematically isolating the gradient interference terms brought by new category knowledge and maintaining the model's classification boundaries on historical tasks.
[0016] 2. This invention overcomes the drawback of continuously growing cache capacity in traditional experience replay methods, ensuring computational overhead under fixed storage. Addressing the problem in existing technologies where extremely small memory caches lead to new categories dominating and historical target users being forgotten, this invention only requires maintaining a single memory cache of fixed capacity during the continuous learning phase, significantly reducing the storage and computational overhead of the actual system.
[0017] 3. A combined instance-level and prototype-level contrastive loss mechanism is employed to improve classification accuracy and stability. This method designs a dual contrastive loss mechanism, which not only narrows down the feature vectors of similar user preferences in the feature space through supervised contrastive loss between samples, but also strengthens the overall representational ability by calculating the contrastive loss between samples and class prototypes. This dual constraint enables the model to consider both the individual characteristics of new batches of users and extract historical category prototypes in streaming data, achieving accurate and stable user preference classification.
[0018] 4. It aligns well with streaming data application scenarios and has strong practical application value. This invention standardizes and maps discrete user behavior sequences into an abstract two-dimensional matrix, enabling them to be input into neural networks for high-dimensional feature extraction. This solution is applicable to real-world scenarios such as various e-commerce platforms, user data surveys, and online recommendation systems, especially for continuous classification tasks where user types dynamically change over time and with the external environment. Attached Figure Description
[0019] Figure 1 This is a flowchart illustrating the method workflow of an embodiment of the present invention; Figure 2 This is a flowchart illustrating the workflow of the core algorithm, joint contrastive loss, in an embodiment of the present invention. Detailed Implementation
[0020] The present invention will be further illustrated below with reference to specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading the present invention, any modifications of the present invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.
[0021] A continuous learning method for user preference classification based on prototype comparison is disclosed below, which will be described in detail with reference to the accompanying drawings and implementation examples.
[0022] Reference Figure 1 As shown, the method mainly includes the following steps: Step 1: Obtain user behavior data, standardize and map it into a two-dimensional matrix, and input it into the initialized feature extraction network. Extract feature vectors; simultaneously initialize class prototype parameter dictionaries representing various user types. ; Step 2: Construct a fixed-capacity memory cache. ; Step 3, in each online continuous learning cycle In the process, obtain new samples for the current batch and retrieve them from the memory cache. Extract historical samples; Step 4: Combine the old and new samples and perform data augmentation to construct the training batch for the current period. ; Step 5: Extract the feature vectors of the batch samples and combine them with the class prototype parameter dictionary. Constructing a joint contrastive loss function ; Step 6: Calculate the gradient of the joint contrastive loss function and update the feature extraction network. and prototype parameter dictionary ; Step 7: Update the memory cache using the reservoir sampling strategy. ; Step 8: Obtain the characteristics of the users to be classified and output the user category with the highest probability.
[0023] Specifically, we use a residual network (such as ResNet18) as the feature extraction network for this purpose. Used to extract high-dimensional feature vectors of users The acquired user data needs to include several user attribute characteristics. Prototype parameter dictionary. Includes all currently known systems A learnable parameter matrix for a specific user.
[0024] Step 1 involves acquiring the user interaction behavior data stream, standardizing and mapping it into a two-dimensional matrix, and extracting features. Specifically, this includes the following steps: Step 1.1: Capture the user's activity within the set time window. Sequence of historical interaction behaviors; Step 1.2, extract the data for each interaction. The feature dimensions include, but are not limited to, content dwell time and interaction type, and the dimensions are constructed as follows: initial characteristic matrix ; Step 1.3, for the initial feature matrix Each row is standardized so that its element values are mapped to... The intervals are used to form an abstract two-dimensional image with a single channel; Step 1.4: Input the matrix into the feature extraction network. In the middle, the output is of fixed length 2D continuous eigenvectors .
[0025] Specifically, since traditional image classification models cannot directly process raw, discrete user data, this method first establishes a mapping mechanism. This involves extracting recent user images... The sequential interaction behavior, extracting each behavior. Dimensional features (content dwell time, interaction type, etc.). Arrange these features in a time series to construct a... initial characteristic matrix Apply Z-score normalization to each row of the matrix to map its element values to... The intervals are used to form a single-channel, two-dimensional abstract image. Then, a feature extraction network is used. Here, we take ResNet18 as an example, and the final output dimension is... eigenvectors .
[0026] In steps 2 to 4, batches are constructed. The specific process is as follows: Specifically, initialize a storage limit in the server memory. Memory cache (e.g., 1024 unit sample capacity) Set the batch size for network training to [value]. In each round of continuous learning, the model acquires 16 new user samples from the real-time incremental data stream and simultaneously sends them to... Initiate a search to retrieve 16 historical samples. Then, concatenate the old and new samples and apply data augmentation strategies to assemble them into the current mixed training batch. .
[0027] In steps 5 and 6, a joint contrastive loss function is constructed. And update the parameters, the specific steps are as follows: Step 5.1, Scan the current training micro-batch Extract the set of active image category indices from all sample labels in the current batch. .
[0028] Step 5.2, using the formula Calculate the supervised comparison loss between samples within the batch and samples of the same type.
[0029] Step 5.3, from the class prototype parameter dictionary Extract only the active category index set The corresponding category prototype, using the formula Calculate the contrast loss between the sample and the class prototype.
[0030] Step 5.4: Obtain the joint contrastive loss function by weighted summation. Calculate the gradient and backpropagate to update the model.
[0031] Specifically, this is the core of the invention's ability to overcome "catastrophic forgetting." In computation... When setting temperature parameters, please refer to the settings. This brings together user groups with similar preference types within the feature dimension. In the calculation... At that time, due to the exponential summation term in the denominator of its Softmax cross-entropy... Only in the active set Internally, historical categories that are currently unrelated to the current batch will remain dormant. Because dormant class prototypes do not participate in the denominator of the forward calculation, their gradient partial derivatives are equal to 0 during backpropagation (i.e., ...). This mechanism completely eliminates gradient interference from new knowledge at the mathematical level, ensuring that historical class prototypes are updated as little as possible during long-term continuous learning.
[0032] In steps 7 and 8, the specific steps for updating the cache and making predictions are as follows: Step 7.1: Using the flow-through reservoir sampling algorithm, the current micro-batch... New category sample features are written to the memory cache in a probability decay manner. .
[0033] Step 8.1: Obtain the two-dimensional matrix of users to be classified and output the feature vector. .
[0034] Step 8.2, using the formula calculate Output the user category corresponding to the highest cosine similarity with all known class prototypes. .
[0035] Specifically, reservoir sampling ensures that regardless of the length of the data stream, each historical category learned in the past is retained in the cache with approximately equal probability. During the inference phase, the system obtains the user's latest behavior in real time, compares it with all class prototypes accumulated from the initial stage to the present, and uses the argmax function to find the optimal user preference category.
[0036] It is obvious to those skilled in the art that the steps of the prototype-based comparative continuous learning method for user preference classification described in the above embodiments of the present invention can be implemented using general-purpose computing devices. They can be centralized on a single computing device or distributed across a network of multiple computing devices. Optionally, they can be implemented using device-executable program code, which can then be stored in a storage device for execution by a computing device. Furthermore, in some cases, the steps shown or described can be performed in a different order than presented herein, or they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. Thus, the embodiments of the present invention are not limited to any particular hardware and software combination.
Claims
1. A continuous learning method for user preference classification based on prototype comparison, characterized in that, Includes the following steps: Step 1: Acquire the user interaction behavior data stream arriving incrementally, perform standardized mapping processing on it, construct a two-dimensional matrix, and input it into the initialized feature extraction network. Extract feature vectors; simultaneously initialize prototype parameter dictionaries representing various user preference types. ; Step 2: Construct a fixed-capacity memory cache. It is used to store representative sample features and corresponding categories in historical user categories; Step 3, in each online continuous learning cycle In the process, new user samples with different preferences appearing in the current batch are obtained, and a retrieval strategy is used to retrieve them from the memory cache. The search results represent a sample of users with historical preferences. Step 4: Concatenate and mix the new preference user samples with the historical preference user samples and perform data augmentation to construct the actual training batch for the current period. ; Step 5, extract the current training batch The feature vectors of the user samples, combined with the prototype parameter dictionary Construct a joint contrastive loss function that integrates instance-level and prototype-level comparisons. ; Step 6: Calculate the joint contrastive loss function. The gradient is used to update the feature extraction network using stochastic gradient descent. Parameters and prototype parameter dictionary ; Step 7: Utilize the reservoir sampling strategy, using the current training batch The memory cache is updated with new sample features. ; Step 8: Obtain the behavioral feature matrix of the user to be classified, extract its feature vectors and calculate the similarity with all known class prototypes, and output the user category with the highest probability.
2. The continuous learning method for user preference classification based on prototype comparison according to claim 1, characterized in that, In step 1, the incrementally arriving user interaction behavior data stream is acquired, standardized and mapped to construct a two-dimensional matrix, and then input into the initialized feature extraction network. Extracting feature vectors involves the following steps: Step 1.1: Capture the user's activity within the set time window. Sequence of historical interaction behaviors; Step 1.2, extract the data for each interaction. The feature dimensions include, but are not limited to, content dwell time and interaction type, and the dimensions are constructed as follows: initial characteristic matrix ; Step 1.3, for the initial feature matrix Each row is standardized so that its element values are mapped to... The intervals are used to form an abstract two-dimensional image with a single channel; Step 1.4: Use a Transformer network as the feature extraction network. Feature extraction is performed on the abstract two-dimensional image, and a fixed-length output is generated. 3D feature vector .
3. The continuous learning method for user preference classification based on prototype comparison according to claim 1, characterized in that, In step 5, the joint contrastive loss function at the instance level and the prototype level is fused. The calculation formula is defined as follows: in, For the contrastive loss based on samples and class prototypes, This is a supervised comparison loss based on similar samples and other samples. To balance the hyperparameter weights of the two loss constraints.
4. The continuous learning method for user preference classification based on prototype comparison according to claim 3, characterized in that, The contrast loss based on samples and class prototypes described in step 5 The definition is, in, For training batches User samples and their category labels in the data. This is the set of indexes of user preference categories active in the current batch. The class prototype parameter corresponding to the actual preference category. For active categories The class prototype parameter, Represents cosine similarity. This is the scaling factor.
5. The continuous learning method for user preference classification based on prototype comparison according to claim 3, characterized in that, The supervised contrast loss based on similar samples described in step 5 The definition is, in, This indicates that the samples in this batch are similar to the anchor point samples. A set of positive samples with the same preference category The number of positive samples. Indicates that, except for the batch All other sample sets besides itself, The temperature coefficient used to adjust the smoothness.
6. The continuous learning method for user preference classification based on prototype comparison according to claim 1, characterized in that, The joint contrastive loss function is calculated in step 6. The gradient is used to update the feature extraction network using stochastic gradient descent. and class prototype parameter dictionary The mechanism is as follows: for indexes The inactive historical prototype, its gradient partial derivative during backpropagation. It will be strictly limited to zero; by blocking the gradient propagation of emerging categories to inactive historical categories, the classification boundary of the model on historical tasks is maintained.
7. The continuous learning method for user preference classification based on prototype comparison according to claim 1, characterized in that, In step 8, the behavioral feature matrix of the user to be classified is obtained, its feature vector is extracted, and the similarity with all known cognitive class prototypes is calculated. The formula for outputting the user preference category with the highest probability is defined as follows: in, This represents user characteristics indicating unknown preference categories. It represents the set of all user categories that have been accumulated through continuous learning from the initial learning stage to the current stage.
8. A computer device, characterized in that: The computer device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the steps of the continuous learning method for user preference classification based on prototype comparison as described in any one of claims 1-7.
9. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that: When the computer program / instructions are executed by the processor, they implement the steps of the continuous learning method for user preference classification based on prototype comparison as described in any one of claims 1-5.