A diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting

By comparing the diffusion model sequence recommendation method with long tail reweighting, the problem of guiding vector homogeneity and static fusion mechanism is solved, the model's ability to capture user interests and identify long tail items is improved, and the recommendation effect of personalization and diversity is achieved.

CN120372100BActive Publication Date: 2025-08-19SOUTHWEST PETROLEUM UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510890599.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-08-19
Estimated Expiration
2045-06-30

AI Technical Summary

Technical Problem

The existing diffusion model fails to fully consider the semantic representation differences between popular items and non-popular items in the process of constructing guidance vectors, resulting in homogeneity of guidance vectors, which damages the personalization ability of recommendations, and the static fusion mechanism is difficult to dynamically adjust the representation weight, affecting the model's capture of user interests and the identification of long-tail items.

Method used

The diffusion model sequence recommendation method based on contrast learning and long-tail reweighting is adopted. The semantic vector codebook is updated by calculating the counter-population weight, and combined with dynamic fusion and noise addition processing, the diffusion model is optimized to improve the model's capture ability of user interests and the recognition of long-tail items.

Benefits of technology

It enhances the model's ability to capture user interests and the accuracy of generating recommendations, improves the identification and coverage of long-tail items, and is suitable for sequence recommendation scenarios that emphasize personalization, diversity and interpretability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120372100B_ABST
    Figure CN120372100B_ABST
Patent Text Reader

Abstract

The present invention discloses a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting, which relates to the field of data processing technology. The method includes: obtaining a semantic vector codebook and an inverse popularity weight of each item based on historical item interaction data, and updating the semantic vector codebook based on the inverse popularity weight; calculating the contrastive learning loss based on the updated semantic vector codebook; for each sample, dynamically fusing the semantic vector corresponding to the sample, performing noise processing on the target item information, and using the dynamic fusion result and the noise processing result as the input of the diffusion model, obtaining the reconstruction loss based on the target item information and the model output, and optimizing the diffusion model based on the contrastive learning loss and the reconstruction loss; using the trained diffusion model to perform item prediction, and obtaining recommended items based on the item prediction results. This method can improve the model's ability to capture user interests and the accuracy of generating recommendations, as well as enhance the recognition and coverage of long-tail items.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting. Background Art

[0002] With the rapid development of information technology, recommendation systems are widely used in e-commerce, video, social networking and other platforms, improving user experience and platform revenue. Sequential recommendation, as an important branch of recommendation systems, aims to predict users' next behavior based on their historical interaction sequences. Traditional methods, such as models based on recurrent neural networks (RNNs) or Transformers, can learn sequential dependencies, but have limitations in modeling the uncertainty of user interests. In recent years, generative recommendation models have gradually attracted attention, and frameworks such as generative adversarial networks (GANs) and variational autoencoders (VAEs) have been used to enhance the diversity and generalization of recommendation results. However, such methods often face problems such as unstable training or insufficient latent space expression capabilities.

[0003] To address the above issues, researchers introduced the diffusion model (DM) for sequential recommendation. This type of method enhances the modeling ability of user interest distribution by gradually adding noise and reverse denoising to the target item representation. Representative works include DreamRec and DiffuRec. These methods usually rely on constructing a "guidance vector" to assist the diffusion process, so that the generated results are more in line with user preferences. However, there are two common problems in existing work: First, the difference in the impact of popular and non-popular items on semantic representation is not fully considered in the process of constructing the guidance vector, which easily leads to the homogenization of the guidance vector and thus damages the personalized recommendation ability. Second, current models mostly use a static fusion mechanism, which makes it difficult to dynamically adjust the representation weights according to the interests of different users. Summary of the Invention

[0004] The present invention aims to solve at least one of the technical problems in the related art to a certain extent; to this end, the purpose of the present invention is to propose a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting, to improve the model's ability to capture user interests and the accuracy of generating recommendations, and to enhance the recognition and coverage of long-tail items.

