Author: Ian Xu@Foresight Ventures

TL;DR

  • This article discusses the intersection of AI and Web3, exploring how on-chain AI can bring significant value to the decentralized internet. It highlights several projects, including Worldcoin, Pragma, Lyra Finance, Giza, Zama.ai, and potential ML-as-a-service applications.

  • The article emphasizes that AI in the Web3 context is in its early stages but holds great potential. On-chain AI, being transparent and verifiable, can significantly enhance efficiency and security, enabling new product forms. The ZKML is particularly promising, with ZK-rollup potentially serving as an entry point for AI into the Web3 world.

  • While the current infrastructure can support models of a certain scale, there are still many uncertainties, particularly in terms of verifying models through Zero-Knowledge Proofs. This is seen as the inevitable path for AI on-chain but requires exponential improvements in proof systems to support increasingly large models.

  • In terms of applications, on-chain AI could potentially participate in any aspect of Web3, including gaming, DeFi, DID, and tooling. Despite the scarcity of existing projects, the article remains optimistic about the potential of on-chain AI and its transformative impact on the Web3 space.

1. AI + Web3 = ?

Developers’ obsessive dedication to infrastructure construction and the continuous updates of various rollup solutions have indeed made a breakthrough in the originally lagging computing power of web3. This has also made it possible for AI to be put on the blockchain. But you might want to say that instead of going to great lengths to implement on-chain AI, running models off-chain seems to be able to meet most needs. In fact, almost all AI models are currently running in a black-box, centralized mode and are creating irreplaceable value in various fields.

1.1 Let’s go back to the most basic question, what is AI on the blockchain?

The mainstream understanding is to make AI models transparent + verifiable through Web3.

To be more specific, AI on the blockchain means the complete verification of artificial intelligence models. That is to say, a model needs to disclose the following three points to the entire network (users or verifiers):

  1. Model architecture;

  2. Model parameters and weights: Disclosing parameters and weights may sometimes have a negative impact on product security. Therefore, for specific scenarios, such as risk control models, weights can be hidden to ensure security;

  3. Model input: In the context of web3, it is generally public data on the chain.

When the above conditions are met, the whole model execution process is deterministic and no longer a black-box operation. Anyone can verify the model’s input and results on the blockchain, thereby preventing the model owner or related authorized person from manipulating the model.



1.2 What is the driving force for on-chain AI?

The significance of on-chain AI is not to replace the centralized operation mode of Web2 AI, but:

  1. Without sacrificing decentralization and trustlessness, it creates the next stage of value for the web3 world. The current Web3 is like the early stage of web2, and it does not yet have the ability to undertake broader applications or create greater value. Only after incorporating AI, can the imagination of Dapp truly leap to the next stage, and these on-chain applications may become closer to the level of web2 applications. This proximity is not in making the functions more similar, but in enhancing user experience and possibilities by leveraging the value of Web3.

  2. It provides a transparent, trustless solution for the black-box operation mode of web2 AI.

Imagine the application scenarios of web3:

  1. Adding a recommendation algorithm to the NFT trading platform, recommending corresponding NFTs based on user preferences, and improving conversion;

  2. Adding AI opponents in games for a more transparent and fair gaming experience;

……

However, these applications are further improvements in efficiency or user experience through AI for existing functions.

  • Is it valuable? Yes.

  • Is the value big? It depends on the product and the scenario.

The value that AI can create is not limited to optimizing from 99 to 100. What really excites me is the new applications from 0 to 1, some use cases that can only be achieved through transparent + verifiable on-chain models. However, these “exciting” use cases currently rely mainly on imagination, without mature applications. Here are some brainstorming ideas:

  1. Crypto trading based on neural network decision models: One product form could be more like an upgraded version of copy trading, or even a completely new way of trading. Users no longer need to trust or research other experienced traders but bet on completely open and transparent models and their performance. Essentially, AI trades faster and more decisively based on predictions of future crypto prices. However, without the “trustless autonomy” inherent in on-chain AI, such betting objects or standards simply do not exist. Users/investors can transparently see the reasons, processes, and even the exact probability of future rises/falls in the model’s decision-making.

  2. AI models acting as referees: A product could be a new form of the oracle, predicting the accuracy of data sources through AI models. Users no longer need to trust validators and don’t have to worry about nodes misbehaving. Oracle providers don’t even need to design complex node networks and reward-punishment mechanisms to achieve decentralization. Correspondingly, the on-chain transparent + verifiable AI is already sufficient to verify the confidence level of off-chain data sources. This new product form has the potential to dominate in terms of security, efficiency, and cost, and the object of decentralization jumps from humans to “trustless autonomy” AI tools, which is undoubtedly safer.

  3. Organization management/operating systems based on large models: The governance of DAOs should inherently be efficient, decentralized, and fair, but the current situation is quite the opposite, loose and bloated, lacking transparency and fairness. The introduction of on-chain AI can provide a very fitting solution, maximizing management mode and efficiency, and minimizing systemic and human risks in management. We can even imagine a new development and operation mode for web3 projects, where the entire framework and future development direction and proposals hardly depend on the decision-making of the development team or DAO voting. Instead, decisions are made based on the larger data acquisition and computational abilities of large models. But all this is premised on the model being on-chain. Without AI’s “trustless autonomy”, there is no transition from humans to tools in the decentralized world.

