ML2SC: Deploying Machine Learning Models as Smart Contracts on the Blockchain

作者
Zhikai Li,Steve Vott,Bhaskar Krishnamachar
出处
期刊:Cornell University - arXiv [Cornell University]
被引量:1
标识
DOI:10.48550/arxiv.2404.16967
摘要

With the growing concern of AI safety, there is a need to trust the computations done by machine learning (ML) models. Blockchain technology, known for recording data and running computations transparently and in a tamper-proof manner, can offer this trust. One significant challenge in deploying ML Classifiers on-chain is that while ML models are typically written in Python using an ML library such as Pytorch, smart contracts deployed on EVM-compatible blockchains are written in Solidity. We introduce Machine Learning to Smart Contract (ML2SC), a PyTorch to Solidity translator that can automatically translate multi-layer perceptron (MLP) models written in Pytorch to Solidity smart contract versions. ML2SC uses a fixed-point math library to approximate floating-point computation. After deploying the generated smart contract, we can train our models off-chain using PyTorch and then further transfer the acquired weights and biases to the smart contract using a function call. Finally, the model inference can also be done with a function call providing the input. We mathematically model the gas costs associated with deploying, updating model parameters, and running inference on these models on-chain, showing that the gas costs increase linearly in various parameters associated with an MLP. We present empirical results matching our modeling. We also evaluate the classification accuracy showing that the outputs obtained by our transparent on-chain implementation are identical to the original off-chain implementation with Pytorch.

科研通智能强力驱动
Strongly Powered by AbleSci AI
科研通是完全免费的文献互助平台,具备全网最快的应助速度,最高的求助完成率。 对每一个文献求助,科研通都将尽心尽力,给求助人一个满意的交代。
实时播报
刚刚
江江jiang完成签到,获得积分10
1秒前
3秒前
3秒前
陈哈哈完成签到,获得积分20
4秒前
舒心远侵发布了新的文献求助10
4秒前
5秒前
葛小坤完成签到,获得积分10
5秒前
5秒前
科研通AI6.4应助zr采纳,获得10
6秒前
陈秋完成签到,获得积分10
6秒前
怕黑半仙发布了新的文献求助30
6秒前
TAOS完成签到,获得积分10
7秒前
珉志完成签到,获得积分10
7秒前
陌儿发布了新的文献求助10
8秒前
林白完成签到,获得积分10
9秒前
helen完成签到,获得积分10
10秒前
10秒前
科研通AI6.2应助自觉之云采纳,获得10
10秒前
10秒前
11秒前
Orange应助自觉之云采纳,获得10
11秒前
充电宝应助稳重的妙菱采纳,获得10
12秒前
华仔应助vict采纳,获得10
12秒前
12秒前
13秒前
脑洞疼应助sean采纳,获得10
13秒前
小chen完成签到,获得积分10
13秒前
科研通AI6.4应助哈基伟采纳,获得10
14秒前
星辰大海应助yu采纳,获得10
15秒前
跳跃的乞完成签到 ,获得积分10
15秒前
SCI的李完成签到 ,获得积分10
15秒前
范范旻蔚发布了新的文献求助10
16秒前
动听衬衫完成签到 ,获得积分10
16秒前
jkj发布了新的文献求助10
16秒前
科研通AI6.4应助哈哈哈采纳,获得10
16秒前
17秒前
20秒前
20秒前
20秒前
高分求助中
(应助此贴封号)【重要!!请各用户(尤其是新用户)详细阅读】【科研通的精品贴汇总】 10000
内視鏡的に摘除しえた十二指腸乳頭部腫瘍の2例 660
On nonlinear stability of contact discontinuities. In: Hyperbolic problems: theory, numerics, applications (Stony Brook, NY, 1994) 510
Management and the Arts 510
Matrix Methods in Data Mining and Pattern Recognition Second Edition 510
微电子器件实验教程 400
The Neuroscience of Language 400
热门求助领域 (近24小时)
化学 材料科学 医学 生物 纳米技术 工程类 有机化学 化学工程 生物化学 计算机科学 内科学 物理 复合材料 催化作用 细胞生物学 无机化学 光电子学 物理化学 电极 基因
热门帖子
关注 科研通微信公众号,转发送积分 7678861
求助须知:如何正确求助?哪些是违规求助? 9243993
关于积分的说明 19927136
捐赠科研通 7249724
什么是DOI,文献DOI怎么找? 3287256
关于科研通互助平台的介绍 2444997
邀请新用户注册赠送积分活动 2290506