[0005] To achieve the above objectives, an embodiment of the present invention proposes a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting, including: obtaining a semantic vector codebook and an inverse popularity weight of each item based on historical item interaction data, and updating the semantic vector codebook based on the inverse popularity weight; calculating the contrastive learning loss based on the updated semantic vector codebook; for each sample in the historical item interaction data, dynamically fusing the sample and its corresponding semantic vector in the updated semantic vector codebook, performing noise processing on the target item information corresponding to the sample, and using the dynamic fusion result and the noise processing result as the input of the diffusion model, obtaining a reconstruction loss based on the target item information and the output of the diffusion model, and optimizing the diffusion model based on the contrastive learning loss and the reconstruction loss; using the trained diffusion model to predict items, and obtaining recommended items based on the item prediction results.

[0006] The embodiment of the present invention provides a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting. First, the diffusion model is trained, including: obtaining a semantic vector codebook and an inverse popularity weight of each item based on historical item interaction data, and updating the semantic vector codebook based on the inverse popularity weight; calculating the contrastive learning loss based on the updated semantic vector codebook; for each sample in the historical item interaction data, dynamically fusing the sample and its corresponding semantic vector in the updated semantic vector codebook, performing noise processing on the target item information corresponding to the sample, and using the dynamic fusion result and the noise processing result as the input of the diffusion model. According to the target item information and The output of the diffusion model is used to obtain the reconstruction loss, and the diffusion model is optimized based on the contrastive learning loss and the reconstruction loss. Then, the trained diffusion model is used to predict items, and recommended items are obtained based on the prediction results. This method introduces personalized semantic quantization and long-tail reweighting (i.e., inverse popularity weighting), which not only improves the model's ability to capture user interests and the accuracy of generating recommendations, but also enhances the recognition and coverage of long-tail items. It is suitable for various sequential recommendation scenarios that emphasize personalization, diversity, and interpretability. At the same time, by dynamically fusing samples and semantic vectors, the reconstructed target item encoding can be more in line with the user's real interest preferences.

[0007] In addition, the diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting in the embodiment of the present invention may also have the following additional technical features:

[0008] According to one embodiment of the present invention, obtaining a semantic vector codebook based on historical item interaction data includes: mapping the historical item interaction data to a semantic vector clustering space through a multi-layer perceptron model, initializing each semantic vector clustering center using the Gumbel-Softmax method, and forming the semantic vector codebook from the semantic vectors corresponding to each of the semantic vector clustering centers.

[0009] According to one embodiment of the present invention, the semantic vector codebook is updated by the following formula:

[0010]

[0011]

[0012]

[0013] in, Represents the target semantic vector codebook The semantic vectors of semantic cluster centers, Indicates the historical item interaction data Sample codes, Represents The corresponding inverse popularity weight vector, Indicates that the cluster label in the historical item interaction data is The set of all samples of express The number of samples in Indicates items popularity, Indicates items The number of interactions, and Respectively represent the maximum and minimum number of interactions of all items, Indicates items The inverse popularity weight of .

[0014] According to one embodiment of the present invention, the contrastive learning loss is obtained by the following formula:

[0015]

[0016] in, represents the contrastive learning loss, Indicates the historical item interaction data Sample codes, Represents The set of samples belonging to the same cluster, Represents Positive sample encoding belonging to the same cluster, Represents Negative sample encoding that does not belong to the same cluster, represents the cosine similarity function, represents the temperature hyperparameter, represents the natural exponential function, represents the mathematical expectation.

[0017] According to one embodiment of the present invention, the dynamic fusion result is obtained by the following formula:

[0018]

[0019] in, represents the gating weight vector, represents the sample code, represents the linear rectification function, represents the dynamic fusion result, express The corresponding semantic vector, Represents Hadamard multiplication.

[0020] According to one embodiment of the present invention, the noise addition result is obtained by the following formula:

[0021]

[0022] in, represents the noise addition result, represents the diffusion time step, Indicates the target item information, Indicates in The cumulative noise attenuation factor of the step, represents the standard normally distributed noise, Indicates the maximum time step.

[0023] According to one embodiment of the present invention, the reconstruction loss is obtained by the following formula:

[0024]