……

In summary,

New product forms based on on-chain AI can be summarized as transitioning the subject of decentralization and trustlessness from humans to AI tools. This is in line with the evolution of productivity in the traditional world, where initially, efforts were made to upgrade and enhance human efficiency, and later, humans were replaced by intelligent tools, revolutionizing the original product design in terms of security and efficiency.

The most critical point, and the premise of all the above, is to make AI transparent + verifiable through Web3.



1.3 The Next Stage of Web3

Web3, as a phenomenal technological innovation, cannot just stay in its initial stage. Traffic and economic models are important, but users will not always stay in pursuit of traffic or spend a lot of resources to do X to earn, and Web3 will not onboard the next wave of new users because of this. But one thing is certain: the revolution of productivity and value in the crypto world must come from the addition of AI.

I think it can be roughly divided into the following three stages:

Start: The update and iteration of zero-knowledge proof algorithms and hardware provide the first possibility for the emergence of on-chain AI; (we are here)

Development: Whether it’s the improvement of existing applications by AI or the new products based on on-chain AI, both are pushing the entire industry forward;

Endgame: What is the ultimate direction of on-chain AI?

The above discussions are all about exploring application scenarios bottom-up through the combination of AI and Web3. If we switch to a top-down approach to view the on-chain AI, could AI trace back to Web3 itself? AI + blockchain = adaptive blockchain

Some public chains will take the lead in integrating on-chain AI, transforming from the level of public chains into a kind of adaptive one. The development direction no longer depends on project foundation decisions but is based on massive data decision-making, and the level of automation far exceeds traditional Web3, thus standing out from the current multi-chain prosperity.

With the blessing of verifiable + transparent AI, where web3’s self-regulation is manifested can refer to a few examples mentioned by Modulus Lab:

  1. On-chain transaction markets can automatically adjust in a decentralized manner, such as adjusting the interest rate of stablecoins in real-time based on publicly available on-chain data, without the need for trust assumptions;

  2. Multimodal learning can allow on-chain protocol interactions to be completed through biometric recognition, providing secure KYC and achieving complete trustless identity management;

  3. Allow on-chain applications to maximize the value brought by on-chain data, supporting services such as customized content recommendation.

From another perspective, zkrollup keeps iterating and optimizing, but it always lacks a real application that can only run on the zk ecosystem, ZKML exactly meets this point, and its imagination space is also large enough. ZK-rollup is likely to serve as the entry point for AI into web3 in the future, creating greater value, and the two complement each other.

2. Implementation and Feasibility

2.1 What Can Web3 Provide for AI?

Infrastructure and ZK are undoubtedly the most fiercely competitive tracks in web3. Various ZK projects have made great efforts in circuit optimization and algorithm upgrading, whether it’s the exploration of multi-layer networks, the development of modularization and data availability layers, further customizing rollup as a service or even hardware acceleration… These attempts are pushing the scalability, cost, and computing power of Web3 infrastructure to the next level.



It sounds good to put AI on the chain, but how exactly is it done?

One approach is through the ZK-proof system. For example, create a customized circuit for machine learning, the process of generating a witness off-chain is the process of model execution, and generate a proof for the model prediction process (including model parameters and inputs), anyone can verify the proof on-chain.

The AI model still runs on an efficient cluster, even with some hardware acceleration to further enhance computational speed, maximizing the use of computing power while ensuring that no centralized person or institution can tamper with or interfere with the model, that is, to ensure:

Model prediction result certainty = verifiable (input + model architecture + parameters)

Based on the above approach, we can further infer which infrastructures are crucial for AI on-chain:

  1. ZKP system, rollup: Rollups expand our imagination of on-chain computing capabilities, packaging a bunch of transactions, and even recursively generating proof of proof to further reduce costs. For the current large models, the first step to provide possibilities is the proof system and rollup;

  2. Hardware acceleration: ZK rollup provides a verifiable basis, but the generation speed of proof directly relates to the usability and user experience of the model. Waiting for several hours to generate a model’s proof is obviously not going to work, so hardware acceleration through FPGA is a great boost.

  3. Cryptography: Cryptography is the foundation of the crypto world, and on-chain models and sensitive data also need to ensure privacy.

Supplement:

The basis of large models is GPU. Without high parallel support, the efficiency of large models will be very low, and they cannot run. Therefore, for an on-chain zk ecosystem:

GPU-friendly = AI-friendly

Take Starknet as an example, Cario can only run on CPU, so only some small decision tree models can be deployed, which is not conducive to the deployment of large models in the long term.

2.2 Challenge: More Powerful Proof System

The generation speed and memory usage of ZK Proof are crucial, one is related to user experience and feasibility, while the other pertains to cost and scalability.

Is the current zkp system sufficient?

Sufficient, but not good enough…

Modulus Lab has detailed the specific situation of models and computing power in the article “The Cost of Intelligence: Proving Machine Learning Inference with Zero-Knowledge”. When you have time, you can read this “Paper0” in the ZKML field: https://drive.google.com/file/d/1tylpowpaqcOhKQtYolPlqvx6R2Gv4IzE/view

Below are the different proof systems mentioned in Paper 0.



Based on the above zk algorithms, Modulus Lab conducts tests from two dimensions: time consumption and memory occupancy and controls two core variables: parameters, and layers in these two dimensions. The following are benchmark suites. Such a design can roughly cover LeNet5’s 60k parameter volume, 0.5MFLOPs, to ResNet-34’s 22M parameter volume, 3.77 GFLOPs.



Time consumption test:



Memory consumption test:



Based on the above data, overall, the current zk algorithm and the potential to support the generation of large model proofs are available, but the corresponding costs are still high, requiring even more than 10 times optimization. Taking Gloth16 as an example, although it benefits from the optimization of computation time brought by high concurrency, as a trade-off, memory usage significantly increases. The performance of Plonky2 and zkCNN in time and space also verifies this point.

So now the question has actually changed from whether the zkp system can support on-chain AI to is the cost worth supporting AI on-chain. And with the exponential rise in model parameters, the pressure on the proof system will also rapidly increase. Indeed, is there a trustless neural network now? No! It’s because the cost is too high.

Therefore, creating an AI-customized proof system is of vital importance. At the same time, to implement AI logic, which is very complex in a single call, the gas consumption model also needs to be redesigned. A high-performance zkvm is essential. But now we can see many high-performance attempts, such as OlaVM, polygon Miden, etc. The continuous optimization of these infrastructures greatly improves the feasibility of on-chain AI.

3. Is the application worth looking forward to?

Although on-chain AI is still in its early stages, it may be between the starting and development stages when viewed from the above layers. However, the AI direction never lacks excellent teams and innovative ideas.

As mentioned above, looking at the development stage of AI in the web3 world, the current market is at the mid-stage from starting to developing, and the product attempt direction is still mainly based on user experience optimization based on existing functions. But the most valuable thing is to turn trustless subjects from people into tools through AI on the chain, subverting the original product form in terms of security and efficiency.

Next, starting from some existing application attempts, analyze the long-term product development direction of on-chain AI

3.1 The Rockefeller Bot: The world’s first on-chain AI

Rockefeller is the first on-chain AI product launched by the Modulus Lab team, with a strong “commemorative value”. This model is essentially a trading bot. Specifically, the training data of Rockefeller is a large amount of publicly available WEth-USDC price/exchange rate on the chain. It is a three-layer feed-forward neural network model, and the prediction target is the future WEth price rise and fall.

Here is the process when the trading bot decides to trade:

  1. Rockefeller generates ZKP for the prediction results on ZK-rollup;

  2. ZKP is verified on L1 (funds are kept by L1 contract) and operations are executed;

