A personalized federated learning method based on parameter stratification

By adopting parameter hierarchy and clustering techniques in federated learning, the problems of slow convergence and high computational complexity caused by data distribution differences in federated learning are solved, and the rapid convergence and personalized model customization is achieved, which improves the model's adaptation Sex and efficiency.

CN115587633BActive Publication Date: 2024-11-22CHONGQING UNIV OF POSTS & TELECOMM
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211382618.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-07
Publication Date
2024-11-22
Estimated Expiration
2042-11-07

AI Technical Summary

Technical Problem

In a federated learning environment, the difference in client data distribution results in slow convergence of global models, high computational complexity, and training models are difficult to generalize in different data.

Method used

Using a personalized federated learning method based on parameter hierarchy, the model parameters are divided into basic layer parameters and personalized layer parameters, the basic layer parameters are updated through stochastic gradient descent, and the client clustering is divided using the tripartite cosine similarity matrix. Dynamically adjust weights to achieve rapid convergence and personalized model customization.

Benefits of technology

Through parameter hierarchy and clustering, the problem of data distribution differences is alleviated, the convergence speed and adaptability of the global model are improved, the computational complexity is reduced, and personalized model training is achieved that is more suitable for local data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115587633B_ABST
    Figure CN115587633B_ABST
Patent Text Reader

Abstract

The present invention belongs to the application field of federated learning technology, and in particular, relates to a personalized federated learning method based on parameter stratification; the present invention comprises: the client performs parameter division on the local model before federated learning to obtain basic layer parameters and personalized layer parameters, the basic layer parameters and the personalized layer parameters are updated in each federated learning, and the client is clustered based on the updated basic layer parameters, so as to obtain the group average weight of each group and upload it to the server, and the server updates the basic layer parameters; after the federated learning is completed, the optimal basic layer parameters are obtained and sent to the client, and the client uses local data to train the local model to obtain a personalized local model; the present invention can alleviate the heterogeneity problem caused by the non-independent and identically distributed data of each client through parameter stratification and cluster division in federated training, which helps each client's final model to be more suitable for its local data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the application field of federated learning technology, relates to the adjustment of global models and local models, and in particular to a personalized federated learning method based on parameter stratification. Background Art

[0002] With the further development of big data, people's awareness and concern about data privacy are also increasing; therefore, federated learning has received widespread attention since its proposal and has been applied in some scenarios. Federated learning is a distributed machine learning framework with privacy protection and secure encryption technology, which aims to allow decentralized participants to collaborate on machine learning model training without disclosing private data to other participants. However, due to the high heterogeneity of data, it is difficult for us to train a global model suitable for all clients through federated learning.

[0003] As research on federated learning deepens, people have proposed using personalized federated learning methods to solve the problem of data heterogeneity. The core idea of ​​personalized federated learning is to capture the personalized information of each client and follow different research directions according to its heterogeneous data distribution to obtain a high-quality personalized model. At present, researchers divide personalized federated learning into two categories: global model personalization and learning personalized models. Global model personalization is divided into two stages. First, a shared global FL model is trained, and then additional training is performed on local data to achieve the purpose of personalization. The purpose of learning a personalized model is to establish a personalized model by modifying the aggregation process of the FL model.

[0004] In recent years, more and more scholars have conducted research on personalized federated learning in the field of federated learning. The research areas are mainly based on multi-task learning, hierarchical processing of the base layer and the personalized layer, and transfer learning. Based on multi-task learning, it mainly learns the independent model of each node and uses an arbitrary convex loss function to train an independent weight vector for each node; and considers the correlation between node models to solve statistical problems in the federated environment and increase sample capacity. Based on hierarchical processing, it mainly considers the differences in data distribution between each node. At the same time, the higher the number of neural network layers, the stronger the personalized characteristics. Based on transfer learning, it is a learning process that uses the similarity between data, tasks, or models to apply the model learned in the source field to the target field.

[0005] Although many scholars have conducted extensive research in the field of personalized federated learning and achieved considerable success, there are still some challenges:

