# pFedBASC: Personalized Federated Learning with Blockchain-Assisted Semi-Centralized Framework
## 4 Methodology
### pFedBASC Aggregation Method  
In pFedBASC, only HN parameters \(\mathbf{\varphi}\) are involved in the model transfer. Therefore, we only discuss the aggregation method for \(\mathbf{\varphi}\). We mainly focus on the design of the aggregation method and weight setting. The pFedBASC performs aggregation on client-side, and local aggregation of \(C_{i}\) includes three parts: the first part is local model \(\mathbf{\varphi}_{i}^{l}\), the second part consists of trusted models \(\mathbf{\varphi}_{j}^{l_{j}}\) from trusted client group \(C_{i}^{group}\), and the third part involves registered models \(\mathbf{\varphi}_{k}^{l_{k}}\) obtained from the blockchain. Clients aggregate model parameters of these three types locally, generating a global model \(\mathbf{\varphi}_{i}^{l}\) for the next round of training. In pFedBASC, we use the following aggregation formula for each client:  
\[\mathbf{\varphi}_{i}^{l}=p_{i}^{l}\mathbf{\varphi}_{i}^{l}+\sum_{C_{j}\in C_{i}^{group }}p_{j}^{l}\mathbf{\varphi}_{j}^{l}+\sum_{C_{k}\in C_{i}^{group}}p_{k}^{l}\mathbf{ \varphi}_{k}^{l_{k}} \tag{6}\]  
where the weight \(p\) denotes the aggregation weight. We employ the Gossip protocol for model transmission within the trusted client group \(C_{i}^{group}\). The Gossip protocol shares updated models after \(C_{i}\) has completed local training by broadcasting the new local model \(\mathbf{\varphi}_{i}^{l}\) to trusted \(C_{j}\). All \(C_{j}\) within group \(C_{i}^{group}\) will repeat this operation to share the model until all connected \(C_{j}\) receive the model updates from other clients in the group. This method can effectively improve the communication efficiency. In particular, considering the inconsistency of data distribution among clients, we design an aggregation weight adjustment scheme based on the loss function. We use local dataset \(\mathcal{D}_{i}\) to perform inference on the models \(\mathbf{\varphi}_{j}^{l_{j}}\) and \(\mathbf{\varphi}_{k}^{l_{k}}\), incorporating the loss function into the weight definition. That is, we randomly sample a batch of data from the client dataset for inference, approximating the loss function on the global dataset. The weight based on the loss function is defined as follows:  
\[p_{1,j}^{t}=\frac{1}{L(\mathbf{\varphi}_{j}^{l_{j}};\mathcal{D}_{i})}\qquad p_{1,k} ^{t}=\frac{1}{L(\mathbf{\varphi}_{k}^{l_{k}};\mathcal{D}_{i})} \tag{7}\]  
Simultaneously, we consider the inconsistency of computational capabilities among clients, also known as system heterogeneity. System heterogeneity arises from differences in computing hardware and environments, leading to different time costs for client training. Although the decentralized aggregation scheme and Gossip protocol reduce the waiting time between clients, system heterogeneity can lead to models situated in different rounds during aggregation, as shown below:  
\[t-1\
eq t_{j},\ t-1\
eq t_{k},\ t_{k}\
eq t_{j} \tag{8}\]  
Therefore, it is necessary to compensate and adjust outdated models. This paper designs an outdated model compensation scheme based on delayed rounds. This scheme adjusts the weights according to the difference between \(\mathbf{\varphi}_{j}^{l_{j}}\) and \(\mathbf{\varphi}_{k}^{l_{k}}\) and the current training \(t\)-th round. The delayed round-based weight definitions are as follows:  
\[p_{2,j}^{t}= \begin{cases}e^{(t_{j}-t)},t_{j}<t\\ 1,t_{j}\geqslant t\end{cases} \qquad p_{2,k}^{t}= \begin{cases}e^{(t_{k}-t)},t_{ k}<t\\ 1,t_{k}\geqslant t\end{cases}