It can be seen that the prediction and fund operations of the trading bot are completely decentralized and trustless. As mentioned above, from a higher dimension, Rockefeller is more like a new type of Defi gameplay. Compared to trusting other traders, in this mode, users are actually betting on the transparent + verifiable + autonomous model. Users do not need to trust centralized institutions to ensure the legality of the model decision-making process. At the same time, AI can also eliminate the impact of human nature to the greatest extent and make decisions more decisively.



You might already want to invest some money in Rockefeller and give it a try, but can this really make money?

No, it can’t, according to the Modulus team. Rather than being an application, Rockefeller is more like a Proof of Concept (POC) for on-chain AI. Due to limitations in cost, efficiency, and proof systems, Rockefeller’s primary purpose is to serve as a demo to show the feasibility of on-chain AI to the web3 world. (Rockefeller has completed its mission and is now offline T T)

3.2 Leela: The world’s first on-chain AI game

Leela v.s. the World, recently released, is also from Modulus Lab. The game mechanism is simple, where human players form teams to battle against AI. In the game, players can stake their bets, and at the end of each match, the loser’s pool will be distributed to the winner according to the number of tokens staked.



Speaking of on-chain AI, this time Modulus Lab has deployed a larger deep neural network (with a number of Parameters > 3,700,000). Although Leela surpasses Rockefeller in terms of model scale and product content, it is essentially still a large-scale on-chain AI experiment. The mechanism and operation mode behind Leela is what need attention, which can help us better understand the operation mode and improvement space of on-chain AI. Here is the logic diagram given by the official:



Every move Leela makes, or every prediction, will generate a ZKP, and only after being verified by the contract will it take effect in the game. That is to say, thanks to the trustless autonomous AI, the funds bet by users and the fairness of the game are fully protected by cryptography, and there is no need to trust the game developer.

Leela uses the Halo2 algorithm, mainly because its tools and flexible design can help design a more efficient proof system. The specific performance situation can refer to the test data above. But at the same time, during the operation of Leela, the Modulus team also found the drawbacks of Halo2, such as slow proof generation and unfriendliness to one-shot proving, etc. Therefore, it further confirms the conclusion drawn from the previous test data: if we need to bring larger models into web3, we need to develop a more powerful proof system.

However, the value of Leela lies in bringing us a larger imagination space for AI + Web3 game, at this moment, King of Glory players should be extremely hopeful for the matchmaking algorithm to be fully on-chain:) Gamefi needs more high-quality content support and a fairer game system, and on-chain AI just provides this. For example, introducing AI-driven game scenes or NPCs into the game provides a huge imagination space for both the player’s game experience and the gameplay of the economic system.

3.3 Worldcoin: AI + KYC

Worldcoin is an on-chain identity system (Privacy-Preserving Proof-of-Personhood Protocol) that uses biometrics to establish an identity system and achieve derivative functions like payments. The goal is to combat Sybil attacks, and it now has more than 1.4 million registered users.



Users scan their iris with a hardware device called Orb, and personal information is added to a database. Worldcoin runs a CNN model in the computational environment of the Orb hardware to compress and validate the effectiveness of user iris data. It sounds powerful, but for true decentralized identity verification, the Worldcoin team is exploring model output verification through ZKPs.

Challenges

Worth mentioning is that the CNN model used by Worldcoin has a size: parameters = 1.8 million, layers = 50. Based on the test data shown above, the current proof system can handle this in terms of time, but the memory consumption is impossible to complete for consumer-grade hardware.

3.4 Other projects

  1. Pragma: Pragma is a ZK oracle developed from the Starkware ecosystem. The team is also exploring how to solve the problem of decentralized off-chain data verification through on-chain AI. Users no longer need to trust validators but can verify off-chain data sources through sufficiently accurate and verifiable on-chain AI, such as reading corresponding physical information as input and making decisions for actual asset or identity verification.

  2. Lyra finance: Lyra finance is an option AMM that provides a derivatives trading market. To improve capital utilization, the Lyra team and Modulus Lab are collaborating to develop an AMM based on a verifiable AI model. With a verifiable, fair AI model, Lyra finance has the opportunity to become a large-scale implementation experiment for on-chain AI, bringing fair matchmaking to web3 users for the first time, optimizing the on-chain market through AI, and providing higher returns.

  3. Giza: A ZKML platform that deploys models directly on-chain rather than off-chain verification. Nice try, but… Due to the computational power and Cairo’s lack of support for CUDA-based proof generation, Giza can only support the deployment of small models. This is the most fatal problem. In the long run, large models that can have a disruptive impact on web3 will require powerful hardware support, such as GPUs.

  4. Zama-ai: Homomorphic encryption of models. Homomorphic encryption is a form of encryption where: f[E(x)] = E[f(x)], where f is an operation, E is a homomorphic encryption algorithm, and x is a variable, for example, E(a) + E(b) = E(a + b). It allows specific forms of algebraic operations on ciphertext to result in an encrypted result, and decrypting this result will yield the same result as performing the same operation on the plaintext. Model privacy has always been a hotspot and bottleneck of AI. Although zk is privacy-friendly, zk does not equate to privacy. Zama is committed to ensuring the privacy-preserving execution of models.

  5. ML-as-a-service: This is currently just a thought direction, without specific applications, but the goal is to solve the problems of malicious behavior by centralized ML service providers and user trust through ZKPs. Daniel Kang has a detailed description in the article “Trustless Verification of Machine Learning” (refer to the diagram in the article).



