Decentralized & Collaborative AI On Blockchain

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

2019 IEEE International Conference on Blockchain (Blockchain)

Decentralized & Collaborative AI on Blockchain


Justin D. Harris Bo Waggoner
Microsoft Research Microsoft Research
Montreal, Canada New York, USA
justin.harris@microsoft.com bwag@colorado.edu
arXiv:1907.07247v1 [cs.CR] 16 Jul 2019

Abstract—Machine learning has recently enabled large ad- expertise, siloed proprietary data, and access to machine
vances in artificial intelligence, but these tend to be highly cen- learning model predictions (e.g. charged on a per-query basis).
tralized. The large datasets required are generally proprietary;
predictions are often sold on a per-query basis; and published A. Overview
models can quickly become out of date without effort to acquire
more data and re-train them. We propose a framework for
By leveraging advances in AI, prediction markets, and
participants to collaboratively build a dataset and use smart blockchain platforms, we can demonstrate the capabilities
contracts to host a continuously updated model. This model of a new framework to collect vast amounts of data, allow
will be shared publicly on a blockchain where it can be free contributors to potentially profit, and host a shared machine
to use for inference. Ideal learning problems include scenarios learning model as a public resource. The model can be
where a model is used many times for similar input such as
personal assistants, playing games, recommender systems, etc.
collaboratively trained by many contributors yet remain open
In order to maintain the model’s accuracy with respect to some and free for others to use the model for inference. This is
test set we propose both financial and non-financial (gamified) accomplished with several configurable components:
incentive structures for providing good data. A free and open • the incentive mechanism
source implementation for the Ethereum blockchain is provided
• the data handler
at https://github.com/microsoft/0xDeCA10B.
• the machine learning model
Index Terms—Decentralized AI, Blockchain, Ethereum,
Crowdsourcing, Prediction Markets, Incremental Learning A smart contract is created and initialized with choices for
these components. It then accepts “add data” actions from
participants, with the incentive mechanism possibly triggering
I. I NTRODUCTION
payments or allowing other actions. Adding data involves
We propose a framework for sharing and improving a validation from the incentive mechanism, storing in the data
machine learning model. In this framework, anyone can freely handler, and finally calling the update method on the model’s
access the model’s predictions or provide data to help im- contract, as shown in Fig. 1. Prediction is done off-chain by
prove the model. An important challenge is that the system calling the predict function provided for convenience in the
must be robust and incentivize participation, but discourage model’s smart contract code.
manipulation. Our framework is modular, and we propose and The goal of our system is not for the creators to profit:
justify three example choices of “incentive mechanisms” with the goal is to create valuable shared resources. It is possible
different advantages. for the data contributors to profit financially (depending on the
There exist several proposals to combine machine learning incentive mechanism) but this is mainly a result of mechanisms
and blockchain frameworks. In systems such as DInEMMo [1], designed to penalize the contributors who submit bad data.
access to the trained model is limited to a marketplace. This The dataset is also public because it can be found in the
allows contributors to profit based on a model’s usage, but it blockchain’s transaction history or through emitted events
limits access to those who can pay. DanKu proposes storing (if this feature is available to the blockchain framework).
already trained models in smart contracts for competitions, Collecting large datasets can be costly using typical crowd-
which does not allow for continual updating and collaborative sourcing platforms such as Figure Eight (formerly known as
training [2]. In contrast, the goal of this work is to address Dolores Lab, CrowdFlower) and Amazon Mechanical Turk.
the current centralization of artificial intelligence by sharing In crowdsourcing, filtering out “bad data” is a constant battle
models freely. Such centralization includes machine learning with spammers, who can submit low-effort or nonsensical
data and still receive compensation for their work [3]. In
our incentive mechanisms, contributors do not benefit from
978-1-7281-4693-5/19/$31.00 2019
c IEEE DOI 10.1109/Blockchain.2019.00057 submitting bad data and can even pay a penalty; meanwhile,
honest contributors are actively incentivized to correct others’ contract is complicated because a user cannot be forced to
mistakes. make a payment. Instead, many solutions in the blockchain
space require users to “stake” deposits that can be re-claimed
B. Machine Learning and Blockchain Background later if they obey rules.1 Similarly to those systems, we will
We mainly considered supervised learning problems where also propose staking a deposit to simplify some incentive
a dataset consists of labeled samples. For example, in a mechanisms for submitting new data.
recommender system, a movie or restaurant is given a label
from 1 to 5 stars. The term model refers to a machine learning D. Organization
algorithm that has been trained on data. It is used to make In section II, we describe the machine learning data handler
predictions, e.g. predict the label of a given example. It can and model portion of the algorithm. In section III, we give our
be represented as a neural network, a matrix of numbers, a incentive mechanisms. Then we discuss some implementation
decision tree, etc. details in section IV. In section V, we present some reasons
Our framework applies to platforms where decentralized for using a blockchain for this framework. We present our
networks agree on a shared sequence of computations. An responses to several potential issues in section VI. Finally, we
example is the Ethereum blockchain [4]. A smart contract is motivate some future work in section VII.
an object (in the sense of object-oriented programming) in
this shared code. It contains data fields and interacts with new II. M ACHINE L EARNING M ODELS
code and events via its method calls. A computation on-chain This system can be used with various types of models
means the computation is done inside of a smart contract. including supervised and unsupervised. The model architecture
The input and result of the computation are usually stored on (e.g. different types of neural networks, CRFs [7], SVMs [8],
the blockchain. In contrast, off-chain means the computation etc.) chosen relates closely to the incentive mechanism chosen.
can be done locally on the client’s machine and does not In our examples, we mainly consider training supervised
necessarily need to be public. classifiers because they can be used for many applications. We
In Ethereum, reading and running code provided by a smart first propose to leverage the work in the Incremental Learning
contract has no cost if it does not write to the blockchain. space [9] by using models capable of efficiently updating with
This means that one can use the model in a smart contract one sample. This should lower the transaction costs (“gas”) to
for inference for free. When we discuss blockchains, smart update a model hosted in an Ethereum smart contract because
contracts, and examples throughout this paper, we are mainly each data contribution will be small. One simple model with
referring to Ethereum blockchain and the specifics of smart “cheap” updates is a Nearest Centroid Classifier, also known
contracts on the Ethereum platform. However, this design is as a Rocchio Classifier [10]. Online learning algorithms could
certainly not limited to only run on Ethereum. also be appropriate.
C. Staking a Deposit A. Initial Model
In conventional legal systems, violating an agreement may It is often helpful if the initially deployed model has
result in a penalty or fine. Enforcing a penalty via a smart been trained to some extent. For example, if the model is
already somewhat useful, it is more likely to receive users
for inference, who are more likely to generate and provide
back data to improve the model. Also, for some but not all of
our incentive mechanisms, having an initial level of accuracy
(x, y) addData(x, y) allows better validation of contributed data. We stress that
1
although this can be helpful, in many cases the model does
2 not need to be pre-trained or highly accurate.
IncentiveMechanism 3 B. Limitations
DataHandler Due to limitations such as the cost of memory in the
Model Ethereum blockchain, our examples usually focus on applica-
tions related to handling small input that can be compressed
predict(x) update(x, y) easily, such as text. Text can easily be compressed using
vocabulary dictionaries or with common shared encoders such
as the Universal Sentence Encoder in [11]. Complex models
Fig. 1. Adding data consists of 3 steps. (1) The IncentiveMechanism validates such as deep neural networks capable of processing images
the transaction, for instance, in some cases a “stake” or monetary deposit is
required. (2) The DataHandler stores data and meta-data onto the blockchain.
may be costly to store and update using Ethereum. Just
This ensures that it is accessible for all future uses, not limited to this smart uploading the raw images would be costly. For example,
contract. (3) The machine learning model is updated according to predefined
training algorithms. In addition to adding data, anyone can query the model 1 E.g. many solutions using Proof-of-Stake (PoS) such as in Tendermint
for predictions, and the incentive mechanism may be triggered to provide [5] and the Casper system for Ethereum [6] involve staking a deposit to be
users with monetary payments or virtual “karma” points. considered eligible to participate.
uploading all of the popular MNIST dataset of handwritten A. Gamification
digits would cost about 275 ether at a modest gas price of
4gwei according to [2]. At the time of this writing (May We first propose a baseline with no financial incentives in
2019) that is about 65,000USD. Of course this cost would any form with the goal of reducing the barrier to entry. This
be amortized amongst all data contributors. is the Wikipedia [14] for Models & Datasets. This proposal
relies solely on the willingness of contributors to collaborate
The transactions could incur high gas costs especially for
for free, for a common good.
the initial model deployment if the model or smart contract
is large. With high gas costs it is possible that nodes will Additionally, points and optionally badges can be awarded
reject the transaction. Currently (May 2019) Ethereum has a to data contributors, i.e. stackexchangification [15]. Badges in
limit of around 8 million gas. In our experiments 8M gas is Stack Exchange have been shown to be effective by [16]. The
enough to deploy simple models and to submit complex data points and badges can be recorded on-chain in a smart contract
samples. Even if the entire model is too large to submit when using the contributor’s wallet address as a key or identification.
the contract is first deployed, the model can be added to the Here are some examples of measurements for awarding points
contract in several transactions after the contract is created. or badges to a user:
• a specified number of data samples has been contributed
C. Experiment • submitting diverse data samples
• submitting data with different labels
We trained a single layer perceptron model [12] on the • submitting data routinely (e.g. weekly)
IMDB reviews dataset introduced in [13]. The model has 100
Further experiments must be done into how these metrics
binary features which are the presence of the 100 common
can be explicitly computed efficiently on-chain or expanded
words used in the dataset. Thus 100 weights are initially
off-chain.
deployed with the model. Table I shows the gas cost for various
interactions with the model, h, using the Ethereum blockchain.
When data is added, x is the features and y is the label B. Rewards Mechanism Based on Prediction Markets
assigned to x. The gas costs for adding data are calculated
by adding data via the main contract entry point (not directly In this section, we describe a monetary reward-based system
to the model contract). When using more features, initial for incentivizing contribution of correct data. This design
deployment cost increases but the cost to add data is similar extends proposals of [17] and [18] for collaborative machine
because the features in data have a sparse representation. learning contests. An outside party, such as an academic
institution or a company, provides (1) a pool of reward funds
and (2) a test dataset. Participants are rewarded according to
III. I NCENTIVE M ECHANISMS how well they improve the model’s performance as measured
by the test data.
The proposed incentive mechanisms (IM) encourage con-
When this provider is available, we will be able to give
tributors to submit data that will improve the model’s accuracy.
very robust incentives for participation. The mechanism is
This can be measured in various ways. The most natural proxy
also resilient against manipulative or malicious providers and
is to measure the performance with respect to a specific test
participants. For cases where there is no outside party, we
set. We will also discuss ways to measure performance if a
suggest the mechanism in section III-C.
test set cannot be provided. The purpose of this paper is to
present the general framework with motivating examples, as 1) Overview: The mechanism is given in Fig. 2. There are
such, each incentive mechanism will be analysed further in three phases. In the commitment phase, the provider deposits
future work. the bounty and defines a loss function L(h, D). This is a
measure of loss (or a surrogate or proxy metric) of any model
We refer to good data in the following sections as data that
h on any dataset D (typically the average loss on points in
is objectively correct. E.g. for a picture of the number 1, the
the dataset). Finally, the provider cryptographically commits
label “1” is clearly better than the label “0”. Data can also be
to a test dataset, a small random fraction of which is initially
bad (i.e. wrong) or ambiguous.
revealed, similar to how data is revealed in [2].
In the participation phase, people add data or otherwise
TABLE I
provide updates to the model. Each participant is required to
G AS C OSTS deposit or “stake” 1 unit of currency along with their update.2
After an end condition is met (such as a maximum time limit
Action Gas Cost USDb or amount of data), this phase ends. A new cycle can begin if
Deploy model contract 3,845,840 $4.06 a new provider decides to commit new test data.
Add data with 15 words (h(x) = y)a 177,693 $0.19
Add data with 15 words (h(x) 6= y)a 249,037 $0.26
a Perceptron models are only updated when h(x) 6= y. 2 For the purposes of this description, each interaction is considered a
b In May 2019 with a modest gas price of 4gwei. separate participant. This is useful because participants cannot gain anything
by creating false identities.
A. Commitment Phase incentivized to provide data that is as useful as possible relative
1: Provider deposits B units of currency. to the (expected) test set. (If ht performs worse than the
2: Provider defines a loss function L(h, D). previous model, t loses some or all of their stake.) In total, the
3: Provider secretly divides a test dataset into 100 equal parts smart contract pays out a net amount of L(h0 , D)−L(hT , D),
and uploads their 100 cryptographic hashes. which is the total improvement from all contributions. It is at
4: Smart contract randomly selects 10 of these hashes. most 1 by assumption on the loss function.
5: Provider uploads 10 partial datasets. If they do not match Finally, we must scale this mechanism for a bounty of B 
the 10 hashes, abort. 1. The approach of [17] would require that all participants
6: Provider specifies end condition (e.g. time limit). stake B, which is infeasible. Therefore, instead, we use the
B. Participation Phase approach of iterating the mechanism B times. Each iteration,
1: Smart contract contains an initial model, h0 . the participant stakes 1 unit, then receives a reward. If she can
2: for each participant t = 1, 2, . . . , T until end condition is no longer stake 1 unit due to losses, she drops out.4 Although
met: do this is slightly complex, it still remains that the better ht , the
3: Participant deposits a stake of 1 unit of currency more reward t gets, so we believe incentives for participation
4: Participant provides data. are strongly aligned.
5: Model is updated from ht−1 to ht . 3) Untrusted provider, commitment, and value burning:
C. Reward Phase The provider can potentially manipulate by first, the choice
1: Provider uploads 90 partial datasets; call them D. If they of dataset, and second, by participating or partnering with
do not match the remaining 90 hashes, abort. some participants. As we describe next, the defenses against
2: Let bt = 1 for all t // balance initially equals stake manipulation are the cryptographic commitment scheme along
3: Let list S = (1, . . . , T ) // list initially contains everyone with value “burning”, which occurs when some value that was
4: for i = 1, . . . , B do deposited to the smart contract is not returned to anyone.
5: for each participant t in S do The cryptographic commitment scheme forces the provider
6: Let t0 be previous participant in S, or 0 if none. to reveal in advance a random 10% of the dataset (of course,
7: Participant t’s balance is changed: the numbers of 10 and 100 can be adjusted as desired). If
the provider does not comply, the process is aborted and the
bt ← bt + L(ht0 , D) − L(ht , D)
reward B stays stuck in the contract (not refunded). Assuming
8: Let list S = (t ∈ S : bt ≥ 1). // all who can re-stake the provider complies, participants learn something about the
1 stay in S final dataset. This prevents the following problematic attack:
the provider secretly chooses a dataset with incorrect labels,
9: Each participant t is paid bt .
then participates anonymously with corresponding updates.
Fig. 2. Bounty-based Incentive Mechanism. We use h to denote a machine The provider could then not only gain back most of the original
learning model and D for a dataset. The loss function L(h, D) is clipped to reward, but also earn significant amounts from the stakes of
the range [0, 1] by the smart contract.
the honest participants, which they would lose because their
data is not helpful for this test set. The commitment scheme
In the reward phase, the provider uploads the test dataset reveals a representative part of the test set up front, so that
and the smart contract checks that it satisfies the commitment.3 participants would likely be alerted to such an attack and
Then, the smart contract determines rewards for all partici- refuse to participate.
pants, as discussed next. At the end of the process, a significant amount of the
2) Reward calculation.: First imagine that the bounty B = original bounty is likely to remain stuck in the contract.
1, so that each participant t’s reward is their stake plus the Specifically, only the following amount is distributed:
following number:
B · [L(h0 , D) − L(hT , D)] . (2)
L(ht−1 , D) − L(ht , D). (1)
This is exactly the reward function proposed in [17], based While this is not ideal, the benefit is that there is no incentive
on automated-market-maker or scoring-rule based prediction for the provider to choose an incorrect dataset in hopes of
markets [19]. It can be pictured as follows: The smart contract having significant value left over. The smart contract could
first pays L(h0 , D) to the first participant. Their data updated instead donate left over funds to some predetermined account
the model to h1 , so they pay L(h1 , D) to the second partici- (such as a charity), but that would be open to manipulation.
pant. This continues down the line until the last participant In summary, the provider must expect to lose the entire
pays L(hT , D) back to the smart contract. The better ht bounty. Therefore, it will only participate if the benefit from
performs, the less participant t has to pay forward, so they are
3 We note that, because the test data is not uploaded until the end, 4 Of course, our mechanism can be modified to allow participants to stake
participants do not see the current performance of the model on the final more than 1 unit in order to cover more losses, but it is not clear if this would
test set and cannot overfit to it. be beneficial to them.
the trained model is worth this cost, so that only honest Very sensitive models could allow malicious contributors
providers have an incentive to join.5 to claim refunds for “bad” data before another contributor
has a chance to “correct” their bad submission. Such models
C. Deposit, Refund, and Take: Self-Assessment should also require a deposit high enough to dissuade bursts
of malicious data submissions. Special care needs to be taken
Ideally, one could enforce a fine or penalty on those submit-
and experiments should be done before setting t.
ting bad data. One way to determine if data is bad is to have
Certainly t does not have to be constant. It could somehow
other contributors validate it as is common in conventional
depend on the provided data sample, frequency of data sub-
crowdsourcing methods. However, enforcing a penalty at a
mitted, or even the certainty of the model on the data point.
later time via a smart contract is difficult as established in
I.e. if the model has a measure of probability of correctness,
section I-C. To facilitate penalties, this proposal enforces a
P (h(x) = y), for submission (x, y) then it can be used to
deposit when contributing data.
reduce t because it’s unlikely to be changed later.
This IM is an alternative where one does not need to
rely on a benevolent agent to submit a test set as described 1
t∝
previously. Instead it is possible to rely on the data contributors P (h(x) = y)
to indirectly validate and pay each other. As a proxy to verify 2) Varying Deposit: Requiring a deposit has a few goals:
data, we propose using the deployed model, h, to validate new • Introduce value to the system allowing others the chance
contributions. The caveat is that the initially deployed model to profit after they have contributed correct data.
needs to already be trained and generally already correctly • Inhibit too frequent changes to the model.
classify samples with some accepted degree of accuracy. • Reduce spam (incorrect or invalid data).
Here are the highlights of the proposal: To achieve these goals we propose
• Deploy a model, h, already trained with some data. 1
• Deposit: Each data contribution with data x and label y d∝
time since last update
also requires a deposit, d. Data and meta-data for each
contribution is stored in the data handler. I.e. it is costly for contributors to send many updates in a short
• Refund: To claim a refund on their deposit, after a time t amount of time. This should give those using the prediction
has passed and if the current model, h, still agrees with function of the models a more consistent experience. E.g.
the originally submitted classification, i.e. if h(x) == consider a personal assistant in one’s home that behaves too
y, then the contributor can have their entire deposit d differently to the same spoken request uttered several times a
returned. day, such as a request to play the news.
3) Taking Another’s Deposit: We introduce some guide-
– We now assume that (x, y) is “good” data.
lines for a contributor that is reporting “bad” data to take
– The successful return of the deposit should be
some of the deposit from the original contributor, c. Note that
recorded in a tally of points for the wallet address.
contributed data and meta-data about it can be found in the
• Take: A contributor that has already had data validated in data handler or emitted events.
the Refund stage can locate a data point (x, y) for which First some definitions:
h(x) 6= y and request to take a portion of the deposit, d, • Let r(cr , d) be the reward that the contributing reporter,
originally given when (x, y) was submitted. cr receives for reporting data (x, y) with deposit d.
If the sample submitted, (x, y) is incorrect or invalid, then • Let n(c) be the number of data samples for which
within time t, other contributors should submit (x, y 0 ) where contributor c received a refund (assumed good data).
y 0 is the correct or at least generally preferred label for x Guidelines:
and y 0 6= y. This is similar to how one generally expects bad • h(x) 6= y: The current model disagrees with the label.
edits to popular Wikipedia articles to be corrected in a timely So we assume the data is “bad”.
manner. • n(cr ) > 0: The reporter should have already had data
1) Time to Wait for Refund: The creator of the contract refunded. This enforces that they hopefully already sub-
must select, t, how much time contributors need to wait before mitted “good” data before they can try to profit from the
they can claim a refund on their deposit. As a guideline, we system.
propose setting t to be enough time for other contributors to • cr 6= c: The reporter cannot be the original contributor.
submit corrections with different labels if they disagree with Otherwise contributors can easily attempt to reclaim their
the data. For example, t ≥ one week. deposit for “bad” data.
Models that are not very sensitive might need to allow more • The reward should be shared amongst “good” contribu-
time to pass in order for enough samples to be provided to tors.
teach the model about a new use case. n(cr )
r(cr , d) ∝ d × P (3)
all c n(c)
5 A colleague points out that a provider may be able to gain back some of
the bounty by participating using the portion of the initially revealed test set. – This protects against Sybil attacks where a contrib-
However, this is not harmful to the final performance of the model. utor can use a second account to take back their
entire deposit. They can still claim back some of the remaining 92% of the training data over time. Details for
their reward from another account but they will have the simulation can be found with our source code.
to wait and get refunded for some “good” data using
that other account. IV. I MPLEMENTATION
• r(cr , d) >  > 0: The reward should be at least some In this section we discuss some implementation details for
minimal value to cover potential transaction costs. our proposed framework.
• The data handler must keep track of the remaining deposit
that can be claimed, dr ≤ d. A. Floating Point Numbers
dr ← dr − r(cr , d) In our examples we use integers for data representations
because Ethereum does not support floating point numbers.
r(cr , d) ≤ dr ≤ d Whenever we expect a floating point number, we take in an
• Since n(c) changes over time, the ratio in (3) changes integer that has already been multiplied by some value, e.g.
while reporters are claiming their share of d. Therefore, 109 (9 decimal places of precision). All operations are done
it possible that some reporters get a smaller proportion of considering this transformation.
d. We discuss some possible solutions to this in III-C5.
B. Inversion of Control
4) Biasing the Model: With the proposal, contributors can
be tempted to only submit data the model already agrees with To favor clarity and ease development, our examples use the
(h(x) = y) at submission time and hope the model still agrees Inversion of Control [20] principle favoring composition over
with at refund time. This could create a bias in the model inheritance. In Ethereum smart contracts using inheritance can
towards data it already “knows”. Contributors would normally be cheaper than ones using composition according to [21].
still have to pay a transaction fee so in effect they still pay a Some subtleties such as ownership and publicity of contained
nominal fee to deposit and claim their refund. The model and contracts need to be considered. Fig. 4 shows a class diagram
training method must be carefully chosen and the designer can for the proposed framework.
consider how to handle duplicate or similar data. The IM can Since the model will exist as its own contract it will need
even reject too much duplicate or similar data. to have its update method exposed publicly. Only the owner
5) Preventing Lock-ups: In this section we discuss ways to of the model (the CollaborativeTrainer) can call the model’s
avoid funds getting “locked-up“ or “stuck inside” the smart update method because this owner is responsible for using the
contract. It is possible that contributors omit to collect their incentive mechanism.
refunds or that contributors do not take their portion of the
V. B ENEFITS OF B LOCKCHAIN
deposit leaving value “stuck inside” the contract. To avoid
this we introduce two new parameters: Using a blockchain (such as Ethereum [4]) provides us with
• tc : The amount of time the creator has to wait to take the many advantages compared to traditional source code hosting
entire remaining refund (dr ) for a specific contribution. and deployment:
Where tc > t. Additionally, this gives creators some
incentive to deploy a model as they may get a chance to
claim a significant portion of d. Contracts may want to
enforce that this is much greater than the amount of time
to wait for attempting a refund, which gives contributors
even more time to get the deposit back and not allow the
creator take too much (tc  t).
• ta : The amount of time anyone has to wait to take the
entire remaining refund (dr ). Where ta ≥ tc > t. in case
the creator omits to take “stuck” value from the contract.
Certainly there can be more variants of these such as a value,
td , for data contributors with refunded submissions (n(c) > 0)
where ta ≥ td ≥ tc .
6) Experiment: We developed simulations to test parame-
ters for incentive mechanisms and models. For one simulation,
we initially trained a Perceptron model [12] with 8% of
the IMDB reviews training dataset introduced in [13]. The
model has 1000 binary features which are the presence of
the 1000 most frequent words in the dataset. Fig 3 shows Fig. 3. Balance percentages and model accuracy in a simulation where an
adversary, ”Bad Agent” is willing to spend about twice as much on deposits
the results of a simulation where for simplicity, we show just than an honest contributor, ”Good Agent”. The adversary is only submitting
one honest contributor and one malicious contributor but these data about one sixth as often. Despite the malicious efforts, the accuracy can
contributors effectively represent many contributors submitting still be maintained and the honest contributors profit.
A. Public, Persistent & Decentralized Response: The incentive mechanism should make it
The model is a shared and publicly visible resource. One costly and unbeneficial to submit bad data. Furthermore, many
can essentially trust that the model will persist and be available blockchains have transactions fees making it very costly to
on one of many decentralized nodes. submit a lot of data. Even if a model is corrupted, the users
of the model can just revert back to an earlier version of the
B. Versioning model since it is on a blockchain. Additionally, analysis can
It is easy to revert to an earlier version of the model by be done to salvage “good” data already submitted.
only updating your node’s version of the blockchain up to the
B. Ambiguous Data
particular block where your application is satisfied with the
model, possibly measuring performance with respect to one’s Those using this framework must carefully consider the type
own hidden test set. of model, IM, and how submitting ambiguous data can affect
the system. For example, the sentiment of “The movie is okay”
C. Models Evolve Over Time if the options for the label are “happy” or “sad”. Ambiguous
Smart contracts on a blockchain allow models to evolve as data is always an issue when crowdsourcing but is especially
the environment changes, for example recognize novel words. concerning here since contributors can lose funds. It is safest
for contributors to keep their data unambiguous.
D. Transparency & Trust
Typically a machine learning or data collection service C. Overwhelming the Network
would be set up with a REST API or some other system where Some applications relying on public blockchains have had
users interface with code running on some servers. Users can reliability issues due to network congestion. This can be an
submit or request data from the servers but there is no way issue for this framework when adding data which requires
for the user can be completely certain of the source code creating new transactions. Inference should not be affected
running on the servers. Code running in an Ethereum smart because running inference just involves reading which is
contract is completely public and the result of a particular normally free and can be done locally with the latest local
execution can be deterministically evaluated. Essentially, data version of the model.
contributors can trust that the model updates and that they will
be compensated for their contributions. D. Requiring a Deposit
Many new contributors might not be familiar with the estab-
VI. P OTENTIAL I SSUES lished practice of blockchain applications requiring a deposit.
Data contributors and smart contract creators should con- Small fees are already required to process any transaction in
sider several vulnerabilities when using our framework. Many most of the popular blockchains such as Bitcoin [22] and
possible issues have already been addressed for systems with Ethereum [4].
static models in [2]. This section analyzes issues specific to There are some ways to hide these fees from end users. A
systems where models can be trained. third-party can hide the deposit cost by providing their own
A. Submitting Bad Data interface to a public system and validating data contributions
themselves. Perhaps this third party believes they have algo-
A wealthy and determined agent can corrupt a model rithms and better means to validate data. They could then
deployed by submitting incorrect or nonsensical training data. reward users under their own scheme which may not even
involve financial incentives.

