Chapter 2: Why Put Your AI On-Chain

Modulus Labs
8 min readAug 6, 2022

--

“Okay, okay…” I imagine you saying, having just read our first blog on the potential of putting AI On-Chain.

I know your dueling allegiances… on one side, the warm comfort of the status quo, and on the other, the tantalizing opportunities and uncertainties of the future.

“But wait!” — common sense now rushing back into you like a frozen river, quenching the flame of excitement that consumed all just moments ago — “what’s the good of validating AI on-chain? I get that rollups let you sidestep the compute barrier, but who needs powerful AI that’s also transparent and verifiable??” Or to put it more succinctly:

“Why?”

Wow. You read my mind perfectly. This is a special moment for you and me.

And yes, that is, in fact, a very good question. To be entirely frank in the interest of our budding relationship, it’s also not an entirely straightforward one to answer. After all, we’ve never had the opportunity to publicly verify AI inference before at any level of scale. That’s part of the excitement of being at the frontier, and something that’s ultimately unique to the blockchain architecture. This is also why we’ve labelled this moment a “huge leap forward” for web3 and the field of AI.

Thankfully, though, we don’t have to leap blindly into this future. Instead, we can build up the incoming “AI on-chain world” from definitions first. With those characteristics established, we can then understand the implications of this new potential paradigm, together (if you want to skip straight to the potential use-cases, the TLDR strategy would be to go straight to Step 3. Don’t worry, no judgement from us).

Grab ahold! We’re headed to the future!

One last note for today: given the speculative nature of a lot of what’s to come, we won’t be labeling our assumptions for this chapter.

Step 1: Definitions & Implications

A hugely important component of the post-rollup future of Ethereum (as discussed last week) is how it shapes the precise definition of “verification.” Or, to put it another way, rollups as a technology radically transforms what a block represents on the verified chain. Instead of transaction records, Starkware and Matter Labs (STARKs via Validity rollup in the former and SNARKs via zkSync for the latter) log bundled “proofs” of transactions, the computation of which are handled locally (on the “physical L2 layer”). This is already all of the building blocks that are needed for our first definition.

Complete verification: the ability to check the entirety of a sequence of computation instructions in a deterministic way. With the complete knowledge of all inputs to a particular function, this is exactly what SNARKs/STARKs do.

Now, framing last week’s proposed AI cross-over within this architecture, verification takes on a more precise meaning within the context of machine learning models:

Complete verification (AI): For a traditional ML model (e.g. a classifier), complete verification necessitates the publication (or public knowledge) of three things:
(1) The model architecture, normally encoded within the smart contract function itself
(2) The model weights, which need to be separately published and checked before running the inference, and
(3) The inputs, which will typically be public data from the chain, but which need to be published otherwise as well.

In other words, the black-box AI model is now, in an extremely specific and complete fashion, auditable via the chain. And while there remains some flexibility in how much of each aspect above is revealed (crypto hedge funds, as an example, may choose to hide their model weights to protect their alpha), when the model owner chooses to embrace “complete verification,” they attain the core feature we’re interested in today:

Trustless Autonomy — Given that all three characteristics of a model are transparent and on-chain, the entire execution of that (predictive, generative, etc.) ML model is deterministic and thus can be verified. Most importantly, this requires that the model operator mustn’t be able to switch out weights, architecture, or inputs, and thus can’t influence the final result.

To us, the creation of trustless, autonomous, and powerful AI models is the next logical evolution and most earnest cross-over between AI and Blockchain. Yes, we can now build a decentralized Kaggle or trustless AI oracles for the chain, but that’s really just the beginning. We’ll go into a bit more depth at the end, but imagine universe simulators with galactic AI governments, or replacing archaic public institutions with transparent, trustless, and intelligent agents running on-chain. And they, in one form or another, all result from Trustless Autonomy. Not too bad for one seemingly subtle technical milestone.

“Can’t be Evil” > “Don’t be Evil” — web3

Step 2: Beyond Trustless Autonomy?

I can tell you’re starting to get excited, but we’re really just getting rolling. On-chain AI enabled by the kind of architecture described in our last post may result in Trustless Autonomy, but that’s just one direction in which this technology may bring us. Below are some other interpretations of AI x Blockchain. Each row of the table represents a different interpretation of this cross-over, with a quick description in the second column and potential use cases (or scenarios in which the paradigm may be useful) in the third:

Other Potential Results of the AI Inference Verification Schema Discussed

Wow, that was a lot. Deep breaths; don’t worry. The future can come at you fast! Although we have been kicking the proverbial can down the proverbial road for some time now. Let’s get to the rampant speculation *cough cough* I mean areas we’re psyched to see on-chain AI applied.

All of us, putting our models on-chain

Step 3: Areas We’re Excited By

As we’ve explored possibilities for on-chain AI, we’ve been lucky enough to speak to imaginative, creative stakeholders at web2 and web3 companies alike (to name a few — Brave, OpenSea, Ripple, ConsenSys, Starkware, Matter Labs, O(1) Labs, Salesforce, and Shopify). While we won’t be directly quoting any interviews in today’s blog, we will be incorporating many proposals we’ve heard, as well as ideas we’ve been excited by below.

AI Oracles — The oracle problem is well-known within the web3 world, and can roughly be summarized as, “the chain is deterministic, yet requires (potentially non-deterministic) off-chain data sources which need to be agreed upon by all network nodes”. Centralized sources fail completely, while services such as ChainLink bootstrap trustlessness by only reading data from trusted aggregators in a transparent manner. With on-chain AI, however, a single, centralized oracle (e.g. proof of identity, by reading an ID card, or proof of physical work, by validating the image of someone standing next to a completed house) is able to now be trusted by all, and thus solves any off-chain validation problem for which a highly accurate AI model is able to be trained.

Decentralized Kaggle — One excellent protocol which is made fully decentralize-able via just verifiable inference is that of Kaggle competitions. Specifically, contestants first commit their model architectures and weights by the contest deadline, and then all test set inputs are revealed. Contestants’ models are run “on-chain” over the test set, generating verifiable proofs of compute for their posted results, and thus winners are chosen in a decentralized, indisputable way (with rewards being auto-dispensed via smart contract!).

Decentralized Health Care Ensemble — This follows closely in the image of Numerai, which provides obfuscated, high-quality financial data to everyone in a format which any data scientist can develop an arbitrarily complex model for. A decentralized version of such a protocol (where all models and the meta-model itself is on-chain) will allow for substantial gains to be made with respect to AI inference metrics on healthcare outcomes without violating patient privacy — given cryptographically secure data obfuscation methods (fully homomorphic encryption, federated learning, sMPC with respect to the training algorithms, etc). This then frees up data scientists from all over to apply their honed techniques without needing to understand anything about healthcare data or outcomes!

Gaming — One of the most enticing areas we’ve encountered has been within the gaming/Metaverse space. As the gaming industry continues to create more imaginative, higher fidelity titles, a collision with a Metaversal future seems all but certain. In fact, some of the game developers we spoke to have already been hard at work experimenting with new tools enabled by web3 — from massive in-game economies driven by tokenomics to collaborative enterprises built atop crypto factions and dynamic governance, it really does feel like…well, the future.

TBD if Star Atlas becomes a real game, but dang the trailer looks pretty cool

Yet when these budding universe simulators consider incorporating complex AI agents (either within a PvE — player versus environment — framework or in the role of governance), there are only centralized solutions. A transparent, trustless AI may push the web3 gaming world to an entirely new paradigm, giving players the buy-in they need to fully immerse themselves.

Step 4: Putting It All Together

Looking ahead, this new generation of models represent an opportunity to retain the wild strength and astonishing capabilities of modern-day ML (mostly — the goal is not to reach parity with centralized services, who will almost always beat out on-chain AI in raw horsepower. Instead, verified inference may only need to come close to their centralized counterparts to radically expand AI’s on-chain use-cases), while also honoring the notable cultural and technological value shift jumpstarted by web3. Or to put it another way, with inference on chain, everyone can now check and audit anyone’s deployed models — even those of the “big guys.” In so many ways, that’s the precise web3 ethos we first fell in love with, and why we joined this wild movement. When all taken together, we believe the coming technological shifts might just be enough to herald a new age for both AI and the blockchain.

And hey, if there’s a cool use-case that we didn’t think of (there are definitely many), don’t hesitate to comment or reach out; Especially if you’re building something that you feel could benefit from trustless, intelligent agents — we’d love to hear from you. You can follow us here on Medium or find us at: https://twitter.com/ModulusLabs

Re-Visiting Our Assumptions

None for this week. A lot of the work here is highly speculative and represents opinions. Don’t worry, we’ll be back with more math and logic soon!

--

--