arXiv:2503.06203cs.ETcs.LG2025-03被引 7

用大模型将机器学习模型转为可上链运行的优化Solidity代码

Generation of Optimized Solidity Code for Machine Learning Models using LLMs

  • 利用大模型将离线训练的ML模型推理路径与权重转为Solidity代码
  • 通过提示工程优化生成代码的Gas消耗,兼顾EVM性能限制
  • 验证了模型上链可行,适合区块链可信计算场景

尽管现有大量机器学习(ML)模型及其跨平台实现,但几乎不存在可在公共区块链上执行的可验证ML代码。我们提出一种名为LMST的新方法,利用大语言模型(LLMs)将离线训练的ML模型的推理路径及其权重转换为Solidity代码。通过深入的提示工程,在保证代码正确性的基础上,进一步优化生成代码的Gas成本,同时考虑以太坊虚拟机(EVM)的能力与限制。我们还基于生成的代码开发了一个去中心化应用原型,用于验证底层ML模型的准确性声明。大量实验表明,通过大模型自动化翻译,实现机器学习模型在区块链上的部署是可行的。

原文摘要 · Abstract (English)

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.

机器学习区块链大模型Solidity

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。