[0025] in, represents the reconstruction loss, Indicates the target item information, represents the output of the diffusion model, represents the squared Euclidean distance, represents the diffusion model, represents the noise addition result, represents the dynamic fusion result, represents the diffusion time step, represents the mathematical expectation.

[0026] According to one embodiment of the present invention, the optimizing the diffusion model based on the contrastive learning loss and the reconstruction loss includes:

[0027] The final loss is obtained by the following formula:

[0028]

[0029] in, represents the final loss, represents the contrastive learning loss coefficient, represents the contrastive learning loss, represents the reconstruction loss;

[0030] The diffusion model is optimized based on the final loss.

[0031] According to one embodiment of the present invention, the item prediction result is obtained by the following formula:

[0032]

[0033] in, hour, ; Indicates in The reconstruction code of step Step reconstruction coding Indicates the prediction result of the item; Indicates the The diffuse noise coefficient of the step, , Indicates the The posterior noise variance of the step, represents the standard normally distributed noise, Indicates in The cumulative noise attenuation factor of the step.

[0034] According to an embodiment of the present invention, obtaining recommended items based on the item prediction results includes: calculating an inner product between the item prediction results and candidate item information, and sorting the inner product results to obtain an item recommendation list.

[0035] Additional aspects and advantages of the present invention will be set forth in part in the description which follows and, in part, will be obvious from the description which follows, or may be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 This is a flowchart of a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to an embodiment of the present invention;

[0037] Figure 2 A schematic diagram of obtaining a semantic vector codebook using a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to an embodiment of the present invention;

[0038] Figure 3 This is a flowchart of calculating the final loss of a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to one embodiment of the present invention;

[0039] Figure 4 A flowchart of a sequential recommendation method for a diffusion model based on contrastive learning and long-tail reweighting to generate a recommendation list according to an embodiment of the present invention;

[0040] Figure 5 This figure shows the experimental results of comparing a sequence recommendation method based on contrastive learning and long-tail reweighted diffusion model according to an embodiment of the present invention with existing methods on the Amazon Toys dataset.

[0041] Figure 6 This figure shows the experimental results of comparing a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to an embodiment of the present invention with existing methods on the Steam dataset. DETAILED DESCRIPTION

[0042] The embodiments of the present invention are described in detail below. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements with the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present invention, but should not be understood as limiting the present invention.

[0043] A diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to an embodiment of the present invention will be described below with reference to the accompanying drawings.

[0044] To address the problems of existing recommendation methods, such as the single semantic expression of guidance vectors, popular items dominating cluster centers, and the rigid fusion mechanism of target item encoding and semantic vectors, this paper proposes a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting. This method can enhance the modeling accuracy of the recommendation system for user interests and the personalized recommendation effect.

[0045] Figure 1 This is a flowchart of a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting according to an embodiment of the present invention.

[0046] like Figure 1 As shown in FIG, a diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting includes:

[0047] S1: Obtain the semantic vector codebook and the inverse popularity weight of each item based on historical item interaction data, and update the semantic vector codebook based on the inverse popularity weight.

[0048] Among them, historical item interaction data may include user data, item data and interaction data between user items. Historical item interaction data can be used in the form of a time series, representing the item interaction records (such as clicks, browsing, purchases, etc.) that occurred during a certain historical time window, and arranged in chronological order.

[0049] S2, calculates the contrastive learning loss based on the updated semantic vector codebook.

[0050] S3: For each sample in the historical item interaction data, the sample and its corresponding semantic vector in the updated semantic vector codebook are dynamically fused, the target item information corresponding to the sample is noised, and the dynamic fusion results and the noised results are used as the input of the diffusion model. The reconstruction loss is obtained based on the target item information and the output of the diffusion model, and the diffusion model is optimized based on the contrastive learning loss and the reconstruction loss.

[0051] Among them, the target item represents the next potential item of interest that needs to be predicted, which can be obtained based on historical item interaction data; for example, the items that the user actually interacts with (such as purchase records, products with a rating of ≥ 4 stars) are marked as target items; for example, for fuzzy behaviors such as clicking and browsing, behavioral weights are set, such as giving a basic weight (such as weight = 1) to click behaviors, and giving a higher weight (such as weight = 5) to high-value behaviors such as purchases and collections. Combined with the time decay factor (such as doubling the weight of behaviors in the last 7 days), the user's behavioral weights on the items are accumulated, and the item with the largest value is marked as the target item.

