Skip to content
0x1cc edited this page Jul 19, 2023 · 3 revisions

OPML: Optimistic Machine Learning on Blockchain

TL;DR

  • We propose OPML (Optimistic Machine Learning), which enables AI model inference and training/fine-tuning on the blockchain system using optimistic approach.
  • OPML can provide ML service with low cost and high efficiency compared to ZKML. The participation requirement for OPML is low: We are now able to run OPML with a large language model, e.g., 7B-LLaMA (the model size is around 26GB) on a common PC without GPU.
  • OPML adopts a verification game (similar to Truebit and Optimistic Rollup systems) to guarantee decentralized and verifiable consensus on the ML service.
    • The requester first initiates an ML service task.
    • The server then finishes the ML service task and commits results on chain.
    • The verifier will validate the results. Suppose there exists a verifier who declares the results are wrong. It starts a verification game with bisection protocol with the server and tries to disprove the claim by pinpointing one concrete erroneous step.
    • Finally, arbitration about a single step will be conducted on smart contract.

Verification Game in OPML

The verification game of OPML works similarly to referred delegation of computation (RDoC), where two or more parties (with at least one honest party) are assumed to execute the same program. Then, the parties can challenge each other with a pinpoint style to locate the disputable step. The step is sent to a judge with weak computation power (smart contract on blockchain) for arbitration.

In OPML:

  • We build a virtual machine (VM) for off-chain execution and on-chain arbitration. We guarantee the equivalence of the off-chain VM and the on-chain VM implemented on smart contract.
  • To ensure the efficiency of AI model inference in the VM, we have implemented a lightweight DNN library specifically designed for this purpose instead of relying on popular ML frameworks like Tensorflow or PyTorch. Additionally, a script that can convert Tensorflow and PyTorch models to this lightweight library is provided.
  • The cross-compilation technology has been applied to compile the AI model inference code into the VM program instructions.
  • The VM image is managed with a Merkle tree, only the Merkle root will be uploaded to the on-chain smart contract. (the Merkle root stands for the VM state)
  • The bisection protocol will help to locate the dispute step, the step will be sent to the arbitration contract on the blockchain

Performance: We have tested a basic AI model (a DNN model for MNIST classification) on a PC. We are able to complete the DNN inference within 2 seconds in the VM, and the entire challenge process can be completed within 2 minutes in a local Ethereum test environment.

OPML vs ZKML

OPML ZKML
model size any size (available for extremely large model) small/limited (due to the cost of ZKP generation)
validity proof fraud proof zero-knowledge proof (ZKP)
training support ×
requirement Any PC with CPU/GPU Large memory for ZK circuit
Finality Delay for challenge period No delays
service cost low (inference and training can be conducted in native environment) extremely high (generating a ZKP for ML inference is extremely high)
security crypto-economic incentives for security cryptographic security
Clone this wiki locally