# Towards Blockchain-Based Federated Machine Learning: Smart Contract for Model Inference
## 1 Introduction  
Federated learning (FL) is a distributed machine learning (ML) approach that facilitates model training on a decentralized network of individual data sources. Unlike traditional ML, which relies on centralized data computing to develop machine learning models, FL develops and uses a model across multiple decentralized devices [1]. Rather than gathering all data samples to one server, decentralized devices hold local data samples without exchanging them [2, 3, 4]. Despite the setting, it is advantageous if the generalization abilities of the ML model (or models) are evaluated on a separate validation data, which is agreed upon and available to all participants in the learning process. If some data gets uploaded later, after model creation and sharing, these data records, when used for model inference, could be considered as unseen or testing data. Both validation and testing settings correspond to the ML model inference. In recent years, a few novel solutions emerged which attempt to decentralize the machine learning process using various techniques. Google uses cloud infrastructure to distribute the Gboard (Google keyboard) [1] model among phone devices to improve predictive typing. A single shared model is used and developed on the user's data, then changes are summarized and pushed as a model update to the cloud. A number of these updates are integrated and used to improve the existing shared model. The basic principles of this approach show that decentralization can be used in a manner which facilitates the development of a single shared ML model. While the Google approach is quite novel, itsupports a specific type of model and suffers from scalability since the training of a model requires a substantial number of users. Another novel solution by Nvidia proposes building robust ML algorithms, which enable collaboration of different nodes in model training while preserving data privacy [5]. Nvidia implements a server-client approach, where a centralized server works as a manager/facilitator of participating clients. The infrastructure allows the developers to share their models and components and have control over the training process. Partial models are trained on clients, then the partial model weights are shared, and the model is updated based on weights and history of contributions. Even though the infrastructure supports the usage of different models, it still is dependent on a centralized node to aggregate weights and update the shared model, creating a bottleneck in terms of resources and computational power. FL can be useful in several aspects, including load-balancing (to distribute computations in the machine learning task) and privacy preservation (to contribute to the machine learning task without revealing training data). To adapt infrastructure for several ML models and distribute the computing power without relying on a centralized node, several solutions using distributed ledger technology (DLT) [6] or blockchain [7; 8; 9], were developed. Even though FL can be implemented without DLT, the introduction of DLT or blockchain as a specific type of DLT can partially solve interoperability and heterogeneity technical limitations, which are present in the traditional FL approaches. Data heterogeneity with respect to multivariate distribution could be alleviated by introducing the possibility to donate some data for model validation purposes. Interoperability, in terms of compatibility among network nodes, could be solved by providing a common architecture for collaborative model sharing. A solution combining machine learning and blockchain technologies is discussed in [10], where possible integrations between blockchain and machine learning for processes such as model training, validation, testing, deployment, and storage are analyzed. Blockchain infrastructure holds potential to improve transparency and trust in the machine learning process and resulting models by logging everything into a distributed ledger permanently.