[0052] S4, use the trained diffusion model to predict items and obtain recommended items based on the item prediction results.

[0053] Specifically, steps S1 to S3 are the training steps for the diffusion model, and step S4 is the use step for the trained diffusion model. By introducing personalized semantic quantization and long-tail reweighting (i.e., inverse popularity weighting), this method not only improves the model's ability to capture user interests and the accuracy of generating recommendations, but also enhances the recognition and coverage of long-tail items. It is suitable for various sequential recommendation scenarios that emphasize personalization, diversity, and interpretability. At the same time, by dynamically fusing samples and semantic vectors, the reconstructed target item encoding can be made more consistent with the user's true interest preferences.

[0054] In an embodiment of the present invention, for ease of processing, each sample in the historical item interaction data and the target item information corresponding to each sample may be encoded.

[0055] Specifically, the historical item interaction data of a training batch includes samples and The target items correspond to each sample one by one. The set of samples is recorded as ,in and Different, this A sample can be A user's historical interaction sequence; a user's historical interaction sequence , the unique ID of each item in the sample can be mapped to obtain the historical interaction sequence code At the same time, the unique identifier (ID) of the target item corresponding to the sample is mapped to the target item code , as the target item information.

[0056] In some embodiments of the present invention, a semantic vector codebook is obtained based on historical item interaction data, including: mapping the historical item interaction data to a semantic vector clustering space through a multi-layer perceptron model, initializing each semantic vector cluster center using the Gumbel-Softmax method, and forming a semantic vector codebook from the semantic vectors corresponding to each semantic vector cluster center.

