Collaborative recommendation method and device based on negative samples, terminal and readable storage medium

By using a negative sample-based collaborative recommendation method, a corrected embedding vector is generated and the model is optimized using cosine contrastive loss. This solves the problems of data sparsity and information uniformity in collaborative filtering recommendation algorithms, achieving higher recommendation accuracy and efficiency.

CN115391677BActive Publication Date: 2026-05-01SUZHOU VOCATIONAL UNIVERSITY (SUZHOU OPEN UNIVERSITY)
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SUZHOU VOCATIONAL UNIVERSITY (SUZHOU OPEN UNIVERSITY)
Filing Date
2022-09-20
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing collaborative filtering recommendation algorithms struggle to accurately calculate user similarity when faced with data sparsity and limited information sources, thus affecting the accuracy of recommendations.

Method used

A collaborative recommendation method based on negative samples is adopted. By obtaining negative samples from a pre-defined collaborative filtering model, an initial embedding vector is generated and masked to generate a corrected embedding vector. The model is then optimized by combining cosine contrast loss to filter difficult negative samples and improve recommendation accuracy.

Benefits of technology

It improves the accuracy and efficiency of recommendations, enhances user representation capabilities, and improves the performance of the recommendation system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115391677B_ABST
    Figure CN115391677B_ABST
Patent Text Reader

Abstract

The application discloses a negative sample-based collaborative recommendation method and device, a terminal and a readable storage medium. The collaborative recommendation method comprises the following steps: obtaining a preset collaborative filtering model, the preset collaborative filtering model comprising an encoding layer, an aggregation layer and a prediction layer; obtaining a negative sample corresponding to a user in a preset time period; obtaining an initial embedding vector corresponding to the user from the preset collaborative filtering model; generating an embedding vector and a corrected embedding vector; and recommending an item to the user based on the corrected embedding vector. The collaborative recommendation algorithm has the advantages of high accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of big data processing technology, and in particular to a collaborative recommendation method, apparatus, terminal, and readable storage medium based on negative samples. Background Technology

[0002] The rapid development of the internet in recent years has led to a surge in the total amount of information online, while e-commerce continues to expand. The sheer volume of online data means users need to spend considerable time searching for items they like, and this process of filtering out a large amount of useless information undoubtedly hinders their enjoyment of the convenience offered by the internet. To address these issues, personalized recommendation systems have emerged. Personalized recommendation systems are advanced intelligent platforms built on the foundation of massive data mining. They primarily recommend information and products that users are interested in based on their interests and other information, providing users with fully personalized decision support and information services. Personalized recommendations not only play a vital role and have significant value in promoting economic and internet development, but improving the efficiency and accuracy of recommendations is also a hot research topic worthy of study.

[0003] Collaborative filtering recommendation algorithm is one of the most commonly used and effective recommendation algorithms in personalized recommendation systems. Unlike traditional content-based recommendations, collaborative filtering analyzes user interests, finds similar users within a user group, and synthesizes the evaluations of these similar users on a particular item to predict the user's preference for that item. Despite its widespread application, collaborative filtering still struggles to overcome the problems caused by data sparsity and limited information sources. Specifically, the sparsity of the user-item matrix leads to inaccurate user similarity calculations, thus affecting the accuracy of recommendations.

[0004] Therefore, designing a highly accurate collaborative recommendation method has become an urgent problem to be solved. Summary of the Invention

[0005] In view of this, the main objective of the present invention is to provide a collaborative recommendation method, apparatus, terminal and readable storage medium based on negative samples.