[0006] 1. The client's non-IID data leads to slow convergence of the global model. In a federated learning environment, the devices participating in federated learning have large differences in data distribution and communication costs, so it is difficult to quickly train a good global model.

[0007] 2. The problem of high complexity of federated calculations. In the process of calculating parameter similarity to achieve partitioning, there is a problem of high complexity in calculating massive data, which greatly reduces the calculation efficiency.

[0008] 3. Local distribution differences. Due to differences in data distribution among clients, the preferences captured from the original data are different, which makes it difficult for the trained global model to be generalized well in various data. Therefore, how to train a personalized model for each client based on the global model has become a major research direction.

[0009] In view of the problem of heterogeneous data distribution on clients, personalized federated learning has gradually become the mainstream choice to solve this problem. Zhu et al. (Zhu, Zhuangdi, Junyuan Hong, and Jiayu Zhou. "Data-free knowledge distillation for heterogeneous federated learning." International Conference on Machine Learning. PMLR, 2021.) proposed a data-free knowledge distillation method to solve the problem of data heterogeneity. The learned knowledge is used as an inductive bias to adjust local training, so as to achieve fewer communication rounds to promote FL to have better generalization performance. Inspired by this paper, the present invention proposes a personalized federated learning method based on iterative partitioning and parameter stratification. The model base layer parameters are used to participate in federated training, and the personalized layer parameters are used to adapt to the local data distribution. At the same time, the weight divergence problem is solved by clustering partitioning, and the rapid convergence of the global model is achieved with fewer communication rounds. Summary of the invention

[0010] To solve the above problems, the present invention provides a personalized federated learning method based on parameter stratification, comprising the following steps:

[0011] S1. Build a personalized federated learning system including N clients and one server, where the server is equipped with a master model with initialized parameters;

[0012] S2. The client downloads the main model from the server as a local model, and the parameters of the main model are divided into basic layer parameters and personalized layer parameters;

[0013] S3. The client improves the base layer parameters and personalized layer parameters of the local model through stochastic gradient descent based on local data, and obtains the base layer weight update vector;

[0014] S4. After reducing the dimension of the base layer weight update vector, a ternary vector matrix is ​​obtained, and the ternary cosine similarity matrix is ​​obtained by measuring the ternary vector matrix using the ternary cosine similarity method;

[0015] S5. The similarity distance between clients is calculated by the ternary cosine similarity matrix of each client itself, and the clients are clustered into K groups according to the similarity distance and the base layer weight update vector using the K-Medoids algorithm. Each group is internally aggregated to obtain the corresponding group average weight;

[0016] S6. Upload the average weights of all groups to the server for global aggregation. The server obtains the updated basic layer parameters and sends them to the client.

[0017] S7. Determine whether the federated learning iteration threshold is reached. If so, proceed to step S8, otherwise return to step S3;

[0018] S8. The client fixes the base layer parameters of the local model, performs stochastic gradient descent on the local model through local data to improve the personalized parameters, and finally obtains the personalized model of the client.

[0019] Furthermore, each client improves the base layer parameters and personalized layer parameters of the local model through stochastic gradient descent to obtain its own base layer weight update vector, and the base layer parameter update process between clients is independent of each other; the calculation formula of the base layer weight update vector is expressed as:

[0020]

[0021]

[0022] in, represents the base layer weight obtained by stochastic gradient descent of client i, i = {1, 2,, ..., N} in the tth federated learning round, represents the personalization layer weight obtained by client i in the tth federated learning round using stochastic gradient descent, W B (t-1) represents the base layer parameters updated by the server after the t-1th federated learning round, represents the personalization layer weight obtained by client i in the t-1th federated learning round using stochastic gradient descent, C i represents the batch data sampled from the local data of client i, SGD i represents the stochastic gradient descent method used by client i, represents the base layer weight update vector of client i in the tth federated learning round.

[0023] Furthermore, the process of obtaining the ternary cosine similarity matrix of client i, i={1,2,,...,N} in step S3 includes:

