Git Product home page Git Product logo

oao's Introduction

OAO: Onchain AI Oracle

OAO (onchain AI oracle), powered by opML (optimistic machine learning) on Ethereum, brings ML model onchain.

Architecture and Workflow

The specific architecture of OAO is as follows. The user's contract can initiate an AI request by calling OAO, OAO will publish the request to opML node for processing, and then OAO will return the AI result to the user.

OAO Workflow

In terms of workflow, we need to break down the explanation into two parts.

Usage process:

  1. The user contract sends the AI request to OAO on chain, by calling requestCallback function on the OAO contract.

  2. Each AI request will initiate an opML request.

  3. OAO will emit a requestCallback event which will be collected by opML node.

  4. opML node will run the AI inference, and then upload the result on chain.

    Challenge process:

    1. The challenge window starts right after step 4 in previous section.
    2. During the challenge period, the opML validators (or anyone) will be able to check the result and challenge it if the submitted result is incorrect.
    3. If the submitted result is successfully challenged by one of the validators, the submitted result will be updated on chain.
    4. After the challenge period, the submitted result on chain is finalized (results can not be mutated).
  5. When the result is uploaded or updated on chain, the provided result in opML will be dispatched to the user's smart contract via its specific callback function.

Deployment

Here are the OAO contracts deployed onchain:

Currently, you can use the onchain ML model by initiating an onchain transaction by interacting with Prompt contract. We have uploaded two models to OAO.

modelID model
11 llama
50 Stable Diffusion (SD)

Usage

  1. Inherit AIOracleCallbackReceiver in your contract and bind with a specific OAO address:
    constructor(IAIOracle _aiOracle) AIOracleCallbackReceiver(_aiOracle) {}
  2. Write your callback function to handle the AI result from OAO. Note that only OAO can call this function:
    function aiOracleCallback(uint256 requestId, bytes calldata output, bytes calldata callbackData) external override onlyAIOracleCallback()
  3. When you want to initiate an AI inference request, call OAO as follows:
    aiOracle.requestCallback(modelId, input, address(this), gas_limit, callbackData);

oao's People

Contributors

0x1cc avatar roodeag avatar

Stargazers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.