A recommendation method, device and equipment based on federated learning and a storage medium
By grouping based on target attributes and training model parameters in the federated recommender system, the problem of neglecting individual needs in group fairness in existing systems is solved, achieving fairer and more efficient recommender performance.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-16
- Publication Date
- 2026-03-24
AI Technical Summary
Existing federated recommendation systems typically focus only on group fairness, neglecting users' personalized needs, resulting in unfair recommendation performance.
By receiving the target attributes uploaded by the target objects, groups are formed into groups and subgroups, and the corresponding model parameter set is sent to each subgroup for training, ensuring individual fairness and group fairness.
This approach achieves the goal of improving the personalization and recommendation performance of the recommendation system while ensuring fairness, thereby enhancing user engagement and system credibility.
Smart Images

Figure CN119474489B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, and in particular to a recommendation method, apparatus, device, and storage medium based on federated learning. Background Technology
[0002] Recommender systems can identify user preferences for different items from massive amounts of data, thereby providing accurate and satisfactory recommendations. Federated recommender systems integrate federated learning into recommendation scenarios, providing users with potentially valuable services while protecting user privacy by keeping sensitive data locally on the user's device.
[0003] Fairness ensures that federated recommender systems provide impartial recommendation performance to users, thereby improving the system's credibility. Fairness is divided into two concepts: individual fairness and group fairness. Specifically, individual fairness requires treating similar individuals equally. Group fairness, as the most widely studied concept of fairness, aims to ensure that recommendation performance is fair among the various groups defined by the sensitive attributes.
[0004] Most federated recommender systems in related technologies typically focus only on the fairness of the group, that is, federated recommender systems usually only focus on a single sensitive attribute in the recommendation task, while ignoring the personalized needs of users. Summary of the Invention
[0005] In view of this, this application provides a recommendation method, apparatus, device, and storage medium based on federated learning to improve the fairness of recommendation systems.
[0006] In a first aspect, embodiments of this application provide a recommendation method based on federated learning, applied to a server, the method comprising:
[0007] Receive the target attributes uploaded by the target object;
[0008] The target objects are grouped based on the target attributes to obtain at least one group;
[0009] For each group: group the target objects based on the attribute values of the target attribute to obtain at least one subgroup;
[0010] For each subgroup, the model parameter set corresponding to the subgroup is sent to each target object in the subgroup; so that the target object trains a local model based on the received model parameter set; the local model is used to perform recommendation operations.
[0011] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round, and the method further includes:
[0012] Receive the first local parameter uploaded by each target object;
[0013] Receive the model difference sent by each target object;
[0014] The second local parameter is obtained based on the first local parameter corresponding to each target object;
[0015] The second local parameter, the first local parameter corresponding to each target object, and the model difference corresponding to each target object are aggregated to obtain the global model update parameter;
[0016] The stored global model update parameters from the previous round are updated using the global model update parameters.
[0017] In some possible embodiments, the model parameter set includes: the subgroup model update parameters from the previous round; after receiving the model difference sent by each target object, the method further includes:
[0018] For each subgroup;
[0019] Subgroup parameters are constructed based on the local data corresponding to each target object in the subgroup;
[0020] The second local parameter, the subgroup parameter, and the model difference are aggregated to obtain the subgroup model update parameter;
[0021] The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
[0022] In some possible embodiments, the model parameter set includes: the regularization term strength from the previous round; after constructing the subgroup parameters based on the local data corresponding to each target object in the subgroup, the method further includes:
[0023] Receive the local prediction error sent by each of the target objects;
[0024] The second local parameter, the subgroup parameter, and the local prediction error are aggregated to obtain the target regularization term strength;
[0025] The stored regularization term strength from the previous round is updated using the target regularization term strength.
[0026] In some possible embodiments, the model parameter set includes: the previously updated weights, and the method further includes:
[0027] Receive the fair metric value sent by each target object;
[0028] Based on the fairness metric value sent by each target object, the average fairness metric is obtained;
[0029] For each subgroup: obtain a group metric value based on the fairness metric value sent by each target object in the subgroup; obtain the target update weight corresponding to the subgroup based on the group metric value and the mean of the fairness metric; update the previous round update weight using the target update weight.
[0030] Secondly, embodiments of this application provide a recommendation method based on federated learning, applied to a target object, the method comprising:
[0031] Obtain the model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the target object belongs; the subgroup to which the target object belongs is determined based on the target attributes uploaded by the target object;
[0032] The optimization target value is determined based on the model parameter set;
[0033] The local model is trained based on the optimization target value to obtain the trained local model;
[0034] The recommended operation is performed using the trained local model.
[0035] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round and subgroup model update parameters from the previous round. Determining the optimization target value based on the model parameter set includes:
[0036] Obtain the initial model parameters from the previous round;
[0037] Based on the initial model parameters of the previous round and the subgroup model update parameters of the previous round, the local model parameters of the local model are obtained.
[0038] Based on the initial model parameters of the previous round and the global model update parameters of the previous round, the global model parameters of the target object are obtained.
[0039] The optimization target value is obtained based on the training dataset corresponding to the target object, the local model parameters, and the global model parameters.
[0040] In some possible embodiments, the model parameter set includes: the regularization term strength from the previous round; and the process of obtaining the optimization target value based on the training dataset corresponding to the target object, the local model parameters, and the global model parameters includes:
[0041] Based on the training dataset, determine the interaction records and the amount of interaction data corresponding to the target object;
[0042] Based on the interaction records, the amount of interaction data, the strength of the regularization term in the previous round, the local model parameters, the global model parameters, and the preset loss function, the optimization target value is obtained.
[0043] In some possible embodiments, after obtaining the optimized target value, the method further includes:
[0044] Based on the training dataset, determine the interaction records corresponding to the target object;
[0045] The local loss value is obtained based on the interaction record, the loss function, and the local model parameters;
[0046] Based on the interaction record, the loss function, and the global model parameters, the global loss value is obtained;
[0047] Obtain the validation dataset;
[0048] Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained;
[0049] The local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
[0050] In some possible embodiments, training the local model based on the optimization target value to obtain the trained local model includes:
[0051] Based on the updated weights from the previous round and the preset initial values for the next round, the target training round is obtained;
[0052] The local model is trained using the training dataset, the target training rounds, and the optimization target value to obtain the trained local model and the current model parameters of the local model.
[0053] In some possible embodiments, after obtaining the optimized target value, the method further includes:
[0054] The model difference is obtained based on the current model parameters and the local model parameters;
[0055] The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
[0056] In some possible embodiments, after obtaining the current model parameters of the local model, the method further includes:
[0057] Obtain the validation dataset;
[0058] Based on the training dataset, determine the interaction records corresponding to the target object;
[0059] The accuracy is obtained based on the interaction record, the current model parameters, and the preset accuracy function;
[0060] Based on the accuracy and the validation dataset, a fairness metric is obtained;
[0061] The fairness metric is uploaded to the server so that the server updates the weights from the previous round based on the fairness metric.
[0062] Thirdly, embodiments of this application provide a recommendation apparatus based on federated learning, applied to a server, the apparatus comprising:
[0063] The receiving module is used to receive the target attributes uploaded by the target object.
[0064] The first grouping module is used to group the target objects based on the target attributes to obtain at least one group;
[0065] The second grouping module is used to group the target objects based on the attribute values of the target attributes for each group, thereby obtaining at least one subgroup;
[0066] The parameter delivery module is used to send the model parameter set corresponding to each subgroup to each target object in the subgroup, so that the target object can train the local model according to the received model parameter set; the local model is used to perform recommendation operations.
[0067] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round, and the parameter distribution module is further used for:
[0068] Retrieve local data corresponding to each target object;
[0069] Receive the model difference sent by each target object;
[0070] The second local parameter is obtained based on the local data corresponding to each target object;
[0071] The second local parameter, the local data corresponding to each target object, and the model difference corresponding to each target object are aggregated to obtain the global model update parameter;
[0072] The stored global model update parameters from the previous round are updated using the global model update parameters.
[0073] In some possible embodiments, the model parameter set includes: the subgroup model update parameters from the previous round, and the parameter distribution module is further used for:
[0074] For each subgroup;
[0075] Subgroup parameters are constructed based on the local data corresponding to each target object in the subgroup;
[0076] The second local parameter, the subgroup parameter, and the model difference are aggregated to obtain the subgroup model update parameter;
[0077] The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
[0078] In some possible embodiments, the model parameter set includes: the regularization term strength of the previous round, and the parameter distribution module is further used for:
[0079] Receive the local prediction error sent by each of the target objects;
[0080] The second local parameter, the subgroup parameter, and the local prediction error are aggregated to obtain the target regularization term strength;
[0081] The stored regularization term strength from the previous round is updated using the target regularization term strength.
[0082] In some possible embodiments, the model parameter set includes: the weights updated in the previous round, and the parameter distribution module is further used for:
[0083] Receive the fair metric value sent by each target object;
[0084] Based on the fairness metric value sent by each target object, the average fairness metric is obtained;
[0085] For each subgroup: obtain a group metric value based on the fairness metric value sent by each target object in the subgroup; obtain the target update weight corresponding to the subgroup based on the group metric value and the mean of the fairness metric; update the previous round update weight using the target update weight.
[0086] Fourthly, embodiments of this application provide a recommendation apparatus based on federated learning, applied to a target object, the apparatus comprising:
[0087] The parameter receiving module is used to obtain a model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the target object belongs; the subgroup to which the target object belongs is determined based on the target attributes uploaded by the target object;
[0088] The optimization target value determination module is used to determine the optimization target value based on the model parameter set.
[0089] The training module is used to train the local model based on the optimization target value to obtain the trained local model.
[0090] The recommendation module is used to perform recommendation operations using the trained local model.
[0091] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round and subgroup model update parameters from the previous round. The optimization target value determination module is used for:
[0092] Obtain the initial model parameters from the previous round;
[0093] Based on the initial model parameters of the previous round and the subgroup model update parameters of the previous round, the local model parameters of the local model are obtained.
[0094] Based on the initial model parameters of the previous round and the global model update parameters of the previous round, the global model parameters of the target object are obtained.
[0095] The optimization target value is obtained based on the training dataset corresponding to the target object, the local model parameters, and the global model parameters.
[0096] In some possible embodiments, the model parameter set includes: the regularization term strength of the previous round; the optimization objective value determination module is used for:
[0097] Based on the training dataset, determine the interaction records and the amount of interaction data corresponding to the target object;
[0098] Based on the interaction records, the amount of interaction data, the strength of the regularization term in the previous round, the local model parameters, the global model parameters, and the preset loss function, the optimization target value is obtained.
[0099] In some possible embodiments, the optimization target value determination module is further configured to:
[0100] Based on the training dataset, determine the interaction records corresponding to the target object;
[0101] The local loss value is obtained based on the interaction record, the loss function, and the local model parameters;
[0102] Based on the interaction record, the loss function, and the global model parameters, the global loss value is obtained;
[0103] Obtain the validation dataset;
[0104] Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained;
[0105] The local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
[0106] In some possible embodiments, the training module is specifically used for:
[0107] Based on the updated weights from the previous round and the preset initial values for the next round, the target training round is obtained;
[0108] The local model is trained using the training dataset, the target training rounds, and the optimization target value to obtain the trained local model and the current model parameters of the local model.
[0109] In some possible embodiments, the optimization target value determination module is further configured to:
[0110] The model difference is obtained based on the current model parameters and the local model parameters;
[0111] The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
[0112] In some possible embodiments, the optimization target value determination module is further configured to:
[0113] Obtain the validation dataset;
[0114] Based on the training dataset, determine the interaction records corresponding to the target object;
[0115] The accuracy is obtained based on the interaction record, the current model parameters, and the preset accuracy function;
[0116] Based on the accuracy and the validation dataset, a fairness metric is obtained;
[0117] The fairness metric is uploaded to the server so that the server updates the weights from the previous round based on the fairness metric.
[0118] Fifthly, another embodiment of this application also provides an electronic device, including at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform any of the methods provided in the first aspect embodiment of this application.
[0119] In a sixth aspect, another embodiment of this application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for causing a computer to perform any of the methods provided in the first aspect embodiment of this application.
[0120] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description
[0121] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0122] Figure 1 A schematic diagram illustrating an application scenario of a recommendation method based on federated learning provided in this application embodiment;
[0123] Figure 2 A schematic diagram of the overall process when the execution subject of a recommendation method based on federated learning provided in this application is a server;
[0124] Figure 3 A schematic diagram illustrating the update process of the global model update parameters in the previous round of a recommendation method based on federated learning, provided for an embodiment of this application;
[0125] Figure 4 A schematic diagram illustrating the update process of the previous round of subgroup model update parameters in a federated learning-based recommendation method provided in this application embodiment;
[0126] Figure 5 A schematic diagram illustrating the update process of the regularization term strength in the previous round of a recommendation method based on federated learning, provided for an embodiment of this application;
[0127] Figure 6 A schematic diagram illustrating the update process of the previous round of update weights in a recommendation method based on federated learning provided for an embodiment of this application;
[0128] Figure 7 A flowchart illustrating the execution of a recommendation method based on federated learning, provided in an embodiment of this application, with the target object as the execution subject;
[0129] Figure 8A flowchart illustrating the process of determining the optimization target value based on the model parameter set in a recommendation method based on federated learning, provided for an embodiment of this application;
[0130] Figure 9 A flowchart illustrating the determination of local prediction error using a federated learning-based recommendation method, provided for an embodiment of this application.
[0131] Figure 10 A flowchart illustrating the determination of model differences using a federated learning-based recommendation method, provided as an embodiment of this application.
[0132] Figure 11 A schematic diagram illustrating the process of determining a fairness metric using a federated learning-based recommendation method, provided for an embodiment of this application.
[0133] Figure 12 A schematic diagram of an apparatus for a recommendation method based on federated learning provided in an embodiment of this application;
[0134] Figure 13 A schematic diagram of another apparatus for a recommendation method based on federated learning provided in an embodiment of this application;
[0135] Figure 14 This is a schematic diagram of an electronic device based on a federated learning recommendation method provided in an embodiment of this application. Detailed Implementation
[0136] To better understand the technical solution of this application, the embodiments of this application will be described in detail below with reference to the accompanying drawings.
[0137] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.
[0138] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise.
[0139] It should be understood that the term "and / or" used in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. Additionally, the character " / " in this article generally indicates that the preceding and following related objects have an "or" relationship.
[0140] The inventors discovered that recommender systems can identify user preferences for different items from massive amounts of data, thus providing accurate and satisfactory recommendations. Centralized recommender systems require users to upload their local data to a central server or third party, which poses a risk of privacy breaches. To address this issue, federated recommender systems offer an effective solution, integrating federated learning into the recommendation process to provide users with potentially valuable services while protecting their privacy by keeping sensitive data locally rather than transmitting it to a central server.
[0141] Fairness ensures that federated recommender systems provide impartial recommendations to users, thereby improving the system's credibility. Fairness can be divided into two concepts: individual fairness and group fairness. Specifically, individual fairness requires treating similar individuals equally. Group fairness, as the most widely studied concept of fairness, aims to ensure that recommender performance is fair among the various groups defined by the sensitive attributes.
[0142] Most federated recommender systems in related technologies typically focus only on the fairness of the group, that is, federated recommender systems usually only focus on a single sensitive attribute in the recommendation task, while ignoring the personalized needs of users.
[0143] To address the aforementioned problems, embodiments of this application provide a recommendation method, apparatus, device, and storage medium based on federated learning to solve these issues. The inventive concept of this application can be summarized as follows: receiving target attributes uploaded by target objects; grouping target objects based on the target attributes to obtain at least one group; for each group: grouping target objects based on the attribute values of the target attributes to obtain at least one subgroup; for each subgroup, sending the model parameter set corresponding to the subgroup to each target object within the subgroup; enabling the target objects to train a global model and a local model based on the received model parameter set; the local model is used to perform recommendation operations.
[0144] In this embodiment, users can select their desired sensitive attributes, construct different groups based on different sensitive attributes, and construct subgroups based on different values in the groups. A corresponding set of model parameters is set for each subgroup, which can ensure that the trained local model is more accurate and can provide higher recommendation performance while ensuring fairness.
[0145] For ease of understanding, the following detailed description, in conjunction with the accompanying drawings, illustrates a recommendation method based on federated learning provided in an embodiment of this application:
[0146] like Figure 1 The diagram shown illustrates an application scenario of a recommendation method based on federated learning, as described in an embodiment of this application. The diagram includes: a server 10 and a target object 20; wherein:
[0147] Server 10 receives target attributes uploaded by target object 20; groups target object 20 based on target attributes to obtain at least one group; for each group: groups target object 20 based on attribute values of target attributes to obtain at least one subgroup; for each subgroup, sends the model parameter set corresponding to the subgroup to each target object 20 in the subgroup; target object 20 obtains the model parameter set from the server; target object 20 determines whether the local model has converged based on the model parameter set; if the local model has not converged, it trains the local model using the model parameter set to obtain the trained local model; and uses the trained local model for recommendation operations.
[0148] In this application, the target is a terminal device with recommendation function for user applications, including but not limited to: computers, laptops, mobile phones, tablets, and smartwatches.
[0149] The description in this application focuses on only a single server 10 and target object 20. However, those skilled in the art should understand that the illustrated server 10 and target object 20 are intended to illustrate the operation of the server 10 and target object 20 involved in the technical solution of this application, and do not imply any limitation on the number, type, or location of the server 10 and target object 20. It should be noted that adding additional modules to or removing individual modules from the illustrated environment will not change the underlying concept of the exemplary embodiments of this application.
[0150] It should be noted that the federated learning-based recommendation method proposed in this application is applicable not only to... Figure 1 The application scenarios shown are also applicable to any device with recommendation requirements.
[0151] First, we will explain a recommendation method based on federated learning, where the execution entity is the server. Figure 2 The diagram shown illustrates a flowchart of a federated learning-based recommendation method provided in this application, where the execution entity is a server.
[0152] In step 201: Receive the target attributes uploaded by the target object.
[0153] In this embodiment, considering that current fairness studies of federated recommendation systems pre-set a single sensitive attribute for all users, and users cannot choose their desired sensitive attribute based on their actual situation—for example, female users might prefer gender as a sensitive attribute, while older users tend to choose age—forcing all users to choose only one fixed sensitive attribute would significantly impact user motivation. Therefore, in this embodiment, users are given the opportunity to choose an attribute, and the user-selected attribute becomes the target attribute. Users can then select attributes they are interested in from the target object, which will upload the user-selected attribute to the server.
[0154] It should be noted that in this embodiment of the application, there is no limit to the number of target attributes selected by the user; that is, the user can select only one attribute or select multiple attributes at the same time.
[0155] For example: User 1 selects gender as the target attribute, and User 2 selects both gender and age as target attributes.
[0156] In step 202: Group the target objects based on the target attributes to obtain at least one group.
[0157] In this embodiment of the application, in order to ensure that each user can receive the same recommendation performance, after obtaining the target attributes, the target objects can be grouped according to the target attributes to obtain multiple groups, and then different groups can be processed to ensure fairness between groups.
[0158] In some possible embodiments, when grouping target objects based on target attributes, it can be specifically implemented as follows: target objects with the same target attributes are grouped together.
[0159] For example: Target object 1 uploads the target attribute as gender; Target object 2 uploads the target attribute as age; Target object 3 uploads the target attribute as age; Target object 4 uploads the target attribute as age; Target object 5 uploads the target attribute as gender; Target object 6 uploads the target attribute as gender; and Target object 7 uploads the target attribute as age. This results in two groups: Group 1 and Group 2. Group 1 includes Target object 1, Target object 5, and Target object 6; Group 2 includes Target object 2, Target object 3, Target object 4, and Target object 7.
[0160] For example: Target object 1 uploads the target attributes as gender and age; Target object 2 uploads the target attribute as age; Target object 3 uploads the target attribute as age; Target object 4 uploads the target attributes as gender and age; Target object 5 uploads the target attribute as gender; Target object 6 uploads the target attribute as gender; and Target object 7 uploads the target attribute as age. This results in three groups: Group 1, Group 2, and Group 3. Group 1 includes Target object 1 and Target object 4; Group 2 includes Target object 2, Target object 3, and Target object 7; and Group 3 includes Target object 5 and Target object 6.
[0161] In this embodiment of the application, the corresponding target objects can only be divided into a group if the target attributes are completely identical.
[0162] In step 203: For each group: group the target objects based on the attribute values of the target attributes to obtain at least one subgroup.
[0163] In this application embodiment, different users may make different choices for the same attribute. For example, for the gender attribute, some users have the attribute value of "female" while others have the attribute value of "male". Therefore, in order to further ensure that each user can enjoy the same recommendation performance, after obtaining the group, the target objects in the group can be further grouped according to the attribute value of the target object to obtain subgroups.
[0164] In some possible embodiments, grouping target objects within a group can be implemented by: grouping target objects with the same attribute value as a subgroup, or grouping target objects with attribute values within the same range as a subgroup.
[0165] In this embodiment, considering that some attributes have fewer selectable values, such as gender, while other attributes have more selectable values, such as age, users in the same age group may have similar needs. Therefore, an age range can be set, and target objects within the same age range can be treated as a subgroup.
[0166] For example: Group 1 is a group corresponding to the gender attribute, where attribute value 1 represents male and attribute value 0 represents female. Group 1 includes: Target Object 1, Target Object 2, Target Object 3, Target Object 4, and Target Object 5. Target Object 1 has an attribute value of 1, Target Object 2 has an attribute value of 0, Target Object 3 has an attribute value of 1, Target Object 4 has an attribute value of 1, and Target Object 5 has an attribute value of 0. Then Group 1 can be divided into two subgroups: Subgroup 1 and Subgroup 2. Subgroup 1 includes: Target Object 1, Target Object 3, and Target Object 4; Subgroup 2 includes: Target Object 2 and Target Object 5.
[0167] For example, Group 2 is a group corresponding to the age attribute, where attribute values 0-18 represent the first age group, 18-60 represent the second age group, and 60-100 represent the third age group. Group 2 includes: Target Object 1, Target Object 2, Target Object 3, Target Object 4, and Target Object 5. Target Object 1 has an attribute value of 12, Target Object 2 has an attribute value of 15, Target Object 3 has an attribute value of 22, Target Object 4 has an attribute value of 40, and Target Object 5 has an attribute value of 65. Therefore, Group 2 can be divided into three subgroups: Subgroup 1, Subgroup 2, and Subgroup 3. Subgroup 1 includes Target Object 1 and Target Object 2, Subgroup 2 includes Target Object 3 and Target Object 4, and Subgroup 3 includes Target Object 5.
[0168] For example, Group 3 is a group corresponding to gender and age. In gender, attribute value 1 represents male and attribute value 0 represents female. In age, attribute values 0-18 represent the first age group, 18-60 represent the second age group, and 60-100 represent the third age group. Group 3 includes: Target Object 1, Target Object 2, Target Object 3, Target Object 4, and Target Object 5. Target Object 1 has a gender attribute value of 1 and an age attribute value of 12; Target Object 2 has a gender attribute value of 0 and an age attribute value of 24; Target Object 3 has a gender attribute value of 1 and an age attribute value of 15; Target Object 4 has a gender attribute value of 0 and an age attribute value of 40; and Target Object 5 has a gender attribute value of 1 and an age attribute value of 45. Therefore, Group 3 can be divided into three subgroups: Subgroup 1, Subgroup 2, and Subgroup 3. Subgroup 1 includes Target Object 1 and Target Object 3; Subgroup 2 includes Target Object 2 and Target Object 4; and Subgroup 3 includes Target Object 5.
[0169] In step 204: For each subgroup, the model parameter set corresponding to the subgroup is sent to each target object in the subgroup; so that the target object can train the local model according to the received model parameter set; the local model is used to perform recommendation operations.
[0170] In this embodiment of the application, the steps performed for each subgroup are the same. The values of the parameters in the model parameter sets corresponding to different subgroups are different. Therefore, when distributing model parameters, it is necessary to determine the subgroup corresponding to each target object and distribute the model parameter set corresponding to that subgroup to the target object.
[0171] In some possible embodiments, in addition to sending the model parameter set to the target object, the server also needs to receive the data uploaded by each target object and update the model parameter set according to the data uploaded by the target object, thereby ensuring the timeliness and accuracy of the data when sending data to the target object again.
[0172] In some possible embodiments, the model parameter set includes: the global model update parameters from the previous round, which are used to determine whether the local model of the target object has converged; the global model update parameters from the previous round are the same for each subgroup; and the update process of the global model update parameters from the previous round can be implemented as follows: Figure 3 The steps shown are as follows:
[0173] In step 301: Receive the first local parameters uploaded by each target object.
[0174] In this embodiment of the application, the amount of local data for each target object is the first local parameter |D u | indicates.
[0175] In step 302: Receive the model difference sent by each target object.
[0176] In this embodiment, the model difference is determined by the target object and sent to the server. In this application, the following approach is adopted: express.
[0177] In step 303: the second local parameter is obtained based on the first local parameter uploaded for each target object.
[0178] The sum of the first local parameters corresponding to each target object is the second local parameter, which is represented by |D in this embodiment. U | indicates.
[0179] In step 304: the second local parameters, the first local parameters corresponding to each target object, and the model difference corresponding to each target object are aggregated to obtain the global model update parameters.
[0180] In this embodiment of the application, Formula 1 can be used to determine the global model update parameters, wherein:
[0181]
[0182] in, To update the parameters of the global model, |D u | is the first local parameter corresponding to the target object u, |D U | represents the second local parameter. This is the model difference corresponding to the target object u.
[0183] In step 305: the stored global model update parameters from the previous round are updated using the global model update parameters.
[0184] In this embodiment, if the current update is round t, then the previous round was round t-1, and the global model update parameters of the previous round are... Then adopt right Update.
[0185] In some possible embodiments, the model parameter set includes: the previous round of subgroup model update parameters, which are used to determine whether the local model of the target object has converged. The previous round of subgroup model update parameters may not be the same for each subgroup, but the update process is the same. For each subgroup, the update process of the previous round of subgroup model update parameters can be implemented as follows: Figure 4 The steps shown are as follows:
[0186] In step 401: Subgroup parameters are constructed based on the first local parameters corresponding to each target object in the subgroup.
[0187] The sum of the first local parameters corresponding to each target object within the subgroup is the subgroup parameter, which is adopted in this embodiment of the application as D. S express.
[0188] In step 402: The second local parameters, subgroup parameters, and model differences are aggregated to obtain the subgroup model update parameters.
[0189] In this embodiment of the application, Formula 2 can be used to determine the subpopulation model update parameters, wherein:
[0190]
[0191] in, Update parameters for the subpopulation model, |D u | is the first local parameter corresponding to the target object u, D S For subgroup parameters, This is the model difference corresponding to the target object u.
[0192] In step 403: The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
[0193] In this embodiment, if the current update is round t, then the previous round was round t-1, and the global model update parameters of the previous round are... Then adopt right Update.
[0194] In some possible embodiments, the model parameter set includes: the regularization term strength from the previous round, which is used to determine whether the local model for the target object has converged. The regularization term strength from the previous round may not be the same for each subgroup, but the update process is the same. For each subgroup, the update process for the regularization term strength from the previous round can be implemented as follows: Figure 5 The steps shown are as follows:
[0195] In step 501: Receive the local prediction error sent by each target object.
[0196] In this embodiment, the local prediction error is determined by the generalization performance of each target object locally based on the global model. This application employs... This is used to represent the local prediction error.
[0197] In step 502: The second local parameter, subgroup parameter, and local prediction error are aggregated to obtain the target regularization term strength.
[0198] In this embodiment of the application, Formula 3 can be used to determine the strength of the target regularization term for each subgroup, wherein:
[0199]
[0200] in, |D represents the strength of the target regularization term for the subgroup. u | is the first local parameter corresponding to the target object u, D S For subgroup parameters, The local prediction error is represented by τ, which is a preset value used to limit the error. The minimum value.
[0201] For example, τ is a positive number.
[0202] In step 503: Update the stored regularization term strength of the previous round using the target regularization term strength.
[0203] In this embodiment of the application, if the current update is the t-th round, then the previous round was the (t-1)-th round, and the regularization term strength of the previous round was... Then adopt right Update.
[0204] In some possible embodiments, the model parameter set includes: the previous round update weights, which are used to determine the training epoch of the local model for the target object. The previous round update weights for each subgroup are not necessarily the same, but the update process is the same. For each subgroup, the update process of the previous round update weights can be implemented as follows: Figure 6 The steps shown are as follows:
[0205] In step 601: Receive the fair metric value sent by each target object.
[0206] In this embodiment, the fairness metric is determined by the target object based on the current model parameters of the local model. In this application, the following approach is adopted: This indicates the fair metric value sent by the target object.
[0207] In step 602: the fair metric mean is obtained based on the fair metric value sent to each target object.
[0208] After receiving the fairness metric value for each target object, the average fairness metric can be obtained. In this embodiment, the following is adopted: It represents the mean, a fair measure.
[0209] In step 603: the subgroup metric value is obtained based on the fair metric value sent by each target object in the subgroup.
[0210] In this embodiment, the subgroup metric is the average of the fair metric values sent by each target object in the subgroup, using... This represents the subgroup metric.
[0211] In step 604: Based on the subgroup metric and the mean of the fairness metric, the target update weight corresponding to the subgroup is obtained.
[0212] In this embodiment of the application, Formula 4 can be used to determine the target update weight for each subgroup, wherein:
[0213]
[0214] in, Update the weights for the target of the subgroup. To fairly measure the mean, This is a metric for the subgroup.
[0215] In step 605: the target update weight is used to update the previous round update weight.
[0216] In this embodiment of the application, if the current update is the t-th round, then the previous round was the t-1 round, and the update weight of the previous round is... Then adopt right Update.
[0217] In summary, the model parameter set corresponding to each subgroup includes: the global model update parameters of the previous round, the subgroup model update parameters of the previous round, the regularization term strength of the previous round, and the update weights of the previous round.
[0218] The following describes a recommendation method based on federated learning when the execution subject is the target object. Figure 7 As shown, where:
[0219] In step 701: Obtain the initial model parameters from the previous round.
[0220] In this embodiment, the initial model parameters from the previous round are obtained by the target object from the server. After each target object completes training its local model, it uploads the current local model parameters to the server. The server then updates the stored initial model parameters from the previous round based on the received local model parameters. For example, using... This represents the initial model parameters from the previous round.
[0221] In step 702: Obtain the model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the target object belongs; the subgroup to which the target object belongs is determined based on the target attributes uploaded by the target object.
[0222] In this embodiment of the application, in order to ensure that the trained local model is more accurate, the obtained model parameter set is constructed by the server according to the subgroup to which the target object belongs.
[0223] In step 703: Determine the optimization target value based on the model parameter set.
[0224] In some possible embodiments, the model parameter set includes: the initial model parameters from the previous round, the global model update parameters from the previous round, and the subgroup model update parameters from the previous round. The optimization target value is determined based on the model parameter set, and can be specifically implemented as follows: Figure 8 The steps shown are as follows:
[0225] In step 801: Based on the initial model parameters from the previous round and the subgroup model update parameters from the previous round, the local model parameters of the local model are obtained.
[0226] In this embodiment of the application, the initial model parameters of the previous round are used This indicates that the parameters of the previous subgroup model were updated using... express.
[0227] In this embodiment of the application, formula 5 can be used to obtain the local model parameters of the local model, wherein:
[0228]
[0229] in, These are the local model parameters for the local model. These are the initial model parameters from the previous round. Update the parameters for the subpopulation model.
[0230] It is important to know that the local and global models of all target objects in this application are models of the same dimension, so addition and subtraction operations can be performed directly.
[0231] In step 802: Based on the initial model parameters from the previous round and the global model update parameters from the previous round, the global model parameters of the target object are obtained.
[0232] In this embodiment of the application, the parameters of the previous round of global model update are used This means that the global model parameters can be obtained using Formula 6, where:
[0233]
[0234] in, These are the global model parameters for the global model. These are the initial model parameters from the previous round. Update the parameters for the global model from the previous round.
[0235] In step 803: Based on the training dataset, local model parameters, and global model parameters corresponding to the target object, the optimization target value is obtained.
[0236] In some possible embodiments, in order to prevent model overfitting, the regularization strength of the previous round is also required when calculating the optimization objective. Therefore, the optimization objective is obtained based on the training dataset corresponding to the target object, the local model parameters, and the global model parameters. Specifically, it can be implemented as follows: determine the interaction records and interaction data volume corresponding to the target object based on the training dataset; obtain the optimization objective value based on the interaction records, interaction data volume, the regularization strength of the previous round, the local model parameters, the global model parameters, and the preset loss function.
[0237] Here, the interaction record refers to the interaction records between the user and the item in the application scenario corresponding to the local model of the target object. For example, if the application scenario corresponding to the local model is a shopping platform, then the item is the item displayed on the shopping platform, including: item 1, item 2, ..., item n. If the user clicks on item 1, an interaction record is generated for item 1. Similarly, if the user clicks on other items, corresponding interaction records will be generated. Let r be the interaction record generated by the user for item i. u,i The amount of interaction data refers to the total number of user interaction records on the shopping platform, which can be denoted as... The interaction records and interaction data are stored together in the training dataset of the target object; therefore, the training dataset can be denoted as...
[0238] In this embodiment of the application, Formula 7 can be used to determine the optimization target value, wherein:
[0239]
[0240] in, To optimize the target value, r represents the amount of interactive data. u,i L is the record of user interactions with item i. u () represents the pre-set loss function, which represents the difference between the predicted value of user u for item i and the actual interaction record r. u,i The prediction error between them; For the training dataset, The strength of the regularization term in the previous round, where In Formula 7, we can substitute... These are the local model parameters for the local model. These are the global model parameters for the global model. It is the square of the 2-norm.
[0241] In this embodiment, after determining the optimization target value, in order to ensure the accuracy of subsequent calculations of the optimization target value, it is necessary to determine the local prediction error, model difference, and fairness metric based on the current relevant data of the local model. This allows the server to update the parameters in the model parameter set based on the local prediction error, model difference, and fairness metric. These are explained below:
[0242] In some possible embodiments, determining the local prediction error can be implemented as follows: Figure 9 The steps shown are as follows:
[0243] In step 901: Determine the interaction records corresponding to the target object based on the training dataset.
[0244] The specific implementation method of this step is the same as that of determining the interaction record in step 803, and will not be described again here.
[0245] In step 902: the local loss value is obtained based on the interaction record, loss function, and local model parameters.
[0246] In this application, the specific implementation of the loss function is not limited. The loss function in this application is preset and represents the predicted value of user u for item i and the actual interaction record r. u,i The prediction error between them, therefore the local loss value can be used express.
[0247] In step 903: Based on the interaction record, loss function, and global model parameters, the global loss value is obtained.
[0248] In this embodiment of the application, the global loss value can be used express.
[0249] In step 904: Obtain the verification dataset.
[0250] In this embodiment of the application, the verification dataset is pre-stored in the target object, and can be used... This represents the validation dataset.
[0251] In step 905: Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained.
[0252] In this embodiment of the application, Formula 8 can be used to determine the local prediction error, wherein:
[0253]
[0254] in, This is the local prediction error. To validate the dataset, This is the local loss value. Let r be the global loss value. u,i For user u's interaction records with item i, where In Formula 8, we can substitute... For local model parameters, These are global model parameters.
[0255] In step 906: the local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
[0256] After obtaining the local prediction error based on Formula 8, the local prediction error is uploaded to the server, which can then use it. Figure 5 The process shown is used to update the strength of the regularization term from the previous round.
[0257] In some possible embodiments, determining the model difference can be implemented as follows: Figure 10 The steps shown are as follows:
[0258] In step 1001: Obtain the current model parameters of the trained local model.
[0259] In execution Figure 10Before the steps shown, the local model needs to be trained to obtain the current model parameters. The training process is the same as step 703, and will not be described again here.
[0260] In step 1002: the model difference is obtained based on the current model parameters and the local model parameters.
[0261] In this embodiment of the application, formula 10 can be used to determine the model difference, wherein:
[0262]
[0263] in, For model differences, These are the current model parameters. These are the parameters for the local model.
[0264] In step 1003: The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
[0265] After obtaining the model difference based on Formula 9, the model difference is uploaded to the server, and the server can then use the method shown in Formula 1 to update the global model update parameters of the previous round.
[0266] In other possible embodiments, determining the fairness metric may be done using methods such as Figure 11 The steps shown are as follows:
[0267] In step 1101: Obtain the verification dataset.
[0268] In this embodiment of the application, the verification dataset is pre-stored locally by the target object, and can be used... To express.
[0269] In step 1102: Determine the interaction records corresponding to the target object based on the training dataset.
[0270] The specific implementation method of this step is the same as that of step 803, and will not be repeated here.
[0271] In step 1103: the accuracy is obtained based on the interaction record, the current model parameters, and the preset accuracy function.
[0272] In this application, no specific implementation of the accuracy function is limited; any function that can calculate accuracy is applicable to this application.
[0273] In step 1104: Based on the accuracy and the validation dataset, obtain the fairness metric.
[0274] In the implementation of this application, Formula 10 can be used to determine the fairness metric, wherein:
[0275]
[0276] in, For fair measurement, To validate the dataset, For accuracy, r is the current model parameter. u,i This refers to the user's interaction records with item i.
[0277] In step 1105: The fairness metric is uploaded to the server so that the server can update the weights from the previous round based on the fairness metric.
[0278] After obtaining the fairness metric based on Formula 11, the fairness metric is uploaded to the server, and the server can then use the method shown in Formula 4 to update the weights from the previous round.
[0279] In step 704: The local model is trained using the optimized target value to obtain the trained local model.
[0280] In this embodiment of the application, the current model parameters of the local model are adopted. This indicates that the current model parameters are obtained by training the local model using the optimization target value and the target object stored locally in the training dataset. Training the local model can be specifically implemented as follows: The local model is trained using the epoch and the target object stored locally in the training dataset. An epoch refers to the process where all samples in the training dataset are trained once during training. Specifically, this can be implemented as follows: First, obtain the updated weights and the corresponding target iteration number from the model parameter set on the server. Then, based on the updated weights, the corresponding target iteration number, and the preset initial value for the epoch, obtain the target iteration number (i.e., the epoch). The local model is then trained using the training dataset, the target iteration number, and the optimization target value to obtain the trained local model.
[0281] For example, Formula 11 can be used to determine the target number of iterations, where:
[0282]
[0283] in, The target number of iterations (i.e., epochs) The epoch is the one corresponding to the last local model training, retrieved from the server; ε0 is the preset initial value for the epoch. The weights were updated in the previous round.
[0284] After obtaining the target number of iterations, the local model is trained based on the locally stored training dataset and the optimization target value. After training, the model parameters corresponding to the local model are obtained, denoted as...
[0285] In this embodiment of the application, during the model training process, convergence conditions can be preset, and the convergence conditions can be set as optimization objectives for n consecutive rounds. The decrease in the value is less than the threshold δ. Therefore, the optimization target value calculated before this calculation can be obtained, and the convergence of the local model can be determined based on the relationship between the decrease in multiple optimization target values and the threshold.
[0286] For example: the optimization objective obtained in this calculation The value is 10, and the convergence condition can be set to optimize the objective for 5 consecutive rounds. If the decrease in the value is less than the threshold δ, the four previous optimization target values are obtained, in order: 10.6, 10.5, 10.2, and 10.1. Based on the five optimization target values, it can be determined that the decrease in the optimization target value is 0.6. If the threshold δ is determined to be 1, then the local model can be determined to have converged.
[0287] In step 705: the recommended operation is performed using the trained local model.
[0288] In this application, since the local model is trained based on the value of the optimization objective, and the value of the optimization objective is obtained from the model parameter set issued by the server, which is determined based on the attribute values uploaded by the user and the parameters generated during model training, the user can choose the desired attributes and attribute values based on their actual situation, thus ensuring that the user's customized attributes and attribute values are a prerequisite for user satisfaction with fairness. Furthermore, this application dynamically coordinates the relevant parameters of the local model and the global model, ensuring the recommendation performance of the federated recommendation system. During the local model training process, the weights are updated using epochs and the number of epochs of local training is calculated, ensuring the fairness of each local model.
[0289] Based on the same inventive concept, after introducing a recommendation method based on federated learning provided by the embodiments of this application, as follows... Figure 12 As shown, the following describes a federated learning-based recommendation device 1200 provided in an embodiment of this application. The device includes:
[0290] Receiver module 12001 is used to receive target attributes uploaded by the target object;
[0291] The first grouping module 12002 is used to group the target objects based on the target attributes to obtain at least one group;
[0292] The second grouping module 12003 is used to group the target objects based on the attribute values of the target attributes for each group, thereby obtaining at least one subgroup;
[0293] The parameter distribution module 12004 is used to send the model parameter set corresponding to each subgroup to each target object in the subgroup, so that the target object can train the local model according to the received model parameter set; the local model is used to perform recommendation operations.
[0294] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round, and the parameter distribution module 12004 is further used for:
[0295] Receive the first local parameter uploaded by each target object;
[0296] Receive the model difference sent by each target object;
[0297] The second local parameter is obtained based on the local data corresponding to each target object;
[0298] The second local parameter, the first local parameter corresponding to each target object, and the model difference corresponding to each target object are aggregated to obtain the global model update parameter;
[0299] The stored global model update parameters from the previous round are updated using the global model update parameters.
[0300] In some possible embodiments, the model parameter set includes: the subgroup model update parameters from the previous round, and the parameter distribution module 12004 is further used for:
[0301] For each subgroup;
[0302] Subgroup parameters are constructed based on the local data corresponding to each target object in the subgroup;
[0303] The second local parameter, the subgroup parameter, and the model difference are aggregated to obtain the subgroup model update parameter;
[0304] The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
[0305] In some possible embodiments, the model parameter set includes: the regularization term strength of the previous round, and the parameter distribution module 12004 is further used for:
[0306] Receive the local prediction error sent by each of the target objects;
[0307] The second local parameter, the subgroup parameter, and the local prediction error are aggregated to obtain the target regularization term strength;
[0308] The stored regularization term strength from the previous round is updated using the target regularization term strength.
[0309] In some possible embodiments, the model parameter set includes: the weights updated in the previous round, and the parameter distribution module 12004 is further used for:
[0310] Receive the fair metric value sent by each target object;
[0311] Based on the fairness metric value sent by each target object, the average fairness metric is obtained;
[0312] For each subgroup: obtain a group metric value based on the fairness metric value sent by each target object in the subgroup; obtain the target update weight corresponding to the subgroup based on the group metric value and the mean of the fairness metric; update the previous round update weight using the target update weight.
[0313] Based on the same inventive concept, such as Figure 13 As shown, the following describes a federated learning-based recommendation device 1300 provided in an embodiment of this application. The device includes:
[0314] The parameter receiving module 13001 is used to obtain a model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the target object belongs; the subgroup to which the target object belongs is determined based on the target attributes uploaded by the target object;
[0315] The optimization target value determination module 13002 is used to determine the optimization target value based on the model parameter set;
[0316] The training module 13003 is used to train the local model according to the optimization target value to obtain the trained local model;
[0317] The recommendation module 13004 is used to perform recommendation operations using the trained local model.
[0318] In some possible embodiments, the model parameter set includes: global model update parameters from the previous round and subgroup model update parameters from the previous round. The optimization target value determination module 13002 is used for:
[0319] Obtain the initial model parameters from the previous round;
[0320] Based on the initial model parameters of the previous round and the subgroup model update parameters of the previous round, the local model parameters of the local model are obtained.
[0321] Based on the initial model parameters of the previous round and the global model update parameters of the previous round, the global model parameters of the target object are obtained.
[0322] The optimization target value is obtained based on the training dataset corresponding to the target object, the local model parameters, and the global model parameters.
[0323] In some possible embodiments, the model parameter set includes: the regularization term strength of the previous round, and the optimization objective value determination module 13002 is used for:
[0324] Based on the training dataset, determine the interaction records and the amount of interaction data corresponding to the target object;
[0325] Based on the interaction records, the amount of interaction data, the strength of the regularization term in the previous round, the local model parameters, the global model parameters, and the preset loss function, the optimization target value is obtained.
[0326] In some possible embodiments, the optimization target value determination module 13002 is further configured to:
[0327] Based on the training dataset, determine the interaction records corresponding to the target object;
[0328] The local loss value is obtained based on the interaction record, the loss function, and the local model parameters;
[0329] Based on the interaction record, the loss function, and the global model parameters, the global loss value is obtained;
[0330] Obtain the validation dataset;
[0331] Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained;
[0332] The local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
[0333] In some possible embodiments, the training module 13003 is specifically used for:
[0334] Based on the updated weights from the previous round and the preset initial values for the next round, the target training round is obtained;
[0335] The local model is trained using the training dataset, the target training rounds, and the optimization target value to obtain the trained local model and the current model parameters of the local model.
[0336] In some possible embodiments, the optimization target value determination module 13002 is further configured to:
[0337] The model difference is obtained based on the current model parameters and the local model parameters;
[0338] The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
[0339] In some possible embodiments, the optimization target value determination module 13002 is further configured to:
[0340] Obtain the validation dataset;
[0341] Based on the training dataset, determine the interaction records corresponding to the target object;
[0342] The accuracy is obtained based on the interaction record, the current model parameters, and the preset accuracy function;
[0343] Based on the accuracy and the validation dataset, a fairness metric is obtained;
[0344] The fairness metric is uploaded to the server so that the server updates the weights from the previous round based on the fairness metric.
[0345] Corresponding to the above embodiments, this application also provides an electronic device. Figure 14 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. The electronic device 1400 may include a processor 1401, a memory 1402, and a communication unit 1403. These components communicate through one or more buses. Those skilled in the art will understand that the structure of the electronic device shown in the figure does not constitute a limitation on the embodiment of the present invention. It may be a bus topology or a star topology, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0346] The communication unit 1403 is used to establish a communication channel, enabling the electronic device to communicate with other devices. It receives user data from other devices or sends user data to other devices.
[0347] The processor 1401 serves as the control center of the electronic device, connecting various parts of the device via interfaces and lines. It executes software programs and / or modules stored in the memory 1402 and retrieves data stored in the memory to perform various functions and / or process data. The processor can be composed of integrated circuits (ICs), such as a single packaged IC or multiple packaged ICs with the same or different functions connected together. For example, the processor 1401 may consist only of a central processing unit (CPU). In this embodiment, the CPU may have a single processing core or include multiple processing cores.
[0348] The memory 1402 is used to store the execution instructions of the processor 1401. The memory 1402 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.
[0349] When the execution instructions in memory 1402 are executed by processor 1401, the electronic device 1400 is able to perform its functions. Figure 7 Some or all of the steps in the illustrated embodiments.
[0350] In a specific implementation, the present invention also provides a computer storage medium, wherein the computer storage medium may store a program, which, when executed, may include some or all of the steps of the calling method provided by the present invention. The storage medium may be a magnetic disk, optical disk, read-only memory (ROM), or random access memory (RAM), etc.
[0351] Those skilled in the art will clearly understand that the techniques in the embodiments of the present invention can be implemented using software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solutions in the embodiments of the present invention, or the parts that contribute to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in various embodiments or certain parts of the embodiments of the present invention.
[0352] The same or similar parts between the various embodiments in this specification can be referred to mutually. In particular, the device embodiments and terminal embodiments are basically similar to the method embodiments, so the description is relatively simple, and the relevant parts can be referred to the description in the method embodiments.
Claims
1. A recommendation method based on federated learning, characterized in that, Applied to a server, the method includes: Receive target attributes uploaded by the user based on the target object; the target attributes include: age and gender; the target object is a terminal device; The terminal devices are grouped based on the target attributes to obtain at least one group; For each group: the terminal devices are grouped based on the attribute values of the target attribute to obtain at least one subgroup; wherein, when the target attribute is gender, the attribute values corresponding to gender are the values corresponding to male and female, and when the target attribute is age, the attribute values corresponding to age are the values corresponding to the age input by the user. For each subgroup, the model parameter set corresponding to the subgroup is sent to each terminal device in the subgroup; so that the shopping platform in the terminal device can train the corresponding local model based on the received model parameter set; the local model is used to enable the shopping platform to recommend items to the user; The model parameter set also includes: the weights updated in the previous round, and the method further includes: Receive the fairness metric value sent by each terminal device; obtain the fair metric mean based on the fairness metric value sent by each terminal device; for each subgroup: obtain the group metric value based on the fairness metric value sent by each terminal device in the subgroup; obtain the target update weight corresponding to the subgroup based on the group metric value and the fair metric mean; update the previous round update weight using the target update weight; The terminal device trains the local model according to the following method: the terminal device obtains the target training round based on the updated weights from the previous round and the preset initial value of the round; the local model is trained using the training dataset corresponding to the terminal device, the target training round, and the optimization target value to obtain the trained local model and the current model parameters of the local model; the optimization target value is determined by the terminal device based on the model parameter set.
2. The method according to claim 1, characterized in that, The model parameter set includes: the global model update parameters from the previous round, and the method further includes: Receive the first local parameters uploaded by each terminal device; Receive the model difference values sent by each terminal device; The second local parameter is obtained based on the first local parameter corresponding to each terminal device; The second local parameter, the first local parameter corresponding to each terminal device, and the model difference corresponding to each terminal device are aggregated to obtain the global model update parameter; The stored global model update parameters from the previous round are updated using the global model update parameters.
3. The method according to claim 2, characterized in that, The model parameter set includes: the subgroup model update parameters from the previous round. After receiving the model difference sent by each terminal device, the method further includes: For each subgroup; Subgroup parameters are constructed based on the local data corresponding to each terminal device in the subgroup; The second local parameter, the subgroup parameter, and the model difference are aggregated to obtain the subgroup model update parameter; The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
4. The method according to claim 2, characterized in that, The model parameter set also includes: the strength of the regularization term from the previous round, and the method further includes: Receive the local prediction error sent by each of the terminal devices; construct subgroup parameters for each subgroup based on the local data corresponding to each terminal device in the subgroup; perform aggregation processing on the second local parameters, the subgroup parameters, and the local prediction error to obtain the target regularization term strength; update the stored regularization term strength of the previous round using the target regularization term strength.
5. A recommendation method based on federated learning, characterized in that, Applied to a terminal device, the method includes: Obtain the model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the terminal device belongs; the subgroup to which the terminal device belongs is determined based on the target attributes uploaded by the target object; the target attributes include: age and gender; the target object is the terminal device; The optimization target value is determined based on the model parameter set; The local model corresponding to the shopping platform is trained based on the optimization target value to obtain the trained local model; The trained local model is used to recommend items to the user; The model parameter set includes: global model update parameters from the previous round, subgroup model update parameters from the previous round, regularization term strength from the previous round, and update weights from the previous round. The regularization term strength from the previous round is used to determine whether the local model of the target object has converged. The update weights from the previous round are used to determine the training round of the local model of the target object. The target object is a terminal device, and the terminal device contains a shopping platform. The update weights from the previous round are obtained by the server according to the following method: based on the fairness metric value sent by each terminal device; based on the fairness metric value sent by each terminal device, the mean fairness metric is obtained; for each subgroup: based on the fairness metric value sent by each terminal device in the subgroup, the group metric value is obtained; based on the group metric value and the mean fairness metric value, the target update weights corresponding to the subgroup are obtained; the target update weights are used to update the update weights from the previous round. The step of training the local model corresponding to the shopping platform according to the optimization target value to obtain the trained local model includes: obtaining the target training round according to the weights updated in the previous round and the preset initial value of the round; training the local model using the training dataset corresponding to the terminal device, the target training round and the optimization target value to obtain the trained local model and the current model parameters of the local model; Obtain the validation dataset; Based on the training dataset, determine the interaction records corresponding to the terminal device; The accuracy is obtained based on the interaction record, the current model parameters, and the preset accuracy function; Based on the accuracy and the validation dataset, a fairness metric is obtained.
6. The method according to claim 5, characterized in that, Determining the optimization target value based on the model parameter set includes: Obtain the initial model parameters from the previous round; based on the initial model parameters from the previous round and the subgroup model update parameters from the previous round, obtain the local model parameters of the local model; Based on the initial model parameters of the previous round and the global model update parameters of the previous round, the global model parameters of the terminal device are obtained. The optimization target value is obtained based on the training dataset corresponding to the terminal device, the local model parameters, and the global model parameters.
7. The method according to claim 6, characterized in that, The process of obtaining the optimization target value based on the training dataset corresponding to the terminal device, the local model parameters, and the global model parameters includes: Based on the training dataset, determine the interaction records and interaction data volume corresponding to the terminal device; Based on the interaction records, the amount of interaction data, the strength of the regularization term in the previous round, the local model parameters, the global model parameters, and the preset loss function, the optimization target value is obtained.
8. The method according to claim 6, characterized in that, After obtaining the optimized target value, the method further includes: Based on the training dataset, determine the interaction records corresponding to the terminal device; The local loss value is obtained based on the interaction record, the loss function, and the local model parameters; Based on the interaction record, the loss function, and the global model parameters, the global loss value is obtained; Obtain the validation dataset; Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained; The local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
9. The method according to claim 6, characterized in that, After obtaining the optimized target value, the method further includes: The model difference is obtained based on the current model parameters and the local model parameters; The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
10. A recommendation device based on federated learning, characterized in that, Applied to a server, the device includes: A receiving module is used to receive target attributes uploaded by a user based on a target object; the target attributes include: age and gender; the target object is a terminal device. The first grouping module is used to group the terminal devices based on the target attribute to obtain at least one group; The second grouping module is used to group the terminal devices based on the attribute value of the target attribute for each group to obtain at least one subgroup; wherein, when the target attribute is gender, the attribute value corresponding to gender is the value corresponding to male and female, and when the target attribute is age, the attribute value corresponding to age is the value corresponding to the age input by the user. The parameter distribution module is used to send the model parameter set corresponding to each subgroup to each terminal device in the subgroup, so that the terminal device can train the local model according to the received model parameter set; the local model is used to enable the shopping platform to recommend items to users; The model parameter set includes: the previous round update weights. The parameter distribution module is further configured to: receive the fairness metric value sent by each terminal device; obtain the fairness metric mean based on the fairness metric value sent by each terminal device; for each subgroup: obtain the group metric value based on the fairness metric value sent by each terminal device in the subgroup; obtain the target update weight corresponding to the subgroup based on the group metric value and the fairness metric mean; and update the previous round update weights using the target update weights. The terminal device trains the local model according to the following method: the terminal device obtains the target training round based on the updated weights from the previous round and the preset initial value of the round; the local model is trained using the training dataset corresponding to the terminal device, the target training round, and the optimization target value to obtain the trained local model and the current model parameters of the local model; the optimization target value is determined by the terminal device based on the model parameter set.
11. The apparatus according to claim 10, characterized in that, The model parameter set includes: the global model update parameters from the previous round, and the parameter distribution module is also used for: Receive the first local parameters uploaded by each terminal device; Receive the model difference values sent by each terminal device; The second local parameter is obtained based on the first local parameter corresponding to each terminal device; The second local parameter, the first local parameter corresponding to each terminal device, and the model difference corresponding to each terminal device are aggregated to obtain the global model update parameter; The stored global model update parameters from the previous round are updated using the global model update parameters.
12. The apparatus according to claim 11, characterized in that, The model parameter set includes: the subgroup model update parameters from the previous round, and the parameter distribution module is also used for: For each subgroup; Subgroup parameters are constructed based on the local data corresponding to each terminal device in the subgroup; The second local parameter, the subgroup parameter, and the model difference are aggregated to obtain the subgroup model update parameter; The stored subpopulation model update parameters from the previous round are updated using the subpopulation model update parameters.
13. The apparatus according to claim 11, characterized in that, The model parameter set includes: the strength of the regularization term from the previous round, and the parameter distribution module is also used for: Receive the local prediction error sent by each of the terminal devices; For each subgroup, subgroup parameters are constructed based on local data corresponding to each terminal device in the subgroup; the second local parameters, the subgroup parameters, and the local prediction error are aggregated to obtain the target regularization term strength; the target regularization term strength is used to update the stored regularization term strength of the previous round.
14. A recommendation device based on federated learning, characterized in that, Applied to a terminal device, the device includes: A parameter receiving module is used to obtain a model parameter set from the server; the model parameter set is the model parameter set corresponding to the subgroup to which the terminal device belongs; the subgroup to which the terminal device belongs is determined based on the target attributes uploaded by the target object; the target attributes include: age and gender; the target object is the terminal device. The optimization target value determination module is used to determine the optimization target value based on the model parameter set. The training module is used to train the local model corresponding to the shopping platform based on the optimization target value, so as to obtain the trained local model. The recommendation module is used to recommend items to the user using the trained local model; The model parameter set includes: global model update parameters from the previous round, subgroup model update parameters from the previous round, regularization term strength from the previous round, and update weights from the previous round. The regularization term strength from the previous round is used to determine whether the local model of the target object has converged. The update weights from the previous round are used to determine the training round of the local model of the target object. The target object is a terminal device, and the terminal device contains a shopping platform. The update weights from the previous round are obtained by the server according to the following method: based on the fairness metric value sent by each terminal device; based on the fairness metric value sent by each terminal device, the mean fairness metric is obtained; for each subgroup: based on the fairness metric value sent by each terminal device in the subgroup, the group metric value is obtained; based on the group metric value and the mean fairness metric value, the target update weights corresponding to the subgroup are obtained; the target update weights are used to update the update weights from the previous round. The training module is specifically used to: obtain the target training round based on the updated weights of the previous round and the preset initial value of the round; train the local model using the training dataset corresponding to the terminal device, the target training round, and the optimization target value to obtain the trained local model and the current model parameters of the local model; The target value determination module is further configured to: acquire a validation dataset; determine the interaction record corresponding to the terminal device based on the training dataset; and obtain the accuracy based on the interaction record, the current model parameters, and a preset accuracy function.
15. The apparatus according to claim 14, characterized in that, The optimization target value determination module is used for: Obtain the initial model parameters from the previous round; Based on the initial model parameters of the previous round and the subgroup model update parameters of the previous round, the local model parameters of the local model are obtained. Based on the initial model parameters of the previous round and the global model update parameters of the previous round, the global model parameters of the terminal device are obtained. The optimization target value is obtained based on the training dataset corresponding to the terminal device, the local model parameters, and the global model parameters.
16. The apparatus according to claim 15, characterized in that, The optimization target value determination module is used for: Based on the training dataset, determine the interaction records and interaction data volume corresponding to the terminal device; Based on the interaction records, the amount of interaction data, the strength of the regularization term in the previous round, the local model parameters, the global model parameters, and the preset loss function, the optimization target value is obtained.
17. The apparatus according to claim 16, characterized in that, The optimization target value determination module is also used for: Based on the training dataset, determine the interaction records corresponding to the terminal device; The local loss value is obtained based on the interaction record, the loss function, and the local model parameters; Based on the interaction record, the loss function, and the global model parameters, the global loss value is obtained; Obtain the validation dataset; Based on the local loss value, the global loss value, and the validation dataset, the local prediction error is obtained; The local prediction error is uploaded to the server so that the server updates the regularization term strength of the previous round based on the local prediction error.
18. The apparatus according to claim 16, characterized in that, The optimization target value determination module is also used for: The model difference is obtained based on the current model parameters and the local model parameters; The model difference is uploaded to the server so that the server updates the global model update parameters of the previous round stored in the model parameters according to the model difference.
19. An electronic device, characterized in that, It includes a memory for storing computer program instructions and a processor for executing the program instructions, wherein when the computer program instructions are executed by the processor, the electronic device is triggered to perform the method of any one of claims 1-4 and 5-9.
20. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored program, wherein, when the program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1-4 and 5-9.
Citation Information
Patent Citations
Recommendation model training method, medium, electronic equipment and recommendation model
CN112184391A
Federal learning model training method and device, equipment and storage medium
CN115660115A