# pFedBASC: Personalized Federated Learning with Blockchain-Assisted Semi-Centralized Framework
## 4 Methodology
### Proposed FedHype  
We will introduce the design of FedHype. We attempt to embed HN mentioned in Figure 2 into FL, using the methods in propagation (3) and (4) for parameter updates to satisfy the pFL training objective in (5). HN takes the 400-parameter embedding vector set \(\mathbf{v}_{i}\) that combines client ID and chunk ID as input and output TNs according to the knowledge of HN. During the parameter exchange, FedHype only transmits HN. By aggregating HN, the knowledge and parameter generation abilities can be shared with other users.  
As shown in Algorithm 1, the workflow is divided into the aggregator and user parts. After training starts, clients' TN parameters, HN parameters, and embedding vectors \(\{\mathbf{v}_{1},...,\mathbf{v}_{N}\}\) are initialized. Then, \(C_{i}\) generates \(\mathbf{w}_{i}^{t-1}\) using \(\mathbf{\varphi}^{t-1}\) and \(\mathbf{v}_{i}\). Next, \(C_{i}\) carries out local training and updates HN via (4). After completion, HN \(\mathbf{\varphi}_{i}^{t}\) will be sent back to the aggregator, waiting for global aggregation. The aggregator executes the algorithm, obtaining global model \(\mathbf{\varphi}^{t}\), and proceeds with model distribution. This process is repeated until the network converges or target rounds are reached. We call it the aggregator because the aggregation function can be undertaken by a blockchain or user, not solely by a server. FedHype can easily be combined with other FL algorithms to replace aggregation methods, where typically FedAvg is utilized in aggregation by default.  
```
0: total communication rounds \(T\), client learning rate \(\alpha\), HN learning rate \(\eta\), datasets \(\{D_{1},...,D_{N}\}\)
0:\(\mathbf{\varphi}^{T}\)
1: Initialize the clients' TN parameters, HN parameters, and embedding vectors \(\{\mathbf{v}_{1},...,\mathbf{v}_{N}\}\)
2:for each round \(t=1\) to \(T\)do
3:at client \(i=1\) to \(N\)in paralleldo
4:\(\mathbf{w}_{i}^{t-1}=h(\mathbf{v}_{i};\mathbf{\varphi}^{t-1})\)
5:ClientUpdate:
6:\(\mathbf{\hat{w}}_{i}^{t-1}\leftarrow\mathbf{w}_{i}^{t-1}-\alpha\
abla F_{i}(\mathbf{w}_{i} ^{t-1})\)
7:\(\Delta\mathbf{w}_{i}^{t-1}=\mathbf{\hat{w}}_{i}^{t-1}-\mathbf{w}_{i}^{t-1}\)
8:\(\mathbf{\varphi}_{i}^{t}\leftarrow\mathbf{\varphi}^{t-1}-\eta\
abla_{\mathbf{\varphi}^{t- 1}}\Big{(}\hat{\mathbf{w}}_{i}^{t-1}\Big{)}^{T}\Delta\mathbf{w}_{i}^{t-1}\)
9:Communication: send \(\mathbf{\varphi}_{i}^{t}\) to aggregator
10:end at client
11:at aggregator do
12:\(\mathbf{\varphi}^{t}\leftarrow\textbf{ModelAggregation}(\mathbf{\varphi}_{i}^{t})\)
13:Communication: send \(\mathbf{\varphi}^{t}\) to each client \(\text{C}_{i}\)
14:end at aggregator
15:end for
```  
**Algorithm 1**FedHype  
We also conducted a qualitative analysis of the algorithm's time complexity. On the client side, each participant executes the following primary operations sequentially: first, local parameter generation via the hypernetwork; second, local training, which typically represents the most significant consumption of computational resources, influenced by the dataset size and model complexity; and third, updating hypernetwork parameters, an operation whose complexity is generally determined by the size of the hypernetwork. On the aggregator side, the complexity primarily depends on the aggregation algorithm and the number of parameters within the hypernetwork. Optimizing any of these factors can effectively reduce the overall consumption of computing resources.