[0057] Specifically, if Figure 2 As shown, the historical item interaction data of each training batch adopts the historical interaction sequence encoding set ( Figure 2 To include As shown in the form of an example, the historical interaction sequence encoding set is mapped to the semantic vector clustering space through a multi-layer (such as 3-layer) fully connected network (including ReLU activation) of the multi-layer perceptron model, aggregated into K classes (or clusters), and the output dimension is d; Gumbel-Softmax is used to initialize K cluster centers, each center is a d-dimensional vector; the semantic vectors corresponding to the cluster centers are stored through a learnable codebook. The multiple semantic vectors ( Figure 2 Taking K=3 as an example) to form a semantic vector codebook (including semantic vector ); see Figure 2 , The semantic vector of the cluster center of the cluster is , The semantic vector of the cluster center of the cluster is , The semantic vector of the cluster center of the cluster is .

[0058] By encoding historical interaction sequences into dense vectors through a multi-layer perceptron model, it is possible to capture high-order interest features through nonlinear transformations; by initializing cluster centers through Gumbel-Softmax, it is possible to ensure the compatibility of discrete clustering and gradient propagation through differentiable sampling, avoiding the non-differentiable problem of traditional K-means; by storing cluster center vectors (i.e., semantic vectors) in a codebook, it is possible to quickly match user interests through nearest neighbor search and reduce the computational complexity of large-scale item libraries; different cluster centers correspond to differentiated semantics (such as "sports equipment" and "beauty"), which enhances interpretability.

[0059] In some embodiments of the present invention, the semantic vector codebook is updated by the following formula:

[0060]

[0061]

[0062]

[0063] in, Represents the target semantic vector codebook The semantic vectors of semantic cluster centers, Indicates the historical item interaction data Sample codes, Represents The corresponding inverse popularity weight vector, Indicates that the cluster label in the historical item interaction data is The set of all samples of express The number of samples in , Indicates items popularity, Indicates items The number of interactions, and Respectively represent the maximum and minimum number of interactions of all items, Indicates items The inverse popularity weight of .

[0064] Specifically, for each training batch, while obtaining the semantic vector codebook, the normalized popularity of the item is calculated based on the frequency of user interaction, and the inverse popularity weight of the item is calculated based on the popularity of the item; for a user's historical interaction sequence , each item There is a corresponding inverse popularity weight , so the inverse popularity weights corresponding to all items in the historical interaction sequence can be expressed as a vector ,in ; Afterwards, the semantic vector of the semantic vector cluster center is updated according to the inverse popularity weight, thereby updating the semantic vector codebook; thus, by introducing personalized semantic quantization and long-tail reweighting (i.e., inverse popularity weighting), the popularity bias and long-tail effect can be alleviated, which not only improves the model's ability to capture user interests and the accuracy of generating recommendations, but also enhances the recognition and coverage of long-tail items.

[0065] In some embodiments of the present invention, the contrastive learning loss is obtained by the following formula:

[0066]

[0067] in, represents the contrastive learning loss, Indicates the historical item interaction data Sample codes, Represents The set of samples belonging to the same cluster, Represents Positive sample encoding belonging to the same cluster, Represents Negative sample encoding that does not belong to the same cluster, represents the cosine similarity function, represents the temperature hyperparameter, represents the natural exponential function, represents the mathematical expectation.

[0068] By introducing contrastive learning loss to train the diffusion model, the robustness, diversity and semantic alignment ability of the diffusion model can be improved.

[0069] In some embodiments of the present invention, the dynamic fusion result is obtained by the following formula:

[0070]

[0071] in, represents the gating weight vector, represents the sample code, represents the linear rectification function, represents the dynamic fusion result, express The corresponding semantic vector, Represents Hadamard multiplication.

[0072] Specifically, the position information in the historical interaction sequence encoding is extracted through the Rectified Linear Unit (ReLU) function to obtain the gating weight vector; then, the historical interaction sequence encoding is fused with the semantic vector based on the gating weight vector through Hadamard multiplication to generate the guidance encoding (i.e., the dynamic fusion result); lightweight gating is used to achieve the fusion of "position sensitivity" and "semantic vector adaptation", which can accelerate the processing speed of the diffusion model and improve the recommendation rate of long-tail items.

[0073] In some embodiments of the present invention, the noise addition result is obtained by the following formula:

[0074]

[0075] in, represents the noise addition result, represents the diffusion time step, Indicates the target item information, Indicates in The cumulative noise attenuation factor of the step, represents the standard normally distributed noise, Indicates the maximum time step; the above noise addition process is forward noise addition.

[0076] In some embodiments of the present invention, the reconstruction loss is given by:

[0077]

[0078] in, represents the reconstruction loss, Indicates the target item information, represents the output of the diffusion model, represents the squared Euclidean distance, represents the diffusion model, represents the noise addition result, represents the dynamic fusion result, represents the diffusion time step, represents the mathematical expectation.

[0079] For example, in the reverse reconstruction stage, a Transformer model can be used as a generator of the diffusion model to reconstruct the target item code.

[0080] In some embodiments of the present invention, when optimizing the diffusion model based on the contrastive learning loss and the reconstruction loss, the final loss is obtained by the following formula:

[0081]

[0082] in, represents the final loss, represents the contrastive learning loss coefficient, represents the contrastive learning loss, represents the reconstruction loss.

[0083] Afterwards, the diffusion model is optimized based on the final loss; at the same time, the encoding method of the items can also be optimized, that is, the items Encoded as way.

[0084] In a specific implementation of the present invention, the training process of the recommendation model is as follows Figure 3 As shown in the figure, first, the interaction data between users and items is obtained as historical item interaction data, and the historical interaction sequence is obtained as a training sample based on the historical item interaction data, and the target item corresponding to each sample is used as a label. Then, the historical interaction sequence and the target item are encoded respectively to obtain the historical interaction sequence code and the target item code; then, based on the historical interaction sequence code set, the semantic vector cluster center is initialized, the item popularity is calculated, the inverse popularity weight is calculated, and the semantic vector of the cluster center is updated. The gating weight is calculated for each historical interaction sequence code, and the guidance code is generated based on the gating weight and the updated speech vector, and noise is added to the target item code corresponding to each historical interaction sequence code; then, the contrastive learning loss is calculated based on the updated semantic vector, and the noise processing result and the guidance code are input into the Transformer model to remove the noise, and the reconstruction loss is calculated based on the denoising result and the target item code; finally, the final loss is calculated based on the contrastive learning loss and the reconstruction loss, and the final loss is used to optimize the Transformer model.

[0085] It should be noted that for each training batch, a contrastive learning loss is calculated based on the set of historical interaction sequence encodings, and a reconstruction loss is calculated based on each historical interaction sequence encoding in the set; each reconstruction loss is calculated together with the contrastive learning loss to calculate the final loss for optimizing the Transformer model.

[0086] In some embodiments of the present invention, the item prediction result is obtained by the following formula:

[0087]

[0088] in, hour, ; Indicates in The reconstruction code of step Step reconstruction coding Indicates the prediction result of the item; Indicates the The diffuse noise coefficient of the step, , Indicates the The posterior noise variance of the step, represents the standard normally distributed noise, Indicates in The cumulative noise attenuation factor of the step.

[0089] After obtaining the trained diffusion model, in the inference phase, the interaction data of the item to be predicted (which may include item interaction data of multiple users to be recommended) and Gaussian noise are used as input. The diffusion model starts from the Gaussian noise and reconstructs the encoding of the target item through step-by-step reverse sampling using the above formula.

[0090] In some embodiments of the present invention, obtaining recommended items based on item prediction results includes: calculating an inner product between the item prediction results and candidate item information, and sorting the items based on the inner product results to obtain an item recommendation list.

[0091] Among them, candidate items can be obtained based on a preset item set and interaction data of items to be predicted. Specifically, for each user to be recommended, the candidate items are the remaining items in the preset item set after removing the items involved in the item interaction data of the user to be recommended; for example, the preset item set includes 10 items, which are respectively recorded as items 1 to 10, and the items involved in the item interaction data of the user to be recommended include items 1, 2, 4, 5, and 7 to 10, then the candidate items include items 3 and 6; the candidate item information can refer to the encoding of the candidate items.

[0092] For example, if the remaining items in the preset item set after excluding the items involved in the item interaction data of the user to be recommended are empty, then the items with fewer interactions in the item interaction data of the user to be recommended can be taken as candidate items. For example, the top three items with the highest number of interactions can be taken as candidate items.

[0093] Optionally, candidate items may also be directly obtained based on the interaction data of the items to be predicted. For example, for each user to be recommended, all items involved in the item interaction data of the user to be recommended may be used as candidate items.

[0094] In a specific implementation of the present invention, the use process of the recommendation model is as follows Figure 4As shown in the figure, first, the interaction data between users and items is obtained as the interaction data of the items to be predicted, and the historical interaction sequence is obtained based on the interaction data of the items to be predicted. The historical interaction sequence is encoded to obtain the historical interaction sequence code; then, based on the historical interaction sequence code set, the semantic vector cluster center is initialized, the item popularity is calculated, the inverse popularity weight is calculated, and the semantic vector of the cluster center is updated. The gating weight is calculated for each historical interaction sequence code, and the guidance code is generated based on the gating weight and the updated speech vector; then, the Gaussian noise and the guidance code are input into the trained Transformer model to remove the noise, and the item recommendation list for each user to be recommended is obtained based on the denoising result and the candidate item code.

[0095] To illustrate the recommendation effect of the diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting in this embodiment, this embodiment conducts experiments on two public datasets.

[0096] The two datasets are the Amazon Toys dataset and the Steam dataset. The experiment achieves the following: predict the corresponding target item code based on the user's historical interaction sequence, calculate the inner product of the candidate item code and the target item code, and select the top k items from the largest to the smallest according to the inner product result to form a recommendation list.

[0097] The existing sequence recommendation methods compared with the method in this embodiment (CLeaRDiff) include: GRU4Rec, SASRec, BERT4Rec, DreamRec and DiffuRec; the evaluation indicators used in this embodiment are hit ratio (HR) and normalized discounted cumulative gain (NDCG), and experiments are conducted with different k settings. The results are as follows: Figure 5 、 Figure 6 shown.

[0098] Figure 5 、 Figure 6 HR@5, HR@10, and HR@20 are the hit rates (HR) when the number of items k recommended to the user is 5, 10, and 20, respectively; NDCG@5, NDCG@10, and NDCG@20 are the normalized discounted cumulative gains (NDCG) when the number of items k recommended to the user is 5, 10, and 20, respectively; see Figure 5 、 Figure 6 It can be seen that the method in this embodiment (CLeaRDiff) outperforms the existing sequence recommendation methods in HR@5, HR@10, HR@20, NDCG@5, NDCG@10 and NDCG@20.

[0099] It can be seen that this embodiment constructs a diffusion recommendation framework that integrates contrastive learning and long-tail reweighting mechanism, first introduces a semantic vector codebook to semantically quantify the user's historical interaction sequence, and then uses contrastive learning to enhance the discrimination between each semantic vector in the semantic vector codebook, and integrates the historical interaction sequence encoding and the semantic vector through a dynamic gating mechanism to obtain guided encoding, so that the reconstructed target item encoding is more in line with the user's real interest preferences. It not only improves the model's ability to capture user interests and the accuracy of generating recommendations, but also enhances the recognition and coverage of long-tail items. It is suitable for various sequence recommendation scenarios that emphasize personalization, diversity and explainability.

[0100] In summary, the diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting in the embodiment of the present invention solves the semantic homogeneity problem caused by the dominance of popular items in guidance coding by reweighting long-tail items, thereby enhancing the modeling ability of long-tail interests; by combining contrastive learning to enhance the discriminability of semantic vectors, the personalized effect of user interest modeling is further improved; by introducing a dynamic semantic fusion mechanism, it can adaptively fuse historical interaction sequence coding and semantic vectors, thereby enhancing the model's expressive power and recommendation flexibility.

[0101] It should be noted that the logic and / or steps represented in the flowcharts or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processor, or other system that can fetch instructions from and execute instructions on an instruction execution system, apparatus, or device), or for use in conjunction with such instruction execution systems, apparatuses, or devices; for the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transmit a program for use by an instruction execution system, apparatus, or device, or in conjunction with such instruction execution systems, apparatuses, or devices; More specific examples (a non-exhaustive list) of computer-readable media include the following: an electrical connection having one or more wires (electronic devices), a portable computer disk cartridge (magnetic devices), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disc read-only memory (CDROM); in addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or, if necessary, processing it in another suitable manner, and then storing it in a computer memory.