[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows: a collaborative recommendation method based on negative samples, comprising the following steps: obtaining a preset collaborative filtering model, wherein the preset collaborative filtering model includes an encoding layer, an aggregation layer, and a prediction layer; obtaining negative samples corresponding to user U in a preset time period, wherein the negative samples include Num items N1, N2, ..., N... Num Based on the encoding layer in the preset collaborative filtering model, item N is generated.h The corresponding initial embedding vector E' of dimension D h , where D, h, and Num are all natural numbers, h = 1, 2,..., Num; obtain the initial embedding vector E of dimension D corresponding to user U from the preset collaborative filtering model u ; generate an embedding vector where I h represents whether to mask item N h . When I h = 1, it means to retain item N h ; when I h = 0, it means to discard item N h ; The corrected embedding vector H corresponding to user U u = g·E u +(1 - g)·P u ·V, where g is a real number, 0 ≤ g ≤ 1, and V is a real number matrix with D rows and D columns; recommend items to user U based on the corrected embedding vector H u

[0007] As an improvement of an embodiment of the present invention, in the preset collaborative filtering model, replace the initial embedding vector E u with the corrected embedding vector H u .

[0008] As an improvement of an embodiment of the present invention, it further includes the following steps: optimize the preset collaborative filtering model using the cosine contrast loss ; where M and L are thresholds, 0 ≤ M < L, w is a constant, and cos() is the cosine similarity function

[0009] As an improvement of an embodiment of the present invention, 0 ≤ M ≤ 1

[0010] As an improvement of an embodiment of the present invention, 0 ≤ L ≤ 1

[0011] An embodiment of the present invention further provides a collaborative recommendation device based on negative samples, including the following modules: an information acquisition module, which acquires a preset collaborative filtering model, and the preset collaborative filtering model includes an encoding layer, an aggregation layer, and a prediction layer; acquires the negative samples corresponding to user U in a preset time period, and the negative samples include Num items N1, N2,..., N Num , and based on the encoding layer in the preset collaborative filtering model, generate the initial embedding vector E' of dimension D corresponding to item N h h ​, D, h, and Num are all natural numbers, h = 1, 2,..., Num; a processing module for obtaining an initial embedding vector E of dimension D corresponding to user U from the preset collaborative filtering model u ; generating an embedding vector where I h represents whether to mask item N h When I h = 1, it means to retain item N h ; when I h = 0, it means to discard item N h ; The corrected embedding vector H corresponding to user U u = g·E ... u +(1 - g)·P u ·V, where g is a real number, 0 ≤ g ≤ 1, and V is a real matrix with D rows and D columns; a recommendation module for recommending items to user U based on the corrected embedding vector H u

[0012] As an improvement of an embodiment of the present invention, in the preset collaborative filtering model, the initial embedding vector E u is replaced with the corrected embedding vector H u

[0013] As an improvement of an embodiment of the present invention, it further includes the following module: a training module for optimizing the preset collaborative filtering model using cosine contrast loss ; where M and L are thresholds, 0 ≤ M < L, w is a constant, and cos() is the cosine similarity function.

[0014] An embodiment of the present invention further provides a terminal, including: a memory for storing a computer program; a processor for implementing the steps of the above collaborative recommendation method when executing the computer program.

[0015] An embodiment of the present invention further provides a readable storage medium, on which a computer program is stored, and the computer program implements the steps of the above collaborative recommendation method when executed by a processor.

[0016] ​The collaborative recommendation method, apparatus, terminal, and readable storage medium based on negative samples provided in this invention have the following advantages: This invention discloses a collaborative recommendation method, apparatus, terminal, and readable storage medium based on negative samples. The collaborative recommendation method includes: obtaining a preset collaborative filtering model, which includes an encoding layer, an aggregation layer, and a prediction layer; obtaining negative samples corresponding to users within a preset time period; obtaining an initial embedding vector corresponding to the user from the preset collaborative filtering model; generating an embedding vector and a corrected embedding vector; and recommending items to the user based on the corrected embedding vector. This collaborative recommendation algorithm has the advantage of high accuracy. Attached Figure Description

[0017] Figure 1 A flowchart illustrating the collaborative recommendation method provided in an embodiment of the present invention;

[0018] Figure 2A , Figure 2B , Figure 3A , Figure 3B and Figure 3C The figure shows the experimental results of the collaborative recommendation method. Detailed Implementation

[0019] The present invention will now be described in detail with reference to the embodiments shown in the accompanying drawings. However, these embodiments do not limit the present invention, and any structural, methodological, or functional modifications made by those skilled in the art based on these embodiments are included within the scope of protection of the present invention.

[0020] The following description and accompanying drawings fully illustrate specific embodiments described herein to enable those skilled in the art to practice them. Some embodiments may include or substitute parts and features of other embodiments. The scope of the embodiments herein encompasses the entire scope of the claims and all available equivalents thereof. Throughout this document, the terms “first,” “second,” etc., are used only to distinguish one element from another without requiring or implying any actual relationship or order between the elements. Indeed, a first element can also be referred to as a second element, and vice versa. Furthermore, the terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a structure, apparatus, or device that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a structure, apparatus, or device. Without further limitation, an element defined by the phrase “comprising one…” does not exclude the presence of other identical elements in the structure, apparatus, or device that includes said element. The various embodiments described herein are presented in a progressive manner, with each embodiment focusing on its differences from other embodiments; similar or identical parts between embodiments can be referred to interchangeably.

[0021] The terms "longitudinal," "lateral," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer" used in this document to indicate orientations or positional relationships are based on the orientations or positional relationships shown in the accompanying drawings. They are used solely for the convenience of describing the document and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. In the description herein, unless otherwise specified and limited, the terms "installed," "connected," and "linked" should be interpreted broadly. For example, they can refer to mechanical or electrical connections, or internal connections between two elements; they can be direct connections or indirect connections through an intermediate medium. Those skilled in the art can understand the specific meaning of the above terms according to the specific circumstances.

[0022] Embodiment 1 of this invention provides a collaborative recommendation method based on negative samples. This collaborative recommendation method can be executed using a computer system, such as the server of an online movie ticketing website, an online shopping website, etc. Therefore, in this application, the item can be a movie ticket, a commodity, etc. The computer system executes the collaborative recommendation method once at a preset time interval, or once when a user logs in.

[0023] like Figure 1 As shown, it includes the following steps:

[0024] Step 101: Obtain a preset collaborative filtering model, which includes an encoding layer, an aggregation layer, and a prediction layer; obtain negative samples corresponding to user U in a preset time period, where the negative samples contain Num items N1, N2, ..., N Num Based on the encoding layer in the preset collaborative filtering model, item N is generated. h The corresponding D-dimensional initial embedding vector E′ h D, h, and Num are all natural numbers, where h = 1, 2, ..., Num;

[0025] Here, in the encoding layer, initial vector representations are generated by embedding and encoding users and items separately. Then, a user-item interaction matrix is ​​constructed based on users' historical interaction data. When creating the user-item interaction matrix, let M and N represent the number of users and items, respectively, and U and I represent the user set and item set, respectively. The user-item interaction matrix Y∈R is defined. M×N Using Y ij Let Y represent the element in the i-th row and j-th column of matrix Y. If user i has interacted with item j, then Y... ij =1, otherwise Y ij =0.

[0026] In the aggregation layer, most traditional collaborative filtering methods directly use the user's original vector representation to calculate the similarity between the user and the item. Here, in order to better simulate user behavior characteristics, all the items that each user has interacted with are input into the model as additional supplementary information, thereby forming a user feature vector with better representation capabilities.

[0027] In the prediction layer, after obtaining the final representations of users and items, cosine similarity is used to calculate the predicted rating of the user for the item.

[0028] Step 102: Obtain the initial D-dimensional embedding vector E corresponding to user U from the preset collaborative filtering model. u Generate embedding vectors Among them, I h Indicates whether item N is... h To take cover, when I h =1, indicating that item N is retained. h ; when I h =0 indicates that item N was discarded. h ; The corrected embedding vector H corresponding to user U u =g·E u +(1-g)·P u ·V, where g is a real number, 0≤g≤1, and V is a D-row, D-column real matrix;

[0029] In existing collaborative filtering models, similarity is almost always calculated directly using the user's original vector representation. However, considering the uniqueness of user representation, this collaborative recommendation method aggregates the sequence of items the user has interacted with as supplementary information to enhance the user representation. It is understandable that when I... h =0, which is equivalent to discarding item N. h Here, g can be understood as a hyperparameter weight used to control the importance of the behavior aggregation vector.

[0030] Step 103: Based on the modified embedding vector H u Recommend items to user U.

[0031] In this embodiment, in the preset collaborative filtering model, the initial embedding vector E is... u Replace with modified embedding vector H u .

[0032] Here, the user's historical user profile E u Replace with modified user profile H u Therefore, the next time the collaborative recommendation method is run, the historical user profile E obtained will be... uThat is the corrected user profile H obtained from this execution u .

[0033] In this embodiment, the following steps are further included: Using the cosine contrast loss to optimize the preset collaborative filtering model; where M and L are thresholds, 0 ≤ M < L, w is a constant, and cos() is the cosine similarity function.

[0034] In this embodiment, 0 ≤ M ≤ 1.

[0035] In this embodiment, 0 ≤ L ≤ 1.

[0036] Here, only when satisfies will the cosine contrast loss L CCL (H u , E′ h ) be calculated. For those that do not meet this condition the cosine contrast loss is not calculated, that is, they are discarded. Using this cosine contrast loss L CCL to calculate the final global loss, thereby updating the model parameters during the backpropagation gradient descent process.

[0037] By performing L2 normalization on the two vectors H u and E′ h , the cosine similarity only calculates the angular difference, thereby avoiding the influence of the representation size; this is very beneficial because the sizes of user and item representations may have strong biases due to their popularity in the collaborative filtering task.

[0038] Here, M can be understood as the lower bound Margin for filtering negative samples, and L can be understood as the upper bound Limit for filtering negative samples. L CCL (H u , E′ h ) can maximize the similarity between positive pairs and minimize the similarity of negative pairs within the selection interval. w, M, and L can be understood as hyperparameters that control the relative weights of positive sample loss and negative sample loss.

[0039] When the number of samples in the negative samples increases, there are usually many samples with insufficient information. However, existing loss functions (such as BPR, etc.) will equivalently process each negative sample. Therefore, the model training process may be overwhelmed by these uninformative samples, which will significantly reduce the model performance and convergence speed. Because the distribution of negative samples follows a skewed distribution, difficult negative samples are concentrated in the high-similarity part, while low-similarity negative samples are usually simple negative samples. Therefore, the cosine contrast loss L CCLBy using an appropriate margin, inconvenient negative samples can be filtered out, retaining only difficult negative samples. When the cosine similarity of a negative sample is lower than a set margin, it indicates that the negative sample lacks information, and the inventors set its value to zero in the loss function. This operation helps to automatically identify difficult negative samples with a cosine similarity greater than the margin, thus facilitating better model training.

[0040] While researching the image domain, the inventors also studied the distribution of spurious negative samples and found that as hard negative samples were filtered, spurious negative samples tended to concentrate at the top of the hard negative sample pool. Therefore, the inventors hypothesized that a similar distribution of spurious negative samples would exist in the recommendation domain. False negative samples have the same or even higher similarity to hard negative samples, and ignoring their existence would negatively impact model performance. To mitigate or even eliminate this negative impact, the inventors set a threshold limit for selecting negative samples. Specifically, if the cosine similarity of a negative sample exceeds the limit, it is more likely to be a spurious negative sample, and its value in the loss function is set to zero. This operation helps to obtain better and more genuine hard negative samples through negative sampling, thereby improving the model's recommendation performance.

[0041] Here, during the backpropagation process of model training, the embedding representation of each user and item is gradually updated and optimized, thereby updating the user-item interaction matrix.

[0042] To verify the usability of the collaborative recommendation method, the inventors conducted corresponding experiments. First, they gave a brief introduction to the dataset, comparison model, and evaluation index used in the experiment. Second, they conducted a detailed comparative analysis of the experimental parameter settings and experimental results. Finally, they conducted a qualitative and quantitative analysis of the ablation experiment and hyperparameter tuning process of the model.

[0043] Dataset

[0044] This model was tested on three existing public datasets: Movielens-100k, Amazon-Electronics, and Amazon-Music. A brief introduction to each dataset follows:

[0045] Movielens-100k: The MovieLens dataset was collected by the GroupLens research project. This dataset includes 100,000 ratings (1-5) of 1,682 movies from 943 users, with each user rating at least 20 movies.

[0046] Amazon-Electronics: This Amazon dataset is a collection of user reviews from the e-commerce website amazon.com. This paper uses the Electronics category, which contains purchase records of electronic products from Amazon.com. The inventors selected a 5-core version (removing users and items with fewer than 5 purchase records).

[0047] Amazon-Music: This dataset uses the Digital Music category from the Amazon dataset, containing purchase and review records of digital music from amazon.com / music. The inventors selected the 5-core version (removing users and music with fewer than 5 purchase or review records).

[0048] For experimental purposes, the inventors preprocessed the three datasets accordingly: they retained only the user ID, item ID, and rating behavior in the datasets, deleted other redundant information, and then constructed a user-item interaction sequence based on the user's rating behavior for the items, storing it row by row.

[0049] Contrast Model

[0050] The comparative models used in this experiment include NGCF, LightGCN, ENMF, IMP-GCN, DGCF, and SimpleX. The inventors will now describe each of them in detail.

[0051] NGCF: NGCF leverages latent collaborative signals in user item interactions by propagating embeddings across the user item graph structure. This expressively models higher-order connectivity in the user item graph, effectively injecting collaborative signals into the embedding process in an explicit manner. The NGCF model is publicly available in the paper "Neural Graph Collaborative Filtering," which can be downloaded at: https: / / arxiv.org / abs / 1905.08108?context=cs.IR.

[0052] LightGCN: To simplify the design of GCNs and make them more concise and suitable for recommendation, LightGCN only includes the most important component of GCNs—neighborhood aggregation—for collaborative filtering. Specifically, LightGCN learns user and item embeddings by linearly propagating them along the user-item interaction graph and uses the weighted sum of the embeddings learned at all layers as the final embedding. The LightGCN model is publicly available in the paper "LightGCN: Simplifying and Powering Graph Convolution Network for Recommendation," which can be downloaded at: https: / / arxiv.org / abs / 2002.02126.

[0053] ENMF: To learn a neural recommendation model from the entire training data without sampling, ENMF employs three novel optimization methods that can efficiently learn model parameters from the entire data (including all missing data) with relatively low time complexity. The ENMF model is publicly available in the paper "Efficient Neural Matrix Factorization without Sampling for Recommendation", which can be downloaded at: https: / / chenchongthu.github.io / files / TOIS_ENMF.pdf.

[0054] IMP-GCN: IMP-GCN performs high-order graph convolutions on subgraphs. Subgraphs consist of users with similar interests and their interaction items. To form subgraphs, the method designs an unsupervised subgraph generation module that can effectively identify users with shared interests by leveraging user features and graph structure. Therefore, the model avoids propagating negative information from higher-order neighbors into embedding learning. The IMP-GCN model is publicly available in the paper "IMP-GCN: Interest-aware Message-Passing GCN for Recommendation," which can be downloaded at: https: / / arxiv.org / abs / 2102.10044.

[0055] SimpleX: This method considers the choice of loss function and negative sampling rate to be equally important. It also proposes Cosine Contrastive Loss (CCL) and further integrates it into a simple unified collaborative filtering model. The SimpleX model is publicly available in the paper "SimpleX: A Simple and Strong Baseline for Collaborative Filtering," which can be downloaded at: https: / / arxiv.org / abs / 2109.12613.

[0056] Evaluation indicators

[0057] This experiment uses Recall and NDCG, commonly used evaluation metrics in recommender systems, to measure the performance of recommendations.

[0058] Recall is a commonly used evaluation metric in the recall phase of recommender systems. It represents the percentage of positive samples that are predicted to be true. Its formal expression is as follows:

[0059]

[0060] Where u is the user, R(u) is the set of items predicted by the model to be recommended, and T(u) represents the set of items recommended in the actual test set.

[0061] NDCG (normalized discounted cumulative gain) is used as an evaluation metric for ranking results, assessing the accuracy of the ranking. After the recommendation model returns a list of recommendations, NDCG can be used to evaluate the difference between this ranked list and the list of actual user interactions.

[0062]

[0063]

[0064]

[0065] The DCG calculation yields the evaluation metrics for all users' recommendation lists. To enable comparisons between different users, it needs to be normalized. This involves calculating the DCG score for each user's real list, denoted as IDCG. Then, the ratio of each user's DCG to IDCG is used as the normalized score for each user. Finally, the average of all users' scores is taken to obtain the final score, NDCG.

[0066] Analysis of Experimental Results

[0067] Table 1 shows the experimental results of each model on three benchmark datasets. Analyzing the data in this table, the inventors can draw the following conclusions:

[0068] (1) The inventor’s model restricts the upper bound of negative sample sampling on the basis of the original CCL. By comparing the experimental results with simpleX, it was found that the inventor’s model outperformed the existing strongest comparison model simpleX on the three benchmark datasets, thus proving the effectiveness of the inventor’s method.

[0069]

[0070]

[0071] Table 1 compares the recommendation performance of each model on the three datasets.

[0072] Note: The row containing "HNCF(ours)" represents the best data, and the row containing "SimpleX" represents the second-best data.

[0073] (2) As the strongest comparison model, simpleX has significant performance due to its effective screening of negative samples. Data shows that generating more difficult negative samples enables the model to beat most collaborative filtering models.

[0074] (3) IMP-GCN uses sub-images to filter negative samples in the original image based on the existing LightGCN. Experiments show that after denoising, IMP-GCN has a certain improvement in performance compared to LightGCN.

[0075] Ablation experiments and hyperparameter tuning

[0076] To better demonstrate the effectiveness and robustness of the proposed model, the inventors removed the upper bound (limit) for negative samples from the model and obtained corresponding experimental results. Simultaneously, to verify the effectiveness of the aggregation module, the inventors set g to 1, meaning that no information about aggregated interactive items was generated when generating user representations, and similar experimental results were obtained. During the experiments, other parameters were kept constant to maintain optimal results, and the inventors compared the results on three benchmark datasets, obtaining the following... Figure 2A and Figure 2B The results are shown.

[0077] Through analysis Figure 2A and Figure 2B The inventors can draw the following conclusions:

[0078] (1) The inventors found that the aggregation module is effective in most scenarios, providing users with richer information and thus enhancing the final recommendation effect.

[0079] (2) On the Music dataset, the inventors found that the model performed best when g=1, indicating that aggregating user interaction information is not always effective and the optimal case needs to be tested on different datasets.

[0080] (3) By comparing the experimental results of models with and without limits, the inventors can find that adding a certain upper bound when screening negative samples is helpful for the final prediction of the model.

[0081] During the hyperparameter tuning process, the inventors performed a grid search on all key parameters involved in the model. They then selected the three parameters most relevant to their model for analysis, as shown in the parameter effect line graph below. Figure 3A , Figure 3B and Figure 3C As shown.

[0082] according to Figure 3A , Figure 3B and Figure 3C In the ml-100k dataset, lower aggregation coefficients yield better results, while in the music dataset, higher g values ​​generally lead to better performance. Regarding the weight w, both datasets show a trend towards lower values ​​being better. As for the limit parameter, the inventors discovered through grid search that the optimal parameter is consistently around 0.94, which precisely demonstrates the effectiveness of their proposed method. When the limit is too high, false negatives may appear, thus reducing the experimental results.

[0083] Embodiment 2 of the present invention provides a collaborative recommendation device based on negative samples, comprising the following modules:

[0084] The information acquisition module acquires a preset collaborative filtering model, which includes an encoding layer, an aggregation layer, and a prediction layer; and acquires negative samples corresponding to user U within a preset time period, wherein the negative samples contain Num items N1, N2, ..., N Num Based on the encoding layer in the preset collaborative filtering model, item N is generated. h The corresponding D-dimensional initial embedding vector E′ h D, h, and Num are all natural numbers, where h = 1, 2, ..., Num;

[0085] The processing module is used to obtain the initial D-dimensional embedding vector E corresponding to user U from the preset collaborative filtering model. u Generate embedding vectors Among them, I h Indicates whether item N is... h To take cover, when I h =1, indicating that item N is retained. h; When I h = 0, it means discarding item N h ; The corrected embedding vector H corresponding to user U u = g·E u + (1 - g)·P u ·V, where g is a real number, 0 ≤ g ≤ 1, and V is a real matrix with D rows and D columns;

[0086] Recommendation module, used to recommend items to user U based on the corrected embedding vector H u ;

[0087] In this embodiment, in the preset collaborative filtering model, the initial embedding vector E u is replaced with the corrected embedding vector H u ;

[0088] In this embodiment, it further includes the following modules:

[0089] Training module, used to optimize the preset collaborative filtering model using the cosine contrast loss ; where M and L are thresholds, 0 ≤ M < L, w is a constant, and cos() is the cosine similarity function.

[0090] Embodiment 3 of the present invention provides a terminal, including: a memory for storing a computer program; a processor for implementing the steps of the collaborative recommendation method in Embodiment 1 when executing the computer program.

[0091] Embodiment 4 of the present invention provides a readable storage medium, on which a computer program is stored, and the computer program realizes the steps of the collaborative recommendation method in Embodiment 1 when executed by a processor.

[0092] It should be understood that although this specification is described according to embodiments, not every embodiment only contains an independent technical solution. This narrative way of the specification is only for clarity. Those skilled in the art should regard the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.

[0093] The series of detailed descriptions listed above are only specific descriptions of the feasible embodiments of the present invention, and they are not used to limit the protection scope of the present invention. Any equivalent embodiments or changes made without departing from the technical spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. A collaborative recommendation method based on negative samples, characterized in that, Includes the following steps: Obtain a preset collaborative filtering model, which includes an encoding layer, an aggregation layer, and a prediction layer; obtain negative samples corresponding to user U within a preset time period, where each negative sample contains Num items. , ... Based on the encoding layer in the preset collaborative filtering model, items are generated. The corresponding D-dimensional initial embedding vector D, h, and Num are all natural numbers, where h = 1, 2, ..., Num; From the preset collaborative filtering model, obtain the D-dimensional initial embedding vector corresponding to user U. Generate embedding vectors ,in, Indicates whether or not to use the item Take cover, when This indicates that the item is being kept. ;when This indicates that the item has been discarded. ; The corrected embedding vector corresponding to user U V, where g is a real number, 0≤g≤1, and V is a D-row, D-column real matrix; Based on modified embedding vector Recommend items to user U; Using cosine contrastive loss , optimize the preset collaborative filtering model; where , , M and L are thresholds, 0 ≤ M < L, w is a constant is the cosine similarity function 2. The collaborative recommendation method according to claim 1, characterized in that: In the preset collaborative filtering model, the initial embedding vector is... Replace with modified embedding vector .

3. The collaborative recommendation method according to claim 1, characterized in that: 0≤M≤1。 4. The collaborative recommendation method according to claim 1, characterized in that: 0≤L≤1。 5. A collaborative recommendation device based on negative samples, characterized in that, Includes the following modules: The information acquisition module acquires a preset collaborative filtering model, which includes an encoding layer, an aggregation layer, and a prediction layer; and acquires negative samples corresponding to user U within a preset time period, wherein the negative samples contain Num items. , ... Based on the encoding layer in the preset collaborative filtering model, items are generated. The corresponding D-dimensional initial embedding vector D, h, and Num are all natural numbers, where h = 1, 2, ..., Num; The processing module is used to obtain the initial D-dimensional embedding vector corresponding to user U from the preset collaborative filtering model. Generate embedding vectors ,in, Indicates whether or not to use the item Take cover, when This indicates that the item is being kept. ;when This indicates that the item has been discarded. ; The corrected embedding vector corresponding to user U V, where g is a real number, 0≤g≤1, and V is a D-row, D-column real matrix; Recommendation module for using modified embedding vectors Recommend items to user U; A training module for optimizing the preset collaborative filtering model by using a cosine contrast loss , where , , M and L are thresholds, 0 ≤ M < L, w is a constant is a cosine similarity function 6. The collaborative recommendation device according to claim 5, characterized in that: In the preset collaborative filtering model, the initial embedding vector is... Replace with modified embedding vector .

7. A terminal, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the collaborative recommendation method as described in any one of claims 1 to 4 when executing the computer program.

8. A readable storage medium, characterized in that, The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the collaborative recommendation method as described in any one of claims 1 to 4.