Quaternion-based collaborative recommendation method and device, terminal and readable storage medium
By using a quaternion-based collaborative recommendation method, the collaborative recommendation model is optimized using quaternion vectors and Hamiltonian multiplication, which solves the data sparsity problem and improves the accuracy and efficiency of recommendations.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2026-03-24
AI Technical Summary
Existing collaborative filtering recommendation algorithms suffer from inaccurate user similarity calculations when dealing with data sparsity and single information sources, thus affecting the accuracy of recommendations.
A quaternion-based collaborative recommendation method is adopted. By generating quaternion vectors of users and items, Hamiltonian multiplication and cosine similarity are used to optimize the preset collaborative recommendation model, generate a corrected quaternion vector, and recommend items to users.
It improves the accuracy and efficiency of recommendations by capturing complex relationships through the representational power of quaternion space and the enhancement of Hamiltonian multiplication, thereby improving the accuracy of recommendations.
Smart Images

Figure CN115391676B_ABST
Abstract
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 quaternions. 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 quaternions.
[0006] To achieve the above objectives, the technical solution of the present invention is implemented as follows: a collaborative recommendation method based on quaternions, comprising the following steps: obtaining the quaternion vector E corresponding to user U from a preset collaborative recommendation model. u =e u,r +e u,i i+e u,j j+e u,k k, where i, j, and k are imaginary parts, and eu,r e u,i e u,j and e u,k All are real vectors of dimension D, where D is a natural number and D≥2; retrieve Num1 items N1, N2, ..., N that have an implicit relationship with user U within a preset time period. Num1 Based on the preset collaborative recommendation model, item N is generated. h The corresponding quaternion vector E′ h =e′ h,r +e′ h,i i+e′ h,j j+e′ h,k k, e′ h,r 、e′ h,i 、e′ h,j and e′ h,k Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1; generate quaternion vectors. Where W is a quaternion vector W = P r +P i i+P j j+P k k, P r P i P j and P k They are all real vectors of dimension D. For Hamiltonian multiplication, the product of two D-dimensional real vectors is the Hadamard product; the modified quaternion vector H corresponding to user U. u =g·E u +(1-g)·P, where g is a real number, 0≤g≤1; based on the modified quaternion vector H u Recommend items to user U.
[0007] As an improvement to an embodiment of the present invention, the "based on the modified quaternion vector H" u "Recommending items to user U" specifically includes: obtaining Num2 items N′1, N′2, ..., N′ Num2 Based on the preset collaborative recommendation model, item N′ is generated. g The corresponding quaternion vector E″ g =e″ g,r +e″ g,i i+e″ g,j j+e″ g,k k, and e″ g,r 、e″ g,i 、e″ g,j and e ″ g,kBoth are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; N items are generated. ′ g The corresponding rating value is Here, cos() represents the cosine similarity. When calculating cosine similarity, the product of two D-dimensional real vectors is the inner product. From Num2 items N′1, N′2, ..., N′... Num2 The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
[0008] As an improvement to an embodiment of the present invention, Num3 = 20.
[0009] As an improvement to this embodiment of the invention, the method further includes the following steps: in the preset collaborative recommendation model, the quaternion vector E... u Replace with modified quaternion vector H u .
[0010] As an improvement to this embodiment of the invention, the method further includes the following steps: utilizing cosine contrast loss. The preset collaborative recommendation model is optimized; wherein, m is the threshold, w is a constant, and cos() is the cosine similarity. When calculating cosine similarity, the product between two D-dimensional real vectors is the inner product.
[0011] This invention also provides a quaternion-based collaborative recommendation device, comprising the following modules: a user information processing module, used to obtain the quaternion vector E corresponding to user U from a preset collaborative recommendation model. u =e u,r +e u,i i+e u,j j+e u,k k, where i, j, and k are imaginary parts, and e u,r e u,i e u,j and e u,k All are real vectors of dimension D, where D is a natural number and D≥2; the item information processing module is used to obtain Num1 items N1, N2, ..., N that have an implicit relationship with the user U within a preset time period. Num1 Based on the preset collaborative recommendation model, item N is generated. h The corresponding quaternion vector E′ h =e′ h,r +e′ h,i i+e′ h,j j+e′ h,k k, e′h,r 、e′ h,i 、e′ h,j and e′ h,k Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1; the processing module is used to generate quaternion vectors. Where W is a quaternion vector W = P r +P i i+P j j+P k k, P r P i P j and P k They are all real vectors of dimension D. For Hamiltonian multiplication, the product of two D-dimensional real vectors is the Hadamard product; the recommendation module is used for the corrected quaternion vector H corresponding to user U. u =g·E u +(1-g)·P, where g is a real number, 0≤g≤1; based on the modified quaternion vector H u Recommend items to user U.
[0012] As an improvement to this embodiment of the invention, the recommendation module is further configured to: obtain Num2 items N′1, N′2, ..., N′ Num2 Based on the preset collaborative recommendation model, item N′ is generated. g The corresponding quaternion vector E″ g =e″ g,r +e″ g,i i+e″ g,j j+e″ g,k k, and e″ g,r 、e″ g,i 、e″ g,j and e″ g,k Both are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; Item N′ is generated. g The corresponding rating value is Here, cos() represents the cosine similarity. When calculating cosine similarity, the product of two D-dimensional real vectors is the inner product. From Num2 items N′1, N′2, ..., N′... Num2 The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
[0013] As an improvement to an embodiment of the present invention, Num3 = 20.
[0014] This invention also provides a terminal, comprising: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the collaborative recommendation method as described above.
[0015] This invention also provides a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the collaborative recommendation method described above.
[0016] The quaternion-based collaborative recommendation method, apparatus, terminal, and readable storage medium provided in this invention have the following advantages: This invention discloses a quaternion-based collaborative recommendation method, apparatus, terminal, and readable storage medium. The collaborative recommendation method includes: obtaining a quaternion vector corresponding to a user from a preset collaborative recommendation model; obtaining multiple items with implicit relationships to the user within a preset time period; generating a quaternion vector corresponding to each item based on the preset collaborative recommendation model; obtaining a modified quaternion vector corresponding to the user based on the quaternion vectors of multiple items; and recommending items to the user based on the modified quaternion vector. This collaborative recommendation method 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 2 and Figure 3 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 quaternions. 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 at preset intervals, or when a user logs in.
[0023] like Figure 1 As shown, it includes the following steps:
[0024] Step 101: Obtain the quaternion vector E corresponding to user U from the preset collaborative recommendation model. u =e u,r +e u,i i+e u,j j+e u,k k, where i, j, and k are imaginary parts, and e u,r e u,i e u,j and e u,k All are real vectors of dimension D, where D is a natural number and D≥2;
[0025] Here, the pre-defined collaborative recommendation model generally consists of three parts: an interactive encoder, negative sampling, and a loss function. This pre-defined collaborative recommendation model uses quaternion embedding to embed user U into a quaternion space, thereby obtaining the quaternion vector E corresponding to user U. u .
[0026] Here, the user is represented as a quaternion, which has good representational ability, thus facilitating subsequent processing.
[0027] Step 102: Obtain Num1 items N1, N2, ..., N that have an implicit relationship with user U within a preset time period. Num1 Based on the preset collaborative recommendation model, item N is generated. h The corresponding quaternion vector E′ h =e′ h,r +e′ h,i i+e′ h,j j+e′ h,k k, e′ h,r 、e′ h,i 、e′ h,j and e′ h,k Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1;
[0028] Here, the item is represented as a quaternion. It is understandable that quaternions have good representational ability, which facilitates subsequent processing.
[0029] Step 103: Generate quaternion vectors Where W is a quaternion vector W = P r +P i i+P j j+P k k, P r P i P j and P k They are all real vectors of dimension D. For Hamiltonian multiplication, the product between two D-dimensional real vectors is the Hadama product.
[0030] Step 104: The corrected quaternion vector H corresponding to user U u =g·E u +(1-g)·P, where g is a real number, 0≤g≤1; based on the modified quaternion vector H u Recommend items to user U.
[0031] Here, we assume that Q and Q′ are both quaternions, and Q = Q r +Q i i+Q j j+Q k k, Q′=Q′ r +Q′ i i+Q′ j j+Q′ k k, Q r Q i Q j Q k ,Q′ r ,Q′ i ,Q′ j ,Q′ k ∈R, i,j,k are imaginary parts, satisfying i 2 =j 2 =k 2 =ijk=-1.
[0032] In mathematics, quaternions Q and Q' ′ The definition of addition is as follows: Q + Q′ = (Q r +Q′ r )+(Q i +Q′ i )i+(Q j +Q′ j )j+(Q k +Q′ k )k, where "+" means the addition of two real numbers. It can be understood that if the meaning of "+" is modified to the addition between two vectors, then the addition between two quaternion vectors in this embodiment can be defined.
[0033] In mathematics, the subtraction of quaternions Q and Q′ is defined as follows: QQ′=(Q r -Q′ r )+(Q i -Q′ i )i+(Q j -Q′ j )j+(Q k -Q′ k)k, where "-" means subtraction of two real numbers. It can be understood that by modifying the meaning of "+" to subtraction between two vectors, the subtraction between two quaternion vectors in this embodiment can be defined.
[0034] In mathematics, the Hamiltonian multiplication of quaternions Q and P is defined as follows:
[0035] In this formula, "+" represents addition of two real numbers, "-" represents subtraction of two real numbers, and "*" represents multiplication of two real numbers. It can be understood that by modifying the meaning of "+" to addition of two vectors, "-" to subtraction, and "*" to the Hadamard product of two vectors, the formula can be completed. The operation.
[0036] Here, each time the collaborative recommendation method is executed, the historical user profile E corresponding to user U is obtained. u Then, the user's activities during the preset time period are obtained, thus obtaining the revised user profile H. u Subsequently, based on the revised user profile H u When recommending items to users, it's understandable that this collaborative recommendation method uses a variety of information, thereby greatly improving the accuracy of the recommendations.
[0037] In the quaternion space, each quaternion is a hypercomplex number consisting of one real part and three imaginary parts. The Hamiltonian product is the multiplication of quaternions that enhances the potential interrelationship between the real and imaginary parts of two quaternions. Any tiny change in the input quaternion will lead to a completely different output, resulting in highly representative computations where complex relationships can be captured more powerfully.
[0038] In this embodiment, the "based on the modified quaternion vector H" u "Recommending items to user U" specifically includes: obtaining Num2 items N′1, N′2, ..., N′ Num2 Based on the preset collaborative recommendation model, item N′ is generated. g The corresponding quaternion vector E″ g =e″ g,r +e″ g,i i+e″ g,j j+e″ g,k k, and e″ g,r 、e″ g,i 、e″ g,j and e″ g,k Both are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; Item N′ is generated. gThe corresponding rating value is Here, cos() represents the cosine similarity. When calculating cosine similarity, the product of two D-dimensional real vectors is the inner product. From Num2 items N′1, N′2, ..., N′... Num2 The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
[0039] In mathematics, the cosine similarity between a quaternion Q and a quaternion Q′ is . In this context, "+" represents addition of two real numbers, "-" represents subtraction of two real numbers, and "*" represents multiplication of two real numbers. It can be understood that by modifying the meaning of "+" to addition between two vectors, "-" to subtraction, and "*" to the inner product of two vectors, the cosine similarity between quaternions Q and P can be calculated.
[0040] Here, when displaying items, the higher the rating, the more prominent the item will be in the display position.
[0041] In this embodiment, Num3 = 20.
[0042] In this embodiment, the following step is also included: in the preset collaborative recommendation model, the quaternion vector E u Replace with modified quaternion vector H u .
[0043] Optionally, the user's historical user profile can be stored in 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... u This refers to the revised user profile H obtained from this execution. u .
[0044] This embodiment also includes the following step: using cosine contrast loss The preset collaborative recommendation model is optimized; wherein, m is the threshold, w is a constant, and cos() is the cosine similarity. When calculating cosine similarity, the product of two D-dimensional real vectors is the inner product. Here, m can be considered the threshold for filtering negative samples; negative samples below this threshold are discarded (because, at this point, ...). Cosine contrast loss maximizes the cosine similarity between positive pairs and minimizes the cosine similarity between negative pairs.
[0045] To verify the usability of this collaborative recommendation method, the inventors conducted the following experiments:
[0046] To evaluate the effectiveness of our collaborative recommendation method, experiments were conducted on three benchmark datasets: Kindle-Store, Gowalla, and Yelp 2018. The first dataset comes from Amazon reviews, the second from Gowalla user registration information, and the third from the 2018 Yelp Challenge. These three datasets are widely used in recommender system evaluation. Table 1 shows detailed statistics for these three datasets.
[0047] Table 1. Statistical Analysis of Experimental Data
[0048] Dataset Gowalla Yelp 2018 Kindle Store Number of users 29,858 31,668 68,223 Item count 40,981 38,048 61,934 Number of interactions 1,027,370 1,561,406 982,618 sparsity 99.92% 99.87% 99.98%
[0049] Introduction to the comparative model
[0050] NeuMF: To address the issue of insufficient feature interaction in traditional matrix factorization, a deep learning-based collaborative filtering framework is introduced. By describing the non-linear relationships between features, it achieves excellent results. The NeuMF model is publicly available in the paper "Neural Collaborative Filtering", which can be downloaded at: https: / / arxiv.org / abs / 1708.05031.
[0051] HOP-Rec: Enhances user interaction through random walks to achieve higher-order user-item interactions. The HOP-Rec model is publicly available in the paper "HOP-rec: high-order proximity for implicit recommendation", which can be downloaded at: https: / / dl.acm.org / doi / abs / 10.1145 / 3240323.3240381.
[0052] GC-MC: This paper explores the first-order connections between users and items using a single-layer graph convolutional network on the user-item bipartite graph. The GC-MC model is publicly available in the paper "Graph Convolutional Matrix Completion", which can be downloaded at: https: / / www.kdd.org / kdd2018 / files / deep-learning-day / DLDay18_paper_32.pdf.
[0053] NGCF: It proposes a propagation layer for embedding vectors and uses the higher-order structure of bipartite graphs to update the embedding vectors of users and items. The NGCF model is published in the paper "Neural Graph Collaborative Filtering", which can be downloaded at: https: / / arxiv.org / abs / 1905.08108?context=cs.IR.
[0054] LightGCN discards two modules from NGCF: feature transfer and non-linear activation function. This operation improves both model efficiency and generalization ability. The LightGCN model is published in the paper "Neural Graph Collaborative Filtering", which can be downloaded at: https: / / arxiv.org / abs / 1905.08108?context=cs.IR.
[0055] SimpleX proposes a cosine contrast loss that maximizes the cosine similarity of positive user-item pairs and minimizes the similarity of negative sample pairs, thereby improving recommendation performance. The SimpleX model is publicly available in the paper "SimpleX: A Simple and StrongBaseline for Collaborative Filtering", which can be downloaded at: https: / / arxiv.org / abs / 2109.12613.
[0056] In the experiment, the inventors treated items that users interacted with as positive samples and items that users did not interact with as negative samples. The inventors used two common top-k recommendation metrics: recall and Normalized Discounted Cumulative Gain (NDCG). For both metrics, the model's evaluation value was calculated based on the top 20 test samples.
[0057] Table 2 compares recommendation performance on the three datasets.
[0058]
[0059] Table 3 Influence of parameter g
[0060]
[0061]
[0062] The inventor implemented their model in PyTorch and made multiple adjustments to key parameters to achieve optimal performance. The embedding vector size was initialized to 64*4 (four positions corresponding to quaternions, each with a size of 64). The model and other parameters were initialized following the SimpleX model's specifications. The inventor used Adam to optimize the model, with a default learning rate of 0.001 and a default batch size of 512. The initial iteration count was 100. To prevent overfitting during training, early stopping was employed, stopping training approximately every forty iterations in the actual experiments. The user's embedding vector was obtained by aggregating and updating the embedding vectors of interacted items, using average pooling as the aggregation method.
[0063] In this section, the inventors provide a comprehensive comparison of their model with several other recommendation models on three main datasets: Kindle-Store, Yelp2018, and Gowalla. These datasets are commonly used in collaborative filtering-based recommendation models (especially graph neural network-based collaborative filtering recommendation models) to demonstrate the superiority of the inventors' model. Figure 2 The comparison of recommendation performance on three datasets is shown. The inventors provide the following analysis of the experimental results:
[0064] NeuMF is a classic collaborative filtering recommendation model, but its recommendation performance is relatively average. The key reason is that this model only captures the correlation between users and items during the embedding learning process, without utilizing the higher-order interactions between users and items.
[0065] Compared to the NeuMFF model, the GC-MCF model uses a single-layer graph convolutional network on the user-item bipartite graph to explore the first-order connections between users and items. This performance improvement reflects the role of capturing the first-order connections between neighbors in representation learning.
[0066] The HOP-RecF model enhances user interaction through random walks to achieve higher-order user-item interactions, resulting in better recommendation performance compared to the GC-MCF model. The NGCFF model outperforms all the above recommendation models by proposing a propagation layer for embedding vectors and utilizing a higher-order structure of a bipartite graph to update the embedding vectors of users and items. Its improved recommendation performance is attributed to the powerful representation learning capabilities of graph convolutional network-based recommendation models. The LightGCF model N discards two modules from the NGCFF model: feature transfer and non-linear activation function. This operation improves both model efficiency and generalization ability. The SimpleXF model proposes cosine contrast loss, maximizing the cosine similarity of positive user-item pairs and minimizing the similarity of negative sample pairs, simplifying the model while improving recommendation performance.
[0067] The inventor's model demonstrates a significant performance improvement compared to the aforementioned comparative models. Specifically, compared to the strongest comparative model, the inventor's model shows an average relative improvement of 7.01% and 7.85% in the two recommendation metrics, Recall@20 and NDCG@20, respectively. The inventor attributes this significant performance improvement to the more powerful representation learning capabilities of quaternion space and quaternion feature transformations for user and item embeddings.
[0068] Here, the inventors evaluated the impact of several important parameters g on the experimental results. These are the aggregation weight g of the neighbor node embedding to the target node, the weight w of the negative sample loss, and the number of negative samples N. See Tables 1, 2, and 3 for details.
[0069] Observing the results in Tables 1, 2, and 3, although the influence trends of each hyperparameter on the results are not entirely the same across different datasets, some patterns can still be observed: when the weight w of the negative sample loss is too large (e.g., w = 1000), the model performance is not very good on all three datasets. This indicates that the negative sample weight should not be set too large after the introduction of the quadruple. Comparatively, the number of negative samples also has a corresponding impact on different datasets. Table 2 also reflects that Yelp2018 and Kindle-Store show relatively synchronized changes, because these datasets are smaller than the Gowalla dataset. The inventors know that the influence of the hyperparameters on the model performance is also related to the size of the dataset. Furthermore, the inventors conducted hyperparameter experiments on hyperparameter g.
[0070] The details were presented in more detail, such as Figure 2 and Figure 3As shown: Due to the small value of the data itself, the trend of change is not so obvious in the graph, but some information can still be captured: the two evaluation indicators of the three datasets show an approximately positive correlation with the increase of the g value, which indicates that the recommendation effect is largely due to the contribution of user interaction item embedding to user embedding update.
[0071] This embodiment focuses on the fact that most collaborative filtering models are modeled in Euclidean space. However, Euclidean embeddings have been shown to exhibit high distortion when modeling complex graph structures. Therefore, the inventors propose a quaternion-based collaborative filtering recommendation model with cosine contrastive loss. First, the inventors use quaternion embeddings to embed all users and items into a quaternion space. Then, they introduce quaternion feature transformations to aggregate negative samples to obtain the current user's preference vector representation, and combine the current user embedding and its preference vector representation using a weighted sum to obtain the user's final representation. Finally, the inventors use cosine contrastive loss to optimize the model. Extensive experiments were conducted on three publicly available large datasets, and comparative analyses were performed with state-of-the-art recommendation models. The experimental results demonstrate that the inventors' model outperforms current state-of-the-art recommendation models.
[0072] Embodiment 2 of the present invention provides a collaborative recommendation device based on quaternions, comprising the following modules:
[0073] The user information processing module is used to obtain the quaternion vector E corresponding to user U from the preset collaborative recommendation model. u =e u,r +e u,i i+e u,j j+e u,k k, where i, j, and k are imaginary parts, and e u,r e u,i e u,j and e u,k All are real vectors of dimension D, where D is a natural number and D≥2;
[0074] The item information processing module is used to obtain Num1 items N1, N2, ..., N that have an implicit relationship with user U within a preset time period. Num1 Based on the preset collaborative recommendation model, item N is generated. h The corresponding quaternion vector E′ h =e′ h,r +e′ h,i i+e′ h,j j+e′ h,k k, e′ h,r 、e′ h,i 、e′ h,j and e′h,k Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1;
[0075] The processing module is used to generate quaternion vectors. Where W is a quaternion vector W = P r +P i i+P j j+P k k, P r P i P j and P k They are all real vectors of dimension D. For Hamiltonian multiplication, the product between two D-dimensional real vectors is the Hadama product.
[0076] The recommendation module is used to specify the corrected quaternion vector H corresponding to user U. u =g·E u +(1-g)·P, where g is a real number, 0≤g≤1; based on the modified quaternion vector H u Recommend items to user U.
[0077] In this embodiment, the recommendation module is further configured to: obtain Num2 items N′1, N′2, ..., N′ Num2 Based on the preset collaborative recommendation model, item N′ is generated. g The corresponding quaternion vector E″ g =e″ g,r +e″ g,i i+e″ g,j j+e″ g,k k, and e ″ g,r 、e″ g,i 、e″ g,j and e″ g,k Both are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; Item N′ is generated. g The corresponding rating value is Here, cos() represents the cosine similarity. When calculating cosine similarity, the product of two D-dimensional real vectors is the inner product. From Num2 items N′1, N′2, ..., N′... Num2 The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
[0078] In this embodiment, Num3 = 20.
[0079] Embodiment 3 of the present invention provides a terminal, including: a memory for storing a computer program; and a processor for executing the computer program to implement the steps of the collaborative recommendation method as described in Embodiment 1.
[0080] Embodiment 4 of the present invention provides a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the collaborative recommendation method as described in Embodiment 1.
[0081] It should be noted that although the steps are described in a specific order above, it does not mean that the steps must be executed in the above specific order. In fact, some of these steps can be executed concurrently, or even in a different order, as long as the required function can be achieved.
[0082] This invention can be a system, method, and / or computer program product. A computer program product may include a readable storage medium having computer-readable program instructions loaded thereon for causing a processor to implement various aspects of the invention.
[0083] A readable storage medium can be a tangible device that holds and stores instructions for use by an instruction execution device. Readable storage media can include, for example, but not limited to, electrical storage devices, magnetic storage devices, optical storage devices, electromagnetic storage devices, semiconductor storage devices, or any suitable combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), static random access memory (SRAM), portable compact disc read-only memory (CD-ROM), digital multifunction disc (DVD), memory sticks, floppy disks, mechanical encoding devices, such as punch cards or recessed protrusions storing instructions thereon, and any suitable combination thereof.
[0084] The various embodiments of the present invention have been described above. These descriptions are exemplary and not exhaustive, nor are they limited to the disclosed embodiments. Many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the described embodiments. The terminology used herein is chosen to best explain the principles, practical application, or technical improvements to the embodiments in the market, or to enable others skilled in the art to understand the embodiments disclosed herein.
Claims
1. A collaborative recommendation method based on quaternions, characterized in that, Includes the following steps: Obtain the quaternion vector corresponding to user U from the preset collaborative recommendation model. Where i, j, and k are imaginary parts, and and All are real vectors of dimension D, where D is a natural number and D≥2; Retrieve Num1 items that have an implicit relationship with user U within a preset time period. , ... Based on the preset collaborative recommendation model, items are generated. The corresponding quaternion vector , and Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1; Generate quaternion vectors Where W is a quaternion vector W , , , and They are all real vectors of dimension D. For Hamiltonian multiplication, the product between two D-dimensional real vectors is the Hadama product. The corrected quaternion vector corresponding to user U Where g is a real number, 0 ≤ g ≤ 1; obtain Num2 items. , ... Based on the preset collaborative recommendation model, items are generated. The corresponding quaternion vector ,and and Both are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; generate items. The corresponding rating value is ,in, For cosine similarity, the product of two D-dimensional real vectors is the inner product; from Num2 items , ... The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
2. The collaborative recommendation method according to claim 1, characterized in that: Num3=20.
3. The collaborative recommendation method according to claim 1, characterized in that, It also includes the following steps: In the preset collaborative recommendation model, quaternion vectors are used. Replace with modified quaternion vector .
4. The collaborative recommendation method according to claim 1, characterized in that, It also includes the following steps: Using cosine contrast loss The preset collaborative recommendation model is optimized; wherein, m is the threshold, and w is a constant. For cosine similarity, the product between two D-dimensional real vectors is the inner product.
5. A collaborative recommendation device based on quaternions, characterized in that, Includes the following modules: The user information processing module is used to obtain the quaternion vector corresponding to user U from the preset collaborative recommendation model. Where i, j, and k are imaginary parts, and and All are real vectors of dimension D, where D is a natural number and D≥2; The item information processing module is used to obtain Num1 items that have an implicit relationship with user U within a preset time period. , ... Based on the preset collaborative recommendation model, items are generated. The corresponding quaternion vector , and Both are real vectors of dimension D, where h and Num1 are natural numbers, h = 1, 2, ..., Num1; The processing module is used to generate quaternion vectors. Where W is a quaternion vector W , , , and They are all real vectors of dimension D. For Hamiltonian multiplication, the product between two D-dimensional real vectors is the Hadama product. The recommendation module is used to specify the corrected quaternion vector for user U. Where g is a real number, 0 ≤ g ≤ 1; obtain Num2 items. , ... Based on the preset collaborative recommendation model, items are generated. The corresponding quaternion vector ,and and Both are real vectors of dimension D, where g and Num2 are natural numbers, g = 1, 2, ..., Num2; generate items. The corresponding rating value is ,in, For cosine similarity, the product of two D-dimensional real vectors is the inner product; from Num2 items , ... The three highest-rated values (Num3) are selected and displayed to user U, where Num3 is a natural number and Num3 ≤ Num2.
6. The collaborative recommendation device according to claim 5, characterized in that: Num3=20.
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.