[0102] It should be understood that various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof; in the above-mentioned embodiment, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system; for example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logical function on a data signal, a dedicated integrated circuit having a suitable combinational logic gate circuit, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0103] In the description of this specification, reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention; in this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example; moreover, the specific features, structures, materials or characteristics described may be combined in an appropriate manner in any one or more embodiments or examples.

[0104] In the description of the present invention, it should be understood that the terms "center", "longitudinal", "lateral", "length", "width", "thickness", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", "clockwise", "counterclockwise", "axial", "radial", "circumferential" and the like to indicate orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore should not be understood as limiting the present invention.

[0105] In addition, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance or implicitly indicating the number of the indicated technical features; thus, the features defined as "first" and "second" may explicitly or implicitly include at least one such feature; in the description of the present invention, the meaning of "multiple" is at least two, for example two, three, etc., unless otherwise clearly and specifically defined.

[0106] In the present invention, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly specified; for ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to the specific circumstances.

[0107] In the present invention, unless otherwise clearly stipulated and limited, a first feature being "above" or "below" a second feature may mean that the first and second features are in direct contact, or that the first and second features are in indirect contact through an intermediate medium; furthermore, a first feature being "above", "above" or "above" the second feature may mean that the first feature is directly above or obliquely above the second feature, or simply means that the first feature is at a higher level than the second feature; a first feature being "below", "below" or "below" the second feature may mean that the first feature is directly below or obliquely below the second feature, or simply means that the first feature is at a lower level than the second feature.

