A Sequence Recommendation Method Based on Personalized Federated Technology
By employing personalized federated technology for preprocessing, hash indexing, and Bayesian training, combined with locality-sensitive hashing for data integration and model aggregation, the problem of model imbalance between and within domains in sequence recommendation systems is solved. This achieves privacy protection and efficient user preference modeling, thereby improving recommendation performance.
Patent Information
- Application Number
- CN202310023696.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-09
- Publication Date
- 2025-12-02
- Estimated Expiration
- 2043-01-09
AI Technical Summary
Existing privacy-preserving sequence recommendation methods suffer from imbalance between and within domains in federated learning, leading to reduced model effectiveness and easy leakage of user privacy data.
By employing personalized federated technology, through client-side local preprocessing, hash index construction, Bayesian training, and a multi-task learning framework, combined with locality-sensitive hashing for data integration and model aggregation, privacy-preserving user preference modeling is achieved.
While protecting user privacy, it solves the problem of model imbalance between and within domains, improves the scalability and portability of the recommendation system, reduces computational resource consumption, and improves recommendation performance.
Smart Images

Figure CN116089715B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a sequence recommendation method based on personalized federated technology. Background Technology
[0002] The primary task of sequence recommendation systems is to mine user behavior patterns through temporally related sequences of actions, modeling dynamic preferences and predicting the user's item choices at the next moment. However, because sequence recommendation systems could potentially use collected user data for malicious transactions, many users are reluctant to share their data due to concerns about privacy breaches. This can easily lead to serious problems such as "data silos" and "recommendation barriers." Therefore, privacy-preserving sequence recommendation systems have received significant attention and extensive research from both industry and academia.
[0003] Currently, existing privacy-preserving sequence recommendation methods mainly protect data by introducing cryptographic knowledge, such as homomorphic encryption algorithms and differential privacy technology. In the latest technical research, some researchers have used federated learning to protect the privacy of sequence recommendation systems. Although the federated architecture allows user data to remain local, such distributed data and architecture reduce the effectiveness of sequence recommendation models. Assuming that clients with certain attributes can be classified into a category, this is called a domain. The above problems are specifically reflected in: (1) Model imbalance between domains: A single global model cannot adapt to the sequence characteristics of all domains. This may be due to the different attributes of each domain, such as habitual bias caused by geographical factors. (2) Model imbalance within a domain: Different clients have different amounts of data. Clients with less data cannot effectively cope with complex sequence models, and are prone to model shift in the aggregation operation of the central server. Therefore, it is urgent to develop a new privacy-preserving sequence recommendation method to solve these problems existing in current sequence recommendation methods. Summary of the Invention
[0004] The purpose of this invention is to provide a sequence recommendation method based on personalized federated technology. This invention can solve the problems of inter-domain and intra-domain model imbalance caused by distributed data and clients, effectively modeling users' dynamic preferences while protecting privacy, and has the advantages of scalability, portability, and privacy protection.
[0005] The technical solution of this invention: a sequence recommendation method based on personalized federated technology, comprising the following steps:
[0006] Step S1: Each client maintains its data on its local device and preprocesses its own interaction data and the attribute values of interaction items to remove interference items and abnormal values from the data; at the same time, it ensures that the data structures of all clients are aligned in the distributed framework.
[0007] Step S2: The client constructs a hash index on its local device using its own interactive data and forms a hash storage table; after the hash index is constructed, the client uploads it to the central server;
[0008] Step S3: The client performs augmentation operations on the training data on the local device based on the Bayesian training strategy to obtain augmented data, which is used for self-supervised learning of the local sequence model to enhance the representation ability of the local sequence model.
[0009] Step S4: Combining the hash index constructed in step S2 with the augmented data obtained in step S3, the client builds a local sequence recommendation framework based on multi-task on the local device (the local sequence recommendation framework can effectively integrate general sequence encoders to form a local sequence model), and collaborates with the central server to perform distributed training on the local sequence model until the local sequence model converges.
[0010] First, the client initializes and pre-trains the local sequence model; second, it uploads the local sequence model to the central server for personalized aggregation based on locality-sensitive hashing; then, the central server sends a specific aggregated model to the client, and after receiving the aggregated model, the client performs the next round of model training until the local sequence model converges.
[0011] Step S5: The client obtains the parameters of the user's embedded network, combines them with the output of the converged local sequence model, obtains the preference prediction result for the next time step, and completes the personalized recommendation for the client.
[0012] The prediction results exist only on the client devices. The central server does not access any training data sources or recommendation results, and the clients do not communicate with each other.
[0013] In the aforementioned sequence recommendation method based on personalized federated technology, the overall direction of preprocessing in step S1 is to organize and record the client's access to all items and represent it using a vector matrix;
[0014] Preprocessing specifically includes cleaning up outliers and missing values in the interactive data (ensuring data availability), archiving project attributes (such as project type) for projects accessed by the client, archiving user attributes (such as location, age, occupation, hobbies, etc.), and performing data structure alignment operations on project attributes and user attributes on all clients, representing the aligned project attributes and user attributes through vector matrices.
[0015] In the aforementioned sequence recommendation method based on personalized federated technology, step 2 includes the following sub-steps:
[0016] Sub-step S2.1: The client converts historical interaction data into binary feature vectors, downloads relevant hash data from the central server, and constructs a set of hash function clusters on the local device based on the data downloaded from the central server;
[0017] Sub-step S2.2: Combine the binary feature vector with the hash function cluster to generate a hash index specific to the client and upload it to the central server;
[0018] Sub-step S2.3: The central server receives the hash indexes from each client to build a hash storage table.
[0019] In the aforementioned sequence recommendation method based on personalized federated technology, step 3 includes the following sub-steps:
[0020] Sub-step S3.1: Construct a sub-sequence set to generate training data, each training data set containing a positive and negative sample sequence pair, the training data being used for Bayesian model optimization;
[0021] Sub-step S3.2: Construct enhanced positive samples based on positive samples in the training data;
[0022] Sub-step S3.3: Construct enhanced negative samples based on negative samples in the training data;
[0023] Sub-step S3.4: Pair up the enhanced positive samples and the enhanced negative samples to form augmented data for self-supervised learning of the Bayesian model.
[0024] In the aforementioned sequence recommendation method based on personalized federated technology, sub-step S3.2 constructs enhanced positive samples based on the correlation between items and the length of the positive sample sequence, and determines the degree of correlation between items according to the rule of calculating the area of a triangle by its sides.
[0025] In the aforementioned sequence recommendation method based on personalized federated technology, sub-step S3.3 involves constructing enhanced negative samples based on the length of the negative sample sequence.
[0026] In the aforementioned sequence recommendation method based on personalized federated technology, step 4 includes the following sub-steps:
[0027] Sub-step S4.1: Construct a sequence recommendation framework based on multi-task learning. The sequence recommendation framework has scalability and portability. The sequence recommendation framework consists of a user attribute embedding network, a local contrastive learning mechanism, an item embedding network, and a general sequence encoder. After the general sequence encoder is selected as needed, a local sequence model is formed.
[0028] Sub-step S4.2: Initially update the local sequence model by receiving the initialization parameters from the central server, train the local sequence model locally using training data and augmentation data, and upload the trained local sequence model to the central server to wait for the central server to transmit the personalized aggregated model.
[0029] Sub-step S4.3: The central server receives local sequence models from all clients, retrieves similar users for each client by querying the global hash storage table, and then performs personalized aggregation on all local sequence models based on the query results, so that a specific client corresponds to a specific aggregated model, and sends the aggregated model to the corresponding client.
[0030] Sub-step S4.4: The client receives the aggregated model and continues to update the aggregated model with training data and augmentation data for the next round until the local sequence model converges.
[0031] In the aforementioned sequence recommendation method based on personalized federated technology, step 5 includes the following sub-steps:
[0032] Sub-step S5.1: Extract the parameters of the user attribute embedding network and use them as the feature representation of the user attributes. Perform an inner product operation between the parameters and the output vector of the local sequence model.
[0033] Sub-step S5.2: Use the inner product result as the recommendation prediction result to predict the user's preferences at the next moment; the prediction result is only kept on the client's local device and is not shared with the central server in order to protect user privacy;
[0034] Sub-step S5.3: The recommender system maintains a global hash table online in real time; however, when a client exits the federated training framework, the recommender system will no longer retain any records of model sending to that client.
[0035] Compared with existing technologies, the beneficial effects of this invention are reflected in the following: Personalized federation in this invention is manifested in the collaborative training of sequence encoders by users and a central server. The central server generates specific models based on the data distribution characteristics of the client, the model training status, and the client's location. Without acquiring user privacy data, commonly used sequence encoders can be effectively integrated into a federated distributed framework. Therefore, the federated sequence recommendation system based on this invention has scalability, portability, and privacy protection.
[0036] Specifically, this invention introduces Locality Sensitive Hashing (LSH) to design a personalized federated aggregation strategy. This strategy alleviates the problem that a single global model cannot adapt to sequence features across all domains. Furthermore, a data augmentation method based on Bayesian training is designed to improve the contrastive learning strategy, thereby enhancing the representational capabilities of the local sequence encoder. Consequently, clients with limited training data can effectively handle complex sequence models, and in distributed scenarios, they can effectively participate in the model training process of other clients. Therefore, the federated sequence technology incorporating personalization and representation enhancement not only adapts to commonly used encoders, enabling general sequence models to effectively model users' dynamic preferences while protecting privacy, but also improves recommendation performance by predicting users' item preferences at the next moment without consuming significant computational resources. Attached Figure Description
[0037] Figure 1 This is a flowchart illustrating an embodiment of a sequence recommendation method based on personalized federated technology provided by the present invention.
[0038] Figure 2 This is a schematic diagram of the overall framework of the local multi-task sequence model and its distributed training.
[0039] Figure 3 This is an example diagram of the data augmentation method involved in the sequence recommendation method based on personalized federation technology provided by this invention. Detailed Implementation
[0040] The present invention will be further described below with reference to the accompanying drawings and embodiments, but this should not be construed as limiting the present invention.
[0041] Example: In this invention, the data preprocessing operations performed by the client can be selected according to specific scenario requirements. For example, in a POI recommendation scenario, preprocessing of the distance attribute of the POI can be selected. The overall framework of personalized federated technology is as follows: Figure 2 As shown in the diagram, this framework diagram illustrates the details of all the methods involved and their sequential relationships.
[0042] In this embodiment, a sequence recommendation method based on personalized federated technology includes: Figure 1 Steps S1-S5:
[0043] Step S1: Each client maintains its data on its local device and preprocesses its own interaction data and the attribute values of the interaction items;
[0044] Preprocessing includes cleaning up outliers and missing values in the interactive data, archiving project attributes for items accessed by the client, and archiving user attributes; and performing data structure alignment operations on project attributes and user attributes on all clients, representing the aligned project attributes and user attributes through vector matrices.
[0045] Step S2: The client converts historical interaction data into binary feature vectors and constructs a set of hash function families according to the assistance instructions of the central server; it then combines the binary feature vectors and the hash function family to generate a specific hash index and uploads it to the central server to construct a global hash storage table. The entire implementation of step S2 specifically includes the following sub-steps S2.1-S2.3:
[0046] S2.1: Assuming there are n projects, for a single user u in federated learning, all their interaction data can be represented as an n-dimensional vector R. u =(v1,v2,…,v i ,…,v n );v i This represents the interaction status of user u; if v i =0 means user u did not access item i; otherwise, v i =1 means that user u has visited item i.
[0047] S2.2: The client obtains a random vector Q = (q1, q2, ... q i ,…,q n ), where q i For random numbers in [-1, 1], the hash function is defined as follows (1):
[0048]
[0049] Among them, symbols This represents the dot product operation between vectors.
[0050] Based on formula (1), the hash index is constructed as: Dex u =[G1,G2,..,G i ,…,G K ], each G i From {g1(R u ),g2(R u ),…,g r (R u It consists of )}, where G i This represents the hash value generated by a hash bucket. K such hash values together form the hash index Dex. u .
[0051] S2.3: Dex uIt is uploaded to the central server and becomes part of the global hash storage table.
[0052] Step S3: The client generates augmented positive and negative sample pairs by training positive and negative sample pairs. The training data is used for Bayesian model optimization, and the augmented data is used for self-supervised learning of the Bayesian model. During data augmentation, the correlation between items and the sequence length of the training samples are fully considered. An example of data augmentation is shown below. Figure 3 As shown in the figure, the training sample length l is set to 5. The entire implementation of step S3 specifically includes the following sub-steps S3.1-S3.4:
[0053] S3.1: To achieve BPR optimization, the client constructs a set of subsequences to generate training samples. For example, when l=5, the subsequences [v1,v2,v3,v4,v5] and [v1,v2,v3,v4,v6] are regarded as a pair of positive and negative sequences, i.e., training samples, where v5 and v6 are regarded as positive and negative labels, respectively.
[0054] S3.2: Enhance positive samples: Using positive samples S p =[v1,v2,…,v i ,…,v lp For example, v lp Represents positive labels; randomly selects v i ∈S p Use related items Replace v i Generate enhanced positive samples Among them, v i ≠v lp , Refers to v i Related items (related items); v i and The degree of correlation between the two points of interest is determined by their geographical attributes; specifically, this invention fully considers the positive user sample S. p Chinese v i The previous access sequence v i-1 and the next access sequence v i+1 Calculate in this way With v i The degree of correlation; firstly, as shown in formula (2), based on v i Select a set of POIs within a certain geographical range.
[0055]
[0056] Where α is a constant representing a threshold for geographic distance; dis() represents the geographic distance value. Then it means that it is related to v iThe set of all POIs that are within a distance of α.
[0057] Next, based on the idea of calculating the area of a triangle using its side length, we calculate v using the following formulas (3)-(7). i and Relevance:
[0058] a = dis(v i+1 ,v i-1 (3)
[0059] b1 = dis(v i ,v i-1 ),c1=dis(v i ,v i+1 (4)
[0060]
[0061]
[0062]
[0063] Here, dis() represents distance, which can be cosine distance or actual physical distance; a represents v. i+1 With v i-1 The distance between them, b1 represents the distance between v. i With v i-1 The distance between them, c1 represents the distance between v. i and v i+1 The distance between them, b2 represents With v i-1 The distance between them, c2 represents With v i+1 The distances between the three segments, where p1 and p2 represent the average lengths of the three distances. It can be seen as v i and Relevance.
[0064] In addition, in the operation of enhancing positive samples, the number of replacement terms generated is determined by the sequence length l, and the specific calculation is shown in formula (8).
[0065] S3.3: Enhance negative samples: using negative samples S n =[v1,v2,…,v i ,…,v ln For example, v ln Represents the negative label item; select the replacement item v i (≠v ln Randomly select points of interest v′ that the user has not interacted with. i As the replacement value, sequence S is generated. n=[v1,v2,…,v′] i ,…,v ln The number of replacements follows the calculation rule of formula (9):
[0066]
[0067] Where, fre pos fre represents the number of replacements in the augmented positive samples. neg This indicates the number of replacements in the enhanced negative sample.
[0068] S3.4: Pair up positive samples and negative samples to form augmented data for self-supervised learning of the Bayesian model.
[0069] Step S4: The client constructs a sequence recommendation framework based on multi-task learning. This framework consists of a user attribute embedding network, a local contrastive learning mechanism, an item embedding network, and a general sequence encoder. After the sequence encoder is selected as needed, a local sequence model is formed. Subsequently, the central server, in conjunction with a global hash table and the client, completes the personalized training of the local sequence model. The implementation of the entire step S4 specifically includes the following sub-steps S4.1-S4.4:
[0070] S4.1: Client u represents its own attributes as a one-dimensional vector U through a neural embedding network. u The client constructs a local multi-task learning model in conjunction with the required sequence encoder. The multi-tasks include recommendation and contrastive learning tasks; for the recommendation task, given a user u, a sequence encoder f(·), an interest point embedding V, and the user's sequence Seq at timestamp t... u,t Using temporal embedding T and contextual features I, the hidden layer h of the sequence encoder can be obtained. t h t It can be expressed by the following formula (10):
[0071] h t =f(V,T,I,Seq) u,t ;θ s (10)
[0072] Where, θ s The set of parameters representing the encoder.
[0073] According to the user-embedded representation U u Assess user u's preference for item j at timestamp t. As shown in formula (11) below:
[0074]
[0075] Next, pairwise Bayesian personalized ranking (BPR) is applied to learn the parameters θ of the sequence encoder and the embedding network. r Loss function for recommendation tasks The following formula (12):
[0076]
[0077] Here, σ(·) represents the sigmod() function, and (j,k) is a pair of positive and negative labels in the training subsequence.
[0078] S4.2: For the contrastive learning task, the sample representation formulas (13) and (14) will be enhanced:
[0079]
[0080]
[0081] Among them, Seq aug-p This refers to boosting positive samples, Seq aug-n This refers to enhancing negative samples; They are considered as a single positive sample pair, while the remaining 2N are... Considered a negative example; sequence pairs The encoded features are Its corresponding negative example The encoded feature is h′ i The multi-class cross-entropy loss function (NCE) is used to learn the comparison task, as shown in the following formula (15):
[0082]
[0083] Wherein, τ is the temperature coefficient, and an optimal constant value is obtained after parameter adjustment experiments; It is a sequence pair The coding features, It is a sequence pair The encoding features; sim() represents calculating the similarity; This represents the loss function for the comparison task.
[0084] Furthermore, the recommendation task and the contrastive learning task are combined to obtain the final multi-task sequence model. The optimization loss of the multi-task sequence model is expressed as follows: (16)
[0085]
[0086] Here, λ is a constant coefficient used to control the proportion of the comparison task. It is the loss function for recommendation tasks. It is the loss function for the comparison task. This is the final multi-task loss function, and the client performs local model training according to the above operations.
[0087] S4.3: Client u will transfer the local model Θ u ={W u Uploaded to the central server, W u Represents Θ u The central server queries the global hash storage table to find other users in the same hash bucket as u, based on the given parameters. Its definition is Next, the central server generates a specific personalized model for u, expressed as follows: (17)
[0088]
[0089] Where Avg(·) refers to the averaging operation, α is a constant used to control the degree of influence of similar and dissimilar users on the local model of user u, and W u W refers to the local model of similar users of user u. z This refers to the local model of dissimilar users of user u, where ln represents the number of users similar to user u. Refers to the personalized local model generated for user u.
[0090] S4.4: The central server will specify Send to u, u to Perform a new round of training and repeat the above process until the model converges.
[0091] Step S5: According to U u and sequence model output h t To obtain the preference prediction for the next moment.
[0092] The entire implementation of step S5 specifically includes sub-steps S5.1-S5.3:
[0093] S5.1: For the already trained U u and h t Perform inner product operations.
[0094] S5.2: Predict user preferences for the next time step based on the inner product result. All recommendation results are only stored on the client's local device and are not shared with the central server.
[0095] S5.3: The recommendation system maintains a global hash storage table online in real time. When a client exits training, the system will no longer retain any data records related to that client.
[0096] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the concept of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A sequence recommendation method based on personalized federated technology, characterized in that: Includes the following steps: Step S1: Each client maintains its data on its local device and preprocesses its own interaction data and the attribute values of the interaction items. Step S2: The client constructs a hash index on its local device using its own interactive data and forms a hash storage table; Step S3: The client performs augmentation operations on the training data on the local device based on the Bayesian training strategy to obtain augmented data; Step S4: Combining the hash index constructed in step S2 with the augmented data obtained in step S3, the client builds a local sequence recommendation framework based on multi-task on the local device and collaborates with the central server to perform distributed training on the local sequence model until the local sequence model converges. Step S5: The client obtains the parameters of the user's embedded network, combines them with the output of the converged local sequence model, obtains the preference prediction result for the next time step, and completes the personalized recommendation for the client. Step S4 includes the following sub-steps: Sub-step S4.1: Construct a sequence recommendation framework based on multi-task learning. The sequence recommendation framework consists of a user attribute embedding network, a local contrastive learning mechanism, an item embedding network, and a general sequence encoder. After the general sequence encoder is selected as needed, a local sequence model is formed. Sub-step S4.2: Initially update the local sequence model by receiving the initialization parameters from the central server, train the local sequence model locally using training data and augmentation data, and upload the trained local sequence model to the central server. Sub-step S4.3: The central server receives local sequence models from all clients, retrieves similar users for each client by querying the global hash storage table, and then performs personalized aggregation on all local sequence models based on the query results, so that a specific client corresponds to a specific aggregated model, and sends the aggregated model to the corresponding client. Sub-step S4.4: The client receives the aggregated model and continues to update the aggregated model with training data and augmentation data for the next round until the local sequence model converges; Step S5 includes the following sub-steps: Sub-step S5.1: Extract the parameters of the user attribute embedding network and use them as the feature representation of the user attributes. Perform an inner product operation between the parameters and the output vector of the local sequence model. Sub-step S5.2: Use the inner product result as the recommendation prediction result to predict the user's preferences at the next moment; Sub-step S5.3: The recommendation system maintains the global hash table online in real time.
2. The sequence recommendation method based on personalized federated technology according to claim 1, characterized in that: The preprocessing in step S1 includes cleaning up outliers and missing values in the interactive data, archiving project attributes for items accessed by the client, and archiving user attributes; and performing data structure alignment operations on project attributes and user attributes on all clients, representing the aligned project attributes and user attributes through vector matrices.
3. The sequence recommendation method based on personalized federated technology according to claim 1, characterized in that: Step S2 includes the following sub-steps: Sub-step S2.1: The client converts historical interaction data into binary feature vectors, downloads relevant hash data from the central server, and constructs a set of hash function clusters on the local device based on the data downloaded from the central server; Sub-step S2.2: Combine the binary feature vector with the hash function cluster to generate a hash index specific to the client and upload it to the central server; Sub-step S2.3: The central server receives the hash indexes from each client to build a hash storage table.
4. The sequence recommendation method based on personalized federated technology according to claim 1, characterized in that: Step S3 includes the following sub-steps: Sub-step S3.1: Construct a sub-sequence set to generate training data, each training data set containing a positive and negative sample sequence pair, the training data being used for Bayesian model optimization; Sub-step S3.2: Construct enhanced positive samples based on positive samples in the training data; Sub-step S3.3: Construct enhanced negative samples based on negative samples in the training data; Sub-step S3.4: Pair up the enhanced positive samples and the enhanced negative samples to form augmented data for self-supervised learning of the Bayesian model.
5. The sequence recommendation method based on personalized federated technology according to claim 4, characterized in that: In sub-step S3.2, enhanced positive samples are constructed based on the correlation between items and the length of the positive sample sequence, and the degree of correlation between items is determined according to the rule of calculating the area of a triangle by its sides.
6. The sequence recommendation method based on personalized federated technology according to claim 4, characterized in that: In sub-step S3.3, enhanced negative samples are constructed based on the length of the negative sample sequence.
Citation Information
Patent Citations
TEE-based federal recommendation method, apparatus and device, and medium
CN113259100A
Federal learning-based sequence recommendation method and system
CN114595396A