[0024] S31. Use the singular value decomposition algorithm to reduce the dimension of the base layer weight update vector of client i, and obtain the ternary vector matrix of client i, which is expressed as:

[0025]

[0026] Among them, V i The ternary vector matrix representing client i, v i1 、v i2 and v i3 represents the basic direction vector in the three-element vector matrix of client i, represents the base layer weight update vector of client i in the tth federated learning round;

[0027] S32. Define the ternary cosine similarity of client i based on the ternary vector matrix, expressed as:

[0028]

[0029]

[0030] in, represents the ternary cosine similarity of client i, v scale represents the inverse matrix of the product of the base layer weight update vector and the ternary vector matrix, represents the product operator of Hadamard matrices;

[0031] S33. Normalize the ternary cosine similarity of client i to obtain the ternary cosine similarity matrix of client i, which is expressed as:

[0032]

[0033] Among them, M i represents the ternary cosine similarity matrix of client i.

[0034] Furthermore, the process of obtaining the average group weight of each group in step S4 includes:

[0035] S41. Calculate the similarity distance between every two clients according to the ternary cosine similarity matrix, expressed as:

[0036]

[0037] Among them, αi,j represents the similarity distance between client i and client j, M i represents the ternary cosine similarity matrix of client i, M j represents the ternary cosine similarity matrix of client j;

[0038] S42. randomly select the ternary cosine similarity matrices of K clients as cluster centers, perform clustering by similarity distance, and use a cost function to measure clustering quality, and finally obtain K groups;

[0039] S43. Each group performs intra-group security aggregation to obtain the corresponding group average weight, and the calculation formula is:

[0040]

[0041] in, Indicates the number of group g in the tth federated learning round k The average weight of the group, represents the base layer weight update vector of client i in the tth federated learning round, c i represents client i, Indicates group g k The set of group members; Indicates that client i is in group g k Group members, n i represents the number of samples on client i, and n represents the total number of samples of all clients in a group.

[0042] Furthermore, the cost function Cost is expressed as:

[0043] Cost = E m -E m-1

[0044]

[0045]

[0046] Among them, E m represents the evaluation score of the mth group update result, E m-1 represents the evaluation score of the m-1th group update result, p represents the ternary cosine similarity matrix of the clients outside the cluster center, represents the kth group in the mth group update, o k represents the cluster center of the kth group, and K represents the number of groups.

[0047] Furthermore, in step S7, an objective function is set to minimize the average personalized group loss, which is expressed as:

[0048]

[0049] Among them, W B represents the final base layer parameters obtained after federated training, represents the personalized layer parameters locally owned by the first client, N represents the number of all clients participating in the federated training, represents the mathematical expectation of the personalized loss function of the i-th client, (x, y) represents the data sample distribution of client i, represents the personalized layer weight of the i-th client, f represents the output function, and l represents the personalized loss function common to all clients.

[0050] Beneficial effects of the present invention:

[0051] There is a problem of high data heterogeneity in federated learning, which makes it difficult to train a global model suitable for all clients through federated learning. At the same time, there is also a problem of client weight divergence when training a global model in federated learning, which is also a problem caused by data heterogeneity. Because the local data distribution of each client is different, the model optimization direction is different, which greatly reduces the convergence speed and effect of the global model. In response to the above problems, the present invention improves the parameters and training process of each client that needs to be uploaded to federated learning, and proposes a personalized federated learning method based on parameter stratification. The method stratifies the model parameters and divides the model parameters into basic layer parameters and personalized layer parameters. The basic layer parameters are used to participate in federated training, and the personalized layer parameters are retained locally, retaining the unique personality characteristics of each client. This alleviates the problem of different local data distribution, making the trained model more suitable for local clients. At the same time, during the training process, the groups are dynamically divided according to the similarity of parameter updates, which accelerates the convergence speed of the global model. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a schematic diagram of a personalized federated learning framework based on parameter stratification of the present invention;

[0053] Figure 2 This is a flow chart of the personalized federated learning method based on parameter stratification of the present invention. DETAILED DESCRIPTION