[0108] Although the embodiments of the present invention have been shown and described above, it will be understood that the above embodiments are illustrative and are not to be construed as limitations on the present invention. A person skilled in the art may change, modify, replace and modify the above embodiments within the scope of the present invention.

Claims

1. A diffusion model sequence recommendation method based on contrastive learning and long-tail reweighting, characterized in that: include: Obtaining a semantic vector codebook and an inverse popularity weight of each item based on historical item interaction data, and updating the semantic vector codebook based on the inverse popularity weight; Compute contrastive learning loss based on the updated semantic vector codebook; For each sample in the historical item interaction data, dynamically fuse the sample and its corresponding semantic vector in the updated semantic vector codebook, perform noise processing on the target item information corresponding to the sample, and use the dynamic fusion result and the noise processing result as inputs of a diffusion model, obtain a reconstruction loss based on the target item information and the output of the diffusion model, and optimize the diffusion model based on the contrastive learning loss and the reconstruction loss; The trained diffusion model is used to perform item prediction, and recommended items are obtained based on the item prediction results.

2. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The step of obtaining a semantic vector codebook based on historical item interaction data includes: The historical item interaction data is mapped to a semantic vector clustering space through a multi-layer perceptron model, and each semantic vector cluster center is initialized using the Gumbel-Softmax method, and the semantic vectors corresponding to each semantic vector cluster center are combined into the semantic vector codebook.

3. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The semantic vector codebook is updated by the following formula: in, Represents the target semantic vector in the codebook The semantic vectors of semantic cluster centers, Indicates the historical item interaction data Sample codes, Represents The corresponding inverse popularity weight vector, Indicates that the cluster label in the historical item interaction data is The set of all samples of express The number of samples in , Indicates items popularity, Indicates items The number of interactions, and Respectively represent the maximum and minimum number of interactions of all items, Indicates items The inverse popularity weight of .

4. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The contrastive learning loss is obtained by the following formula: in, represents the contrastive learning loss, Indicates the historical item interaction data Sample codes, Represents The set of samples belonging to the same cluster, Represents Positive sample encoding belonging to the same cluster, Represents Negative sample encoding that does not belong to the same cluster, represents the cosine similarity function, represents the temperature hyperparameter, represents the natural exponential function, represents the mathematical expectation.

5. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The dynamic fusion result is obtained by the following formula: in, represents the gating weight vector, represents the sample code, represents the linear rectification function, represents the dynamic fusion result, express The corresponding semantic vector, Represents Hadamard multiplication.

6. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The noise addition result is obtained by the following formula: in, represents the noise addition result, represents the diffusion time step, Indicates the target item information, Indicates in The cumulative noise attenuation factor of the step, represents the standard normally distributed noise, Indicates the maximum time step.

7. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The reconstruction loss is obtained as follows: in, represents the reconstruction loss, Indicates the target item information, represents the output of the diffusion model, represents the squared Euclidean distance, represents the diffusion model, represents the noise addition result, represents the dynamic fusion result, represents the diffusion time step, represents the mathematical expectation.

8. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: Optimizing the diffusion model based on the contrastive learning loss and the reconstruction loss includes: The final loss is obtained by the following formula: in, represents the final loss, represents the contrastive learning loss coefficient, represents the contrastive learning loss, represents the reconstruction loss; The diffusion model is optimized based on the final loss.

9. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 1, characterized in that: The item prediction result is obtained by the following formula: in, hour, ; Indicates in The reconstruction code of step Step reconstruction coding Indicates the prediction result of the item; Indicates the The diffuse noise coefficient of the step, , Indicates the The posterior noise variance of the step, represents the standard normally distributed noise, Indicates in The cumulative noise attenuation factor of the step.

10. The method for sequential recommendation based on contrastive learning and long-tail reweighted diffusion model according to claim 9, characterized in that: Obtaining recommended items based on item prediction results includes: The inner product of the item prediction result and the candidate item information is calculated, and the item recommendation list is obtained by sorting according to the inner product result.

Citation Information

Patent Citations

  • Collaborative filtering recommendation algorithm based on user attributes and item scores

    CN115114517A

  • Contrast learning depolarization intelligent recommendation method based on diffusion model

    CN119988739A