Vanna Labs
  • Introduction
    • 👋Welcome
    • ✨Summary
  • Vision
    • 🏪The AI One-Stop-Shop
      • AI Models on Vanna
      • Applied ML on Vanna
    • 🤝Interoperability
    • ✅Computational Verifiability
    • 🌐Decentralization
    • 🛡️Censorship Resistance
  • Vanna Network
    • 🏗️Architecture
      • Data Preprocessing
      • Parallelized Inference Pre-Execution (PIPE)
      • Validation-Computation Separation (VCS)
      • Cryptoeconomic Security
      • Modular Design
    • ⚙️Inference Modes
      • Vanilla Inference
      • zkML Inference
      • zkFP Inference
      • opML Inference
      • TEE Inference
    • 💿Data Storage
      • Model Storage
      • Data Availability
    • 💻Portal
  • Build
    • 🛠️Getting started
      • Networks
      • Faucets
      • Model Storage
    • 💻Building dApps
      • Data Preprocessing
      • Inference API
      • Inference Example
    • 💾Models
      • Supported LLMs
  • 🔗Links
  • Key Concepts
    • 🧠AI x Blockchain
    • 📜Optimistic Rollups
    • 💾Data Availability
    • ⚡zkML
    • ☀️opML
Powered by GitBook
On this page
  1. Vanna Network
  2. Inference Modes

zkML Inference

PreviousVanilla InferenceNextzkFP Inference

Last updated 1 year ago

zkML inference represents running inference on an AI or ML model in Vanna's decentralized filestore, where a will also be generated and validated by the nodes on the Vanna Network. The proof will be available on the data availability layer, which can be queried through our inference transaction explorer.

In order to run zkML inference, you need to implement the ArbInference interface for inferCallZK.

model - The IPFS CID for the model

input - The input parameters to the inference request

function inferCallZK(bytes memory model, bytes memory input) external returns (bytes memory);

Below is an example of a minimal smart contract that runs zkML inference:

ArbInference.sol
pragma solidity >=0.4.21 <0.9.0;

/// @title Infer Call
/// @notice This contract is used to run on-chain inference.
/// This custom contract will set on 0x000000000000000000000000000000000000011a since we set it in precompile.go.
interface ArbInference {
    function inferCall(bytes memory model, bytes memory input) external returns (bytes memory);
    function inferCallZK(bytes memory model, bytes memory input) external returns (bytes memory);
}
zkMLInference.sol
pragma solidity ^0.8.18;

import "contracts/ArbInference.sol";

contract zkMLInference {
    string value;

    function zkInfer(
        string calldata modelName,
        string calldata inputData
    ) public {
        value = string(abi.encodePacked(ArbInference(address(0x11a)).inferCallZK(abi.encodePacked(modelName), abi.encodePacked(inputData))));
    }
    
    function getValue() public view returns (string memory) {
        return value;
    }
}
⚙️
ZK-SNARK