CollaborativeTrainer
VII. F UTURE W ORK
...
There are a few areas where the presented framework can
+addData(...) be configured and built upon.
A. Models
IncentiveMechanism DataHandler Model
More research needs to be done on the types of models that
... +addedData:mapping ...
will work well within this framework.
+@handleAddData(...) +@handleAddData(...) +@update(...)
+predict(...) 1) Unsupervised Models: The examples discussed mainly
use supervised classifiers because we focus on validating data
Ownable with labels. Test sets and incentive mechanisms to validate the
data contributions can still be used with unsupervised models.
+owner:address (read-only)
+@transfer(newOwner:address)
Some examples are:
[modifier] +onlyOwner() [@] • Clustering: Developing clustering models especially for
outlier detection can be very useful.
• Generative models such as autoencoders and GANs. For
Fig. 4. Overview of the class diagram for the framework; other members and
methods exist. We use “@” before a method to indicate that only the owner example, a model could be built that attempts to generate
may call the method. text or draw pictures.
2) Complex Models: There are cost limitations as described Currently, this framework is mainly designed for models that
in section II-B. We propose more research in pre-computing can be efficiently updated but we hope to see future research
as much as possible off-chain and only performing necessary in scaling to more complex models.
steps in a smart contract. Techniques such as fine-tuning (in the
transfer learning field) [23] or off-chain training as proposed ACKNOWLEDGEMENT
for DeepChain [24] can help. One can use a common encoder The authors would like to thank William Buchwalter for
(shared in more conventional ways such as via web APIs or believing in the ideas initially and helping to implement
publicly posting source code to a website) off-chain to encode the first demos. Nicole Immorlica, Brendan Lucier, Dave
the input and then fine-tune the encoded result on-chain with Pennock, and Glen Weyl for discussions and suggestions.
a simple neural network or even just a single layer. While the Adam Atkinson, Hannes Schulz, Kaheer Suleman, and Jaclyn
encoder should be static, it is possible for it to change slightly Hearnden for giving detailed feedback on the paper.
as long as the input to the fine-tuning component is similar
enough to previously seen training data. R EFERENCES
Complex models can even be interfaced via an API through [1] A. Marathe, K. Narayanan, A. Gupta, and M. Pr, “DInEMMo: Decentral-
ized incentivization for enterprise marketplace models,” 2018 IEEE 25th
the smart contract using a system such as Provable (formerly International Conference on High Performance Computing Workshops
Oraclize) [25]. Hiding the model behind an API means the (HiPCW), pp. 95–100, 2018.
model is not necessarily public which is not in the spirit of this [2] A. B. Kurtulmus and K. Daniel, “Trustless machine learning
contracts; evaluating and exchanging machine learning models
proposal. Complex models can also be built up by combining on the ethereum blockchain,” 2018. [Online]. Available: https:
several “layers” of smart contracts using this framework. //algorithmia.com/research/ml-models-on-blockchain
3) Recovering Corrupted Models: Work can be done in [3] F. Daniel, P. Kucherbaev, C. Cappiello, B. Benatallah, and
M. Allahbakhsh, “Quality control in crowdsourcing: A survey
how to recover a model corrupted by bad data (as described of quality attributes, assessment techniques and assurance
in section VI-A). Once a dataset is collected it can be further actions,” CoRR, vol. abs/1801.02546, 2018. [Online]. Available:
refined through various methods (e.g. clustering data). The http://arxiv.org/abs/1801.02546
[4] V. Buterin, “A next generation smart contract & decentralized application
cleaned dataset can be used to train a new model. This new platform,” 2015.
model could be kept private by those that organize cleaning [5] J. Kwon, “Tendermint: Consensus without mining,” 2014.
efforts and used in their production system. The model could [6] V. Buterin and V. Griffith, “Casper the friendly finality gadget,” 2017.
[7] J. Lafferty, A. McCallum, and F. C. Pereira, “Conditional random fields:
also be used to start a new instance of the collaborative training Probabilistic models for segmenting and labeling sequence data,” 2001.
process and collect more training data. [8] C. Cortes and V. Vapnik, “Support-vector networks,” Machine
Learning, vol. 20, no. 3, pp. 273–297, Sep 1995. [Online]. Available:
B. Incentive Mechanisms https://doi.org/10.1007/BF00994018
[9] J. C. Schlimmer and D. Fisher, “A case study of incremental concept
More exploration, analysis, and experiments with incentive induction,” in Proceedings of the Fifth AAAI National Conference on
mechanisms in this space needs to be done with emphasis on Artificial Intelligence, ser. AAAI’86. AAAI Press, 1986, pp. 496–501.
the type of model each incentive mechanism works well with. [Online]. Available: http://dl.acm.org/citation.cfm?id=2887770.2887853
[10] C. D. Manning, P. Raghavan, and H. Schütze, Introduction to In-
The incentive mechanisms imposed by the smart contract formation Retrieval. Cambridge University Press, 2008, ch. Vector
could be hidden to end users by 3rd party services that space classification, http://nlp.stanford.edu/IR-book/html/htmledition/
build services around this proposed framework. These services rocchio-classification-1.html.
[11] D. Cer, Y. Yang, S. yi Kong, N. Hua, N. Limtiaco, R. S. John,
could validate data contribution themselves offering their own N. Constant, M. Guajardo-Cespedes, S. Yuan, C. Tar, Y.-H. Sung,
rewards to users of their platforms that do not wish to interact B. Strope, and R. Kurzweil, “Universal sentence encoder,” 2018.
with these smart contracts. [12] F. Rosenblatt, “The perceptron: a probabilistic model for information
storage and organization in the brain,” Psychological Review, vol. 65,
no. 6, p. 386, 1958.
C. Privacy [13] A. L. Maas, R. E. Daly, P. T. Pham, D. Huang, A. Y. Ng, and C. Potts,
Contributors may not want to publish their data to a public “Learning word vectors for sentiment analysis,” in Proceedings of the
49th Annual Meeting of the Association for Computational Linguistics:
blockchain. Initially we propose to only use this for framework Human Language Technologies. Portland, Oregon, USA: Association
for data that is safe to become public. E.g. certain queries to for Computational Linguistics, June 2011, pp. 142–150. [Online].
a personal assistant such as, “What will the weather be like Available: http://www.aclweb.org/anthology/P11-1015
[14] Wikipedia contributors, “Wikipedia — Wikipedia, the free ency-
tomorrow?”, which contains no personal data. clopedia,” https://en.wikipedia.org/w/index.php?title=Wikipedia&oldid=
Future work can be done to not submit data directly to 889379633, 2019, [Online; accessed 25-March-2019].
the smart contract and instead just submit model updates as [15] Stack Exchange contributors, “Stack exchange,” https://stackexchange.
com, 2019, [Online; accessed 25-March-2019].
discussed in section VII-A2 and in DeepChain [24]. [16] B. Bornfeld and S. Rafaeli, “Gamifying with badges: A big data
natural experiment on stack exchange,” First Monday, vol. 22,
VIII. C ONCLUSION no. 6, 2017. [Online]. Available: https://firstmonday.org/ojs/index.php/
fm/article/view/7299
We have presented a configurable framework for training [17] J. D. Abernethy and R. M. Frongillo, “A collaborative mechanism for
a model and collecting data on a blockchain by leveraging crowdsourcing prediction problems,” in Advances in Neural Information
several baseline incentive mechanisms and existing types of Processing Systems 25, ser. NeurIPS ’11, 2011, pp. 2600–2608.
[18] B. Waggoner, R. Frongillo, and J. D. Abernethy, “A market framework
machine learning models for incremental learning. Ideal sce- for eliciting private data,” in Advances in Neural Information Processing
narios have varying data with generally agreed upon labels. Systems 28, ser. NeurIPS ’15, 2015, pp. 3492–3500.
[19] R. Hanson, “Combinatorial information market design,” Information
Systems Frontiers, vol. 5, no. 1, pp. 107–119, 2003.
[20] Wikipedia contributors, “Inversion of control — Wikipedia, the free
encyclopedia,” https://en.wikipedia.org/w/index.php?title=Inversion of
control&oldid=885334776, 2019, [Online; accessed 27-March-2019].
[21] Sergii Bomko, “Composition over inheritance - gas efficiency,” https://
ethereum.stackexchange.com/a/60244/9564, 2018, [Online; accessed 27-
March-2019].
[22] S. Nakamoto et al., “Bitcoin: A peer-to-peer electronic cash system,”
2008.
[23] Y. Bengio, “Deep learning of representations for unsupervised and
transfer learning,” in Proceedings of ICML Workshop on Unsupervised
and Transfer Learning, 2012, pp. 17–36.
[24] J.-S. Weng, J. Weng, M. Li, Y. Zhang, and W. Luo, “DeepChain:
Auditable and privacy-preserving deep learning with blockchain-based
incentive,” IACR Cryptology ePrint Archive, vol. 2018, p. 679, 2018.
[25] Provable, “Provable - Oraclize 2.0 - blockchain oracle service, enabling
data-rich smart contracts,” https://provable.xyz/, 2019, [Online; accessed
5-April-2019].

You might also like