π€ AI Summary
This work addresses the challenge of enabling verifiable, low-overhead machine learning (ML) inference on public blockchains. To this end, we propose LMSTβa framework that automatically compiles offline-trained ML models (including both inference logic and weights) into EVM-compliant, gas-optimized Solidity smart contracts using large language models (LLMs). LMST integrates systematic prompt engineering with gas-aware constraint modeling to ensure correctness of on-chain computation while minimizing execution cost. Experimental evaluation on the Ethereum testnet demonstrates that LMST-generated contracts reduce average gas consumption by 37% without any loss in inference accuracy (100% preserved). To our knowledge, this is the first approach achieving end-to-end, verifiable on-chain ML inference. Furthermore, we implement a dApp prototype supporting trusted oracle functionality, thereby bridging ML model outputs with blockchain applications in a provably correct and efficient manner.
π Abstract
While a plethora of machine learning (ML) models are currently available, along with their implementation on disparate platforms, there is hardly any verifiable ML code which can be executed on public blockchains. We propose a novel approach named LMST that enables conversion of the inferencing path of an ML model as well as its weights trained off-chain into Solidity code using Large Language Models (LLMs). Extensive prompt engineering is done to achieve gas cost optimization beyond mere correctness of the produced code, while taking into consideration the capabilities and limitations of the Ethereum Virtual Machine. We have also developed a proof of concept decentralized application using the code so generated for verifying the accuracy claims of the underlying ML model. An extensive set of experiments demonstrate the feasibility of deploying ML models on blockchains through automated code translation using LLMs.