4. Conclusion

  • Overall, AI in the web3 world is in a very early stage, but there is no doubt that the maturation and popularization of on-chain AI will take the value of web3 to another level. Technically, web3 can provide a unique infrastructure for AI, and AI is an essential tool for changing the production relations of web3. The combination of the two can spark many possibilities, which is an exciting and imaginative place.

  • From the perspective of AI’s motivation to go on-chain, on one hand, the transparent + verifiable on-chain AI transforms the decentralized and trustless entities from people to AI tools, greatly enhancing efficiency and security, and providing possibilities for creating entirely new product forms. On the other hand, as the infrastructure of web3 continues to iterate, web3 genuinely needs a killer application that can maximize the value of this infrastructure. ZKML fits this point, for example, ZK-rollup is likely to be the entry point for AI into web3 in the future.

  • From a feasibility perspective, the current infrastructure can support models of a certain scale to some extent, but there are still many uncertainties. Using ZKP to create verifiable models currently appears to be the only path for AI to go on-chain and may also be the most deterministic technical path for bringing AI into web3 applications. However, in the long run, the current proof system needs to be exponentially improved to sufficiently support the increasingly large models.

  • From the perspective of application scenarios, AI can almost perfectly participate in any direction of web3, whether it is gaming, DeFi, DID, or tooling… Although the existing projects are very scarce and lack long-term value, they have not yet transitioned from a tool to improve efficiency to an application that changes production relations. But it’s exciting that someone has taken the first step, and we can see the earliest look at on-chain AI and its future possibilities.

Reference

https://worldcoin.org/blog/engineering/intro-to-zkml

https://medium.com/coinmonks/chapter-1-how-to-put-your-ai-on-chain-8af2db013c6b

https://medium.com/@ModulusLabs/chapter-2-why-put-your-ai-on-chain-33b7625147b7

https://medium.com/@ModulusLabs/chapter-3-the-worlds-first-on-chain-ai-trading-bot-c387afe8316c

https://medium.com/@ModulusLabs/chapter-4-blockchains-that-self-improve-e9716c041f36

https://medium.com/@ModulusLabs/chapter-4-5-trustless-ai-for-living-breathing-games-cc9f24080e30

https://medium.com/@ModulusLabs/chapter-5-the-cost-of-intelligence-da26dbf93307

https://medium.com/@ModulusLabs/chapter-6-leela-vs-the-world-the-worlds-1st-on-chain-ai-game-17ea299a06b6

https://drive.google.com/file/d/1tylpowpaqcOhKQtYolPlqvx6R2Gv4IzE/view

https://medium.com/@danieldkang/trustless-verification-of-machine-learning-6f648fd8ba88

About Foresight Ventures

Foresight Ventures is dedicated to backing the disruptive innovation of blockchain for the next few decades. We manage multiple funds: a VC fund, an actively-managed secondary fund, a multi-strategy FOF, and a private market secondary fund, with AUM exceeding $400 million. Foresight Ventures adheres to the belief of a “Unique, Independent, Aggressive, Long-Term mindset” and provides extensive support for portfolio companies within a growing ecosystem. Our team is composed of veterans from top financial and technology companies like Sequoia Capital, CICC, Google, Bitmain, and many others.

Website: https://www.foresightventures.com/

Disclaimer: All articles by Foresight Ventures are not intended to be investment advice. Individuals should assess their own risk tolerance and make investment decisions prudently.