[0054] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0055] The present invention provides a personalized federated learning method based on parameter stratification, which groups the parameters of the base layer according to their update direction similarity to accelerate the convergence of the global model, and at the same time, utilizes the personalized layer parameters locally to alleviate the problem of local distribution differences, and finally realizes personalized model customization of the local client. Figure 1 As shown, the present invention mainly includes 3 parts:

[0056] S1. Before the federated learning training, the server issues a master model with initialized parameters, and the parameters of the master model are divided into basic layer parameters and personalized layer parameters. The client downloads the master model issued by the server as a local model;

[0057] S2. After the preliminary preparations for federated learning training are completed, the client uses local data to train the local model to obtain the update direction of the basic layer parameters; clusters the clients based on the update direction of the basic layer parameters to make the clustering results more accurate and effective; then calculates the group average weight of the group and uploads it to the server for global aggregation to obtain the updated basic layer parameters, the client re-downloads the updated basic layer parameters obtained from the server, and repeats the operation of S2 until the optimal basic layer parameters are obtained;

[0058] S3. The data distribution of different clients is different, so the global parameters obtained through federated training are not suitable for every client. Therefore, at the beginning of the present invention, the server initializes the basic layer parameters, and the client initializes its own personalized layer parameters. The basic layer parameters are used to participate in federated training to obtain more generalized global basic layer parameters, and the personalized layer parameters participate in each iteration of training. Finally, each client uses the trained basic layer parameters and personalized layer parameters to perform SGD updates using local data to obtain a personalized model that is more suitable for local data distribution.

[0059] In one embodiment, a specific process of a personalized federated learning method based on parameter stratification is as follows: Figure 2 As shown, the following steps are included:

[0060] S10. Construct a personalized federated learning system including N clients and a server, wherein the server is provided with a master model after parameter initialization;

[0061] S20. The client downloads the main model from the server as a local model, wherein the parameters of the main model are divided into basic layer parameters and personalized layer parameters;

[0062] S30. The client improves the base layer parameters and the personalized layer parameters of the local model by stochastic gradient descent based on the local data, and obtains the base layer weight update vector;

[0063] S40. After reducing the dimension of the base layer weight update vector, a ternary vector matrix is ​​obtained, and the ternary cosine similarity matrix is ​​obtained by measuring the ternary vector matrix using the ternary cosine similarity method;

[0064] S50. Calculate the similarity distance between clients through the ternary cosine similarity matrix of each client itself, use the K-Medoids algorithm to cluster the clients according to the similarity distance and the base layer weight update vector to obtain K groups, and perform internal aggregation on each group to obtain the corresponding group average weight;

[0065] S60. Upload the average weights of all groups to the server for global aggregation. The server obtains the updated basic layer parameters and sends them to the client.

[0066] S70. Determine whether the federated learning iteration threshold is reached. If so, proceed to step S80, otherwise return to step S30;

[0067] S80. The client fixes the base layer parameters of the local model, performs stochastic gradient descent on the local model through local data to improve the personalized parameters, and finally obtains the personalized model of the client.

[0068] Preferably, in multiple iterations of federated learning, in each round, each client needs to first download the base layer parameters updated by the server, and then use local data to perform multiple stochastic gradient descents on the base layer parameters of the local model (that is, the latest base layer parameters downloaded by the client from the server) and the personalized layer parameters to improve the parameters of the local model, and obtain the updated base layer parameters and updated personalized layer parameters of the local model, thereby obtaining the update direction of the base layer parameters of the local model, wherein the calculation formula of the base layer weight update vector (that is, the update direction of the base layer parameters of the local model) is expressed as:

[0069]

[0070]

[0071] in, represents the base layer weight obtained by stochastic gradient descent of client i, i = {1, 2,, ..., N} in the tth federated learning round, represents the personalization layer weight obtained by client i in the tth federated learning round using stochastic gradient descent, W B (t-1) represents the base layer parameters updated by the server after the t-1th federated learning round, represents the personalization layer weight obtained by client i in the t-1th federated learning round using stochastic gradient descent, C i represents the batch data sampled from the local data of client i, SGDi represents the stochastic gradient descent method used by client i, represents the base layer weight update vector of client i in the tth federated learning round.

