A cross-domain recommendation method and device based on federated learning and attention mechanism
By introducing attention mechanism and federated learning into the cross-domain recommendation model and combining the user's domain-shared features and specific features, the problems of user preference diversity and privacy protection in cross-domain recommendation are solved, and efficient cross-domain recommendation and privacy protection are achieved.
Patent Information
- Application Number
- CN202310398860.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-06
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2043-04-06
AI Technical Summary
Existing cross-domain recommendation models fail to effectively utilize the diversity of users' preferences in different fields, and it is difficult to achieve cross-domain recommendation in privacy protection scenarios.
A cross-domain recommendation method based on federated learning and attention mechanism is adopted. By building a cross-domain recommendation model on each client, the user's domain-shared features and domain-specific features are obtained, and the attention mechanism is used for aggregation. During the training process, the model parameters are divided into private parameters and public parameters, and federated learning is used for model aggregation.
The accuracy of recommendation prediction is improved, user privacy is protected, and cross-domain recommendation is realized under privacy protection.
Smart Images

Figure CN116431915B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to a cross-domain recommendation method in the field of artificial intelligence, in particular to a cross-domain recommendation method and device based on federated learning and attention mechanism. BACKGROUND
[0002] A recommendation system can train a model that matches the user's favorite goods according to the user's past interaction records (clicks, purchases), etc. Common recommendation models include matrix decomposition, factor decomposition machine, etc. However, when there are many new users in the system, the interaction data between users and goods is often less, which makes it difficult to train a high-matching recommendation system through historical data. For the data sparsity problem, a feasible solution is to use the interaction data of these users in other fields to assist in training in the current field. This method is called cross-domain recommendation (Cross-domain Recommendation) method. The field used to assist training and having rich interaction data is called "source domain", and the field with sparse data is called "target domain".
[0003] A mainstream cross-domain recommendation method is to train user features using data from the source domain and the target domain, extract part of the overlapping user features to train a mapping model, and then input the new user's feature vector in the source domain into the mapping model to obtain the feature vector in the target domain, and then use the mapped feature vector to make recommendation prediction. However, this mapping-based cross-domain recommendation method only considers "domain-shared features", and does not consider "domain-specific features". In other words, the user's preferences in different fields will show diversity, and directly using the mapped "domain-shared features" for recommendation prediction will reduce the performance of the model.
[0004] In addition, with the gradual improvement of people's awareness of privacy protection, the interaction information of users in other fields may be protected, and it is difficult to directly collect multi-party data to train a cross-domain recommendation model. Federated learning (Federated Learning) can effectively protect user privacy during model training. The basic idea is to use a server to coordinate multiple clients to collaboratively train. The original data is only stored on the client, and during the training process, the client only uploads the model parameters or gradients to the server, and the server aggregates to generate a new global model. Combining cross-domain recommendation model with federated learning can protect user privacy while achieving cross-domain recommendation.
[0005] In summary, the traditional mapping-based cross-domain recommendation model can solve the data sparsity problem to some extent, but it has the following shortcomings:
[0006] (1) For overlapping users, only use the "field shared features" for recommendation, without considering the diversity of user preferences in different fields.
[0007] (2) Multiple field information needs to be collected, and when user privacy is protected, the traditional mapping-based cross-domain recommendation model cannot be implemented. SUMMARY
[0008] In view of the deficiencies of the prior art, the present application provides a cross-domain recommendation method and device based on federated learning and attention mechanism.
[0009] According to a first aspect of an embodiment of the present application, a cross-domain recommendation method based on federated learning and attention mechanism is provided, the method comprising:
[0010] obtaining a source domain feature vector of a user;
[0011] constructing a cross-domain recommendation model on each client respectively, obtaining a field shared feature of the user according to the source domain feature vector, and obtaining a field specific feature of the user and a commodity feature vector according to an identifier of the user and an identifier of the commodity respectively; aggregating the field shared feature and the field specific feature to obtain a mixed feature vector; and performing recommendation prediction based on the mixed feature vector and the commodity feature vector to obtain a preference probability of the user for the commodity;
[0012] training the cross-domain recommendation model on all clients based on a federated learning mechanism.
[0013] According to a second aspect of an embodiment of the present application, a cross-domain recommendation device based on federated learning and attention mechanism is provided, comprising one or more processors for implementing the above-mentioned cross-domain recommendation method based on federated learning and attention mechanism.
[0014] According to a third aspect of an embodiment of the present application, a computer readable storage medium having a program stored thereon is provided, the program being executed by a processor to implement the above-mentioned cross-domain recommendation method based on federated learning and attention mechanism.
[0015] Compared with the prior art, the present application has the following beneficial effects: the present application introduces user "field specific features" on the basis of user "field shared features", and uses an attention mechanism to aggregate them, which not only ensures that user features can be accurately migrated from a source domain to a target domain, but also considers the diversity of user preferences in different fields, thereby improving the accuracy of recommendation prediction. The present application further combines the cross-domain recommendation model with federated learning, so that the cross-domain recommendation model can protect user privacy from being leaked while being trained. BRIEF DESCRIPTION OF DRAWINGS
[0016] In order to make the technical solutions in the embodiments of the present application clearer, the drawings needed in the embodiment description will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.
[0017] Figure 1 is a schematic diagram of a cross-domain recommendation method based on federated learning and attention mechanism provided by the present application.
[0018] Figure 2 is a schematic diagram of a cross-domain recommendation model training process based on attention mechanism in the present application.
[0019] Figure 3 is a schematic diagram of a cross-domain recommendation training process based on attention mechanism combined with federated learning.
[0020] Figure 4 is a schematic diagram of a cross-domain recommendation device based on federated learning and attention mechanism provided by the present application. DETAILED DESCRIPTION
[0021] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor are within the scope of protection of the present application.
[0022] It should be noted that the features in the following embodiments and implementation manners can be combined with each other without conflict.
[0023] As shown in Figure 1 , the present application proposes a cross-domain recommendation method based on federated learning and attention mechanism. The method solves the problem that the traditional mapping-based cross-domain recommendation model does not consider the diversity of user preferences and cannot be applied to privacy protection scenarios. The method specifically includes the following steps:
[0024] Step S1, using a generalized matrix factorization model (GMF) to pre-train the source domain data to obtain the source domain feature vector of the user
[0025] Step S2, constructing a cross-domain recommendation model on each client respectively, obtaining a domain-shared feature of a user according to a source domain feature vector, and respectively obtaining a domain-specific feature of the user and a product feature vector according to an identification of the user and an identification of a product; aggregating the domain-shared feature and the domain-specific feature to obtain a mixed feature vector; and performing recommendation prediction based on the mixed feature vector and the product feature vector to obtain a preference probability of the user for the product.
[0026] Further, as shown in the figure, Figure 2 the cross-domain recommendation model comprises a feature vector generation / mapping layer, a feature aggregation layer, and a recommendation prediction layer, and the step S2 specifically comprises the following sub-steps:
[0027] Step S201, feature vector generation / mapping:
[0028] A multi-layer perception model (MLP) is constructed to map the source domain feature vector of the user obtained in step S1, and the mapped vector is denoted as a domain-shared feature of the user
[0029] The identification of the user and the identification of the product in the target domain are input into an embedding layer (Embedding layer) to generate a domain-specific feature of the user i in the target domain and a product feature vector v j of the product j in the target domain through matrix transformation.
[0030] Step S202, feature aggregation:
[0031] An attention matrix is initialized and normalized using a Softmax function, and is denoted as W A . The attention matrix is used as a weight W A , and the domain-specific feature and the domain-shared feature are aggregated based on an attention mechanism to obtain a mixed feature vector u i of the user in the target domain:
[0032]
[0033] Wherein, represents the element product of the vector.
[0034] Step S203, recommendation prediction:
[0035] In this example, a generalized matrix factorization model (GMF) is used to perform recommendation prediction on the target domain, and the input is the mixed feature vector u i of the user in the target domain and the product feature vector v j converted by the Embedding layer.
[0036] Specifically, the mixed feature vector u i and the commodity feature vector v j are input into a vector element product layer for bit-by-bit multiplication, and then input into a fully connected layer, and the expression is as follows:
[0037]
[0038] where w FC represents the weight of the fully connected layer, and sigma represents a sigmoid activation function, which is used to normalize the predicted value to the range of [0, 1].
[0039] The method further comprises:
[0040] Step S3, training the cross-domain recommendation model on all clients based on a federated learning mechanism.
[0041] The step S3 specifically comprises the following steps:
[0042] S301, dividing the parameters of each cross-domain recommendation model into private parameters and public parameters.
[0043] It should be noted that in addition to the original data, part of the sensitive parameters of the cross-domain recommendation model may also expose user features, such as: user's "domain-specific features" Attention layer weight and the like, which should also be protected and not disclosed to the server or other clients. Therefore, the parameters of the cross-domain recommendation model need to be divided into two parts: "private parameters" and "public parameters".
[0044] Step S302, the server initializes all public parameters, and the client initializes the private parameters of each client.
[0045] Further, each client represents a user and only stores the interaction data of the user and the source domain feature vector of the user. During the training process, the user only needs to upload the public parameters of the cross-domain recommendation model to the server to participate in each round of update and aggregation, and the parameters contained in the private parameters are retained on the client.
[0046] Step S303, the server randomly selects a part of the clients as participants of this round of federated learning, and distributes the public parameters to the participants.
[0047] Step S304, the participants train the cross-domain recommendation model according to the historical interaction records and the source domain feature vector of the user in the local database. After the training is completed, the private parameters are retained locally, and the public parameters are uploaded to the server.
[0048] Step S305, the server receives the public parameter for aggregation, wherein the aggregation weight is the number of interaction data owned by the participant.
[0049] Step S306, the server screens all clients, queries K T rounds of non-participating updating clients, and distributes the aggregated public parameter to the K clients to force them to update the privacy parameter.
[0050] It should be noted that since only a part of the clients are selected to participate in training in each round, the public parameter is updated synchronously in each round, and the privacy parameter is only updated when the user is selected for training, which will cause the update progress of the privacy parameter and the public parameter to be mismatched. In order to ensure that the update progress of the privacy parameter and the public parameter is synchronized, the server will force the clients that have not been selected as participants for a long time to update their privacy parameters.
[0051] Step S307, repeat steps S303-S306 until the cross-domain recommendation model on all clients converges.
[0052] Embodiment 1:
[0053] In this example, it is assumed that the source domain is the movie domain and the target domain is the book domain. By using the cross-domain recommendation method based on federated learning and attention mechanism provided by the application, the knowledge transfer of the user's feature vector in the movie domain is used to solve the problem of data sparsity in the book domain, while protecting the user's privacy from being leaked during the training process. The specific steps include:
[0054] Step 1: Train the GMF recommendation model of the user in the movie domain to obtain the feature vector of the user in the movie domain.
[0055] Step 2: Build a cross-domain recommendation model based on attention mechanism on the client side, the input of the cross-domain recommendation model is the feature vector of the user in the movie domain and the interaction record of the user and the book, and the output of the cross-domain recommendation model is the preference probability of the user to the book.
[0056] Step 3: The client and the server participate in federated learning, divide the model into privacy parameters and public parameters according to whether the parameters contain sensitive information, and then collaboratively train the cross-domain recommendation model based on attention mechanism. In order to ensure that the update progress of the privacy parameter and the public parameter is synchronized, the server will force the clients that have not participated in training for a long time to update their privacy parameters.
[0057] In summary, the application realizes a cross-domain recommendation method based on federated learning and attention mechanism. On the one hand, the attention mechanism is used to combine the "field-specific features" and "field-shared features" of the user, fully considering the diversity of the user's preferences in different fields, thereby improving the accuracy of the recommendation; on the other hand, the federated learning is introduced into the cross-domain recommendation, which protects the user's privacy while realizing the training of the recommendation model and the knowledge migration.
[0058] Corresponding to the foregoing embodiment of the cross-domain recommendation method based on federated learning and attention mechanism, the application also provides an embodiment of a cross-domain recommendation device based on federated learning and attention mechanism.
[0059] Referring to Figure 4 , the cross-domain recommendation device based on federated learning and attention mechanism provided by the embodiment of the application comprises one or more processors for implementing the cross-domain recommendation method based on federated learning and attention mechanism in the foregoing embodiments.
[0060] The embodiment of the cross-domain recommendation device based on federated learning and attention mechanism can be applied to any device with data processing capability, which can be a device or apparatus such as a computer. The device embodiment can be realized by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a logically meaningful device, it is formed by reading the corresponding computer program instructions in the non-volatile memory into the memory for running by the processor of the device with data processing capability where it is located. From the hardware level, as shown in Figure 4 , it is a hardware structure diagram of the device with data processing capability where the cross-domain recommendation device based on federated learning and attention mechanism is located. In addition to the processor, the memory, the network interface, and the non-volatile memory shown in Figure 4 , the device with data processing capability where the device in the embodiment is located usually includes other hardware according to the actual functions of the device with data processing capability, and details are not described here.
[0061] The implementation process of the functions and roles of each unit in the above device is specifically described in the implementation process of the corresponding steps in the above method, and is not described here.
[0062] For the device embodiment, since it basically corresponds to the method embodiment, the relevant part can be seen from the part of the method embodiment. The device embodiment described above is only illustrative, wherein the units described as separate components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place or distributed on multiple network units. Part or all of the modules can be selected to achieve the purpose of the present application according to actual needs. Those skilled in the art can understand and implement it without creative labor.
[0063] The embodiment of the present application also provides a computer readable storage medium, which stores a program, and the program is executed by a processor to realize the cross-domain recommendation method based on federated learning and attention mechanism in the above embodiment.
[0064] The computer readable storage medium can be an internal storage unit of any data processing capable device in the above-mentioned embodiments, such as a hard disk or a memory. The computer readable storage medium can also be any data processing capable device, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. Further, the computer readable storage medium can also include an internal storage unit of any data processing capable device and an external storage device. The computer readable storage medium is used to store the computer program and other programs and data required by the data processing capable device, and can also be used to temporarily store data that has been output or will be output.
[0065] The above embodiments are only used to illustrate the design ideas and characteristics of the present application, and the purpose is to enable those skilled in the art to understand the present application and implement it, and the protection scope of the present application is not limited to the above embodiments. Therefore, any equivalent changes or modifications made according to the principles and design ideas disclosed by the present application are within the protection scope of the present application.
Claims
1. A cross-domain recommendation method based on federated learning and attention mechanism, characterized in that: The method comprises: Obtain the user's source domain feature vector; A cross-domain recommendation model is built on each client. The user's domain-shared features are obtained based on the source domain feature vector. The user's domain-specific features and product feature vectors are obtained based on the user's ID and product ID, respectively. The domain-shared features and domain-specific features are aggregated to obtain a hybrid feature vector. Recommendation predictions are made based on the hybrid feature vector and the product feature vector to obtain the user's preference probability for the product. Based on the federated learning mechanism, cross-domain recommendation models are trained on all clients. The process of obtaining the user's domain-shared features based on the source domain feature vector and obtaining the user's domain-specific features and the product feature vector based on the user's identifier and the product's identifier includes: A multi-layer perceptron model is constructed to map the user's source domain feature vector. The vector obtained after mapping is recorded as the user's domain shared feature. Input the user's identifier and the product's identifier in the target domain into the embedding layer, and generate the user's domain-specific features in the target domain and the product feature vector in the target domain through matrix transformation; Among them, the domain-shared features and domain-specific features are aggregated to obtain the hybrid feature vector including: Initialize an attention matrix and normalize it using the Softmax function. Use the attention matrix as the weight and aggregate domain-specific features and domain-shared features based on the attention mechanism to obtain a mixed feature vector of the user in the target domain.
2. The cross-domain recommendation method based on federated learning and attention mechanism according to claim 1 is characterized in that Obtaining the user's source domain feature vector includes: The source domain data is pre-trained using a generalized matrix factorization model to obtain the user's source domain feature vector.
3. The cross-domain recommendation method based on federated learning and attention mechanism according to claim 1 is characterized in that The user's mixed feature vector in the target domain The expression is as follows: ; Where, is the attention matrix, For domain-shared features, domain-specific features, Represents the element-wise product of vectors.
4. The cross-domain recommendation method based on federated learning and attention mechanism according to claim 1, characterized in that Based on the mixed feature vector and the product feature vector, the recommendation prediction is performed to obtain the user's preference probability for the product, including: The mixed feature vector and the product feature vector are input into the generalized matrix decomposition model to make recommendation predictions for the target domain and obtain the user's preference probability for the product.
5. The cross-domain recommendation method based on federated learning and attention mechanism according to claim 4 is characterized in that The mixed feature vector and the product feature vector are input into the generalized matrix decomposition model to make recommendation predictions for the target domain. The obtained user preference probabilities for the products include: Mix the feature vectors and product feature vector The input is sent to the vector element product layer for bitwise multiplication, and then input to the fully connected layer. The expression is as follows: ; in, represents the weight of the fully connected layer, Represents the sigmoid activation function.
6. The cross-domain recommendation method based on federated learning and attention mechanism according to claim 1 is characterized in that Based on the federated learning mechanism, training cross-domain recommendation models on all clients includes: Divide the parameters of the cross-domain recommendation model into private parameters and public parameters; The server initializes all public parameters, and the clients initialize their own private parameters; The server randomly selects a portion of clients to become participants in this round of federated learning and distributes public parameters to the participants; Participants train a cross-domain recommendation model based on the user's historical interaction records and source domain feature vectors in the local database. After training, the private parameters are retained in the local client and the public parameters are uploaded to the server. The server receives public parameters and aggregates them; The server screens all clients and finds K clients that did not participate in the update in round T. It then distributes the aggregated public parameters to these K clients, forcing them to update their private parameters. Repeat the federated learning iteration until the cross-domain recommendation model on all clients converges.
7. A cross-domain recommendation device based on federated learning and attention mechanism, characterized in that: The invention comprises one or more processors for implementing the cross-domain recommendation method based on federated learning and attention mechanism described in any one of claims 1 to 6.
8. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, it is used to implement the cross-domain recommendation method based on federated learning and attention mechanism described in any one of claims 1 to 6.
Citation Information
Patent Citations
Federal representation learning-based privacy protection cross-domain recommendation system
CN115510316A
Double-target cross-domain recommendation method and system based on knowledge graph and multi-head attention
CN115760279A