[0072] Specifically, each client improves the base layer parameters and personalized layer parameters of the local model through stochastic gradient descent to obtain its own base layer weight update vector, and the base layer parameter update process between clients is independent of each other.

[0073] Preferably, after the client obtains the update direction of the base layer parameters of the local model, it needs to perform dimensionality reduction of the base layer parameters, and then obtain the client's ternary cosine similarity matrix as the basis for clustering, and the specific process includes:

[0074] S31. In order to reduce the computational complexity and facilitate the subsequent representation of the ternary cosine similarity matrix, the singular value decomposition algorithm is used to reduce the dimension of the base layer weight update vector of client i, and the ternary vector matrix of client i is obtained, which is expressed as:

[0075]

[0076] Among them, V i The ternary vector matrix representing client i, v i1 、v i2 and v i3 Represents the basic direction vector in the ternary vector matrix of client i, which is used to indicate the optimization direction of the client base layer parameters. represents the base layer weight update vector of client i in the tth federated learning round;

[0077] S32. In order to reduce the computational cost, this paper proposes a measurement method called ternary cosine similarity, which is used to measure the optimization direction of the updated base layer parameters; that is, the ternary cosine similarity of client i is defined based on the ternary vector matrix, expressed as:

[0078]

[0079]

[0080] in, represents the ternary cosine similarity of client i, v scale represents the inverse matrix of the product of the base layer weight update vector and the ternary vector matrix, represents the product operator of Hadamard matrices;

[0081] S33. Normalize the ternary cosine similarity of client i to the interval [0,1] to obtain the ternary cosine similarity matrix of client i, which is expressed as:

[0082]

[0083] Among them, M i represents the ternary cosine similarity matrix of client i.

[0084] Preferably, based on the ternary cosine similarity matrix, this embodiment takes into account the advantages of clustering in solving the weight divergence problem and constructs a module based on the similarity of client base layer parameter updates. First, the similarity distance is calculated by the cosine formula, and then the clients participating in the federated training are clustered and divided by the K-Medoids algorithm. The clients are divided into multiple groups based on the parameter update direction, and finally, each group is securely aggregated to obtain the group average weight of the group. The average weight of each group is globally aggregated on the server to obtain the base layer weight of the next round, which is distributed to each client for the next round of federated training.

[0085] Specifically, the average group weight of each group is obtained and uploaded to the server. The process of the server updating the basic layer parameters includes:

[0086] S41. The similarity distance between each two clients is calculated based on the ternary cosine similarity matrix, and the similarity distance is used as the cluster distance basis for clustering. This is conducive to dividing clients with the same update direction into a small group and accelerating the rapid convergence of the average weight within the group. The similarity distance calculation formula is expressed as:

[0087]

[0088] Among them, α i,j represents the similarity distance between client i and client j, M i represents the ternary cosine similarity matrix of client i, M j represents the ternary cosine similarity matrix of client j;

[0089] S42. randomly select the ternary cosine similarity matrices of K clients as cluster centers, perform clustering by similarity distance, and use a cost function to measure clustering quality, and finally obtain K groups;

[0090] Specifically, clustering is performed based on the similarity distance, that is, the similarity distance between the remaining clients and the clients corresponding to the cluster center is used to perform the clustering. Clients that are not corresponding to the cluster center are assigned to the group with the smallest similarity distance, and then the update process begins: each time an update is performed, each group randomly selects a group member as the cluster center, replaces the original cluster center, restarts clustering, and determines whether the clustering effect after the update is improved. If so, the replacement is retained, otherwise the previous result is restored. When the replacement no longer improves the clustering effect, the update stops.

[0091] Specifically, a cost function is used to measure the quality of the clustering results. The cost function Cost is expressed as:

[0092] Cost = E m -E m-1

[0093]

[0094]

[0095] Among them, E m represents the evaluation score of the mth group update result, E m-1 represents the evaluation score of the m-1th group update result, p represents the ternary cosine similarity matrix of the clients outside the cluster center, represents the kth group in the mth group update, o k represents the cluster center of the kth group, and K represents the number of groups. When the cost function no longer changes, it means that all the center points no longer change or the maximum number of iterations has been reached. According to the clustering algorithm, the optimal group division G = {g1, g2, ..., g K},

[0096] S43. Each group performs intra-group security aggregation to obtain the corresponding group average weight, and the calculation formula is:

[0097]

[0098] in, Indicates the number of group g in the tth federated learning round k The average weight of the group, represents the base layer weight update vector of client i in the tth federated learning round, c i represents client i, Indicates group g k The set of group members; Indicates that client i is in group g k Group members, n i represents the number of samples on client i, and n represents the total number of samples of all clients in a group.

[0099] Finally, the average group weight of each group is obtained, which is expressed as:

[0100]

[0101] S44. Upload the average group weight of each group to the central server for global aggregation, obtain the latest basic layer parameters, and redistribute them to each client for the next round of federated training.

[0102] In one embodiment, this paper designs a method of client parameter stratification to address the data difference problem. The base layer is uploaded to the central server for global aggregation, and the personalized layer is trained on the local data. For each client's local model, the number of stratification is first defined as:

[0103]

[0104] Among them, K B represents the number of base layer parameters, K P Indicates the number of personalization layer parameters.

[0105] Secondly, define the forward transfer method of local model data, which is expressed as:

[0106]

[0107] in, Represents the client's base layer weight matrix (that is, base layer parameters), Represents the first layer parameters in the base layer parameters. The parameters of different layers in the base layer parameters may have different dimensions. The base layer weight matrices of different clients are the same. represents the personalized layer weight matrix (that is, personalized layer parameters) of client i, a represents the activation function, and is specifically represented as a certain layer according to the subscript; the client data first passes through the basic layer, then passes through the personalized layer, and finally gets the output. The forward transfer can be simply described as:

[0108]

[0109] Specifically, after the federated learning is completed, the optimal basic layer parameters are obtained. Next, the personalized layer parameters need to be optimized. That is, the client uses local data to optimize its own personalized layer parameters. At this time, the objective function is set to minimize the average personalized group loss, which is expressed as:

[0110]

[0111] Among them, W B represents the final base layer parameters obtained after federated training, represents the personalized layer parameters locally owned by the first client, N represents the number of all clients participating in the federated training, represents the mathematical expectation of the personalized loss function of the i-th client, (x, y) represents the data sample distribution of client i, represents the weight of the personalized layer of the i-th client, f represents an output function of the sample x of client i first passing through the basic layer and then passing through the personalized layer, and l represents the personalized loss function common to all clients.

[0112] Since the real data generates distribution P i It is unknown during training, and we will use the personalized loss function of the i-th device as a proxy for simulating the global loss function (minimizing the average personalized group loss). The loss on the i-th device (client) is defined as:

[0113]

[0114] Among them, W B represents the final base layer parameters obtained after federated training, W P represents the personalized layer parameters unique to the i-th device, n i represents the sample size of the ith device, (x i,j ,y i,j ) represents the jth sample size in the data distribution of the ith device.

[0115] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.

Claims

1. A personalized federated learning method based on parameter stratification, characterized in that: The following steps are involved: S1. Build a personalized federated learning system including N clients and one server, where the server is equipped with a master model with initialized parameters; S2. The client downloads the main model from the server as a local model, and the parameters of the main model are divided into basic layer parameters and personalized layer parameters; S3. The client improves the base layer parameters and personalized layer parameters of the local model through stochastic gradient descent based on local data, and obtains the base layer weight update vector; Each client improves the base layer parameters and personalized layer parameters of the local model through stochastic gradient descent to obtain its own base layer weight update vector, and the base layer parameter update process between clients is independent of each other; the calculation formula of the base layer weight update vector is expressed as: in, represents the base layer weight obtained by stochastic gradient descent of client i, i = {1, 2,, ..., N} in the tth federated learning round, represents the personalization layer weight obtained by client i in the tth federated learning round using stochastic gradient descent, represents the base layer parameters updated by the server after the t-1th federated learning round, represents the personalization layer weight obtained by client i in the t-1th federated learning round using stochastic gradient descent, C i represents the batch data sampled from the local data of client i, SGD i represents the stochastic gradient descent method used by client i, represents the base layer weight update vector of client i in the tth federated learning round; S4. After reducing the dimension of the base layer weight update vector, a ternary vector matrix is ​​obtained, and the ternary cosine similarity matrix is ​​obtained by measuring the ternary vector matrix using the ternary cosine similarity method; The process of obtaining the ternary cosine similarity matrix of client i, i = {1, 2,, ..., N} includes: S31. Use the singular value decomposition algorithm to reduce the dimension of the base layer weight update vector of client i, and obtain the ternary vector matrix of client i, which is expressed as: Among them, V i The ternary vector matrix representing client i, v i1 、v i2 and v i3 represents the basic direction vector in the three-element vector matrix of client i, represents the base layer weight update vector of client i in the tth federated learning round; S32. Define the ternary cosine similarity of client i based on the ternary vector matrix, expressed as: in, represents the ternary cosine similarity of client i, v scale represents the inverse matrix of the product of the base layer weight update vector and the ternary vector matrix, represents the product operator of Hadamard matrices; S33. Normalize the ternary cosine similarity of client i to obtain the ternary cosine similarity matrix of client i, which is expressed as: Among them, i represents the ternary cosine similarity matrix of client i; S5. The similarity distance between clients is calculated by the ternary cosine similarity matrix of each client itself, and the clients are clustered into K groups according to the similarity distance and the base layer weight update vector using the K-Medoids algorithm. Each group is internally aggregated to obtain the corresponding group average weight; The process of obtaining the group average weight for each group includes: S41. Calculate the similarity distance between every two clients according to the ternary cosine similarity matrix, expressed as: Among them, α i,j represents the similarity distance between client i and client j, M i represents the ternary cosine similarity matrix of client i, M j represents the ternary cosine similarity matrix of client j; S42. randomly select the ternary cosine similarity matrices of K clients as cluster centers, perform clustering by similarity distance, and use a cost function to measure clustering quality, and finally obtain K groups; S43. Each group performs intra-group security aggregation to obtain the corresponding group average weight, and the calculation formula is: in, Indicates the number of group g in the tth federated learning round k The average weight of the group, represents the base layer weight update vector of client i in the tth federated learning round, c i represents client i, Indicates group g k The set of group members; Indicates that client i is in group g k Group members, n i represents the number of samples on client i, and n represents the total number of samples of all clients in a group; The cost function Cost is expressed as: Cost=E m -E m-1 Among them, E m represents the evaluation score of the mth group update result, E m-1 represents the evaluation score of the m-1th group update result, p represents the ternary cosine similarity matrix of the clients outside the cluster center, represents the kth group in the mth group update, o k represents the cluster center of the k-th group, and K represents the number of groups; S6. Upload the average weights of all groups to the server for global aggregation. The server obtains the updated basic layer parameters and sends them to the client. S7. Determine whether the federated learning iteration threshold is reached. If so, proceed to step S8, otherwise return to step S3; S8. The client fixes the base layer parameters of the local model, performs stochastic gradient descent on the local model through local data to improve the personalized parameters, and finally obtains the personalized model of the client; The objective function is set to minimize the average personalized group loss, expressed as: Among them, W B represents the final base layer parameters obtained after federated training, represents the personalized layer parameters locally owned by the first client, N represents the number of all clients participating in the federated training, represents the mathematical expectation of the personalized loss function of the i-th client, (x, y) represents the data sample distribution of client i, represents the personalized layer weight of the i-th client, f represents the output function, and l represents the personalized loss function common to all clients.