Over the past few months, there have been multiple breakthroughs in the AI industry. Models like GPT4 and Stable Diffusion are changing the way people generate and interact with software and internet.
Despite the impressive capabilities of these new AI models, some individuals are concerned with the unpredictability and alignment issues of AI. For example, there is a lack of transparency in the world of online services, where most of the backend work is run by AI models. It’s challenging to verify if these models are behaving in the desired manner. Furthermore, user privacy is also a concern since all the data we provide to the model API can be used to improve the AI or exploited by hackers.
ZKML could be a novel solution to these problems. By instilling verifiable and trustless attributes into machine learning models, blockchain and ZK technology could form a framework for AI alignment.
Zero-knowledge machine learning (ZKML) in this article refers to using zkSNARK (a type of zero knowledge proof) to prove the correctness of a machine learning inference without revealing model’s inputs or model parameters. The use cases of ZKML can be categorized into the following types based on what information is private:
Privacy-preserving machine learning: ZKML can be used to train and evaluate machine learning models on sensitive data without revealing the data to anyone else. This can be important for applications such as medical diagnosis and financial fraud detection. We also see some players to use ZKML on biometric data authentication to build proof of humanity service.
Attestation: In a world where most online contents are generated by AI, cryptography can provide a source of the truth. People are experimenting to use ZKML to fight deepfake issues.
As zkSNARK will be a very important technology for the crypto world, ZKML also has the potential to change the crypto landscape. By adding AI capabilities to smart contracts, ZKML can unlock more complex on-chain applications. This integration is being coined as “giving the blockchain eyes” within the ZKML community.
However, ZK-ML comes with several technical challenges that must be addressed at the current time.
Quantization: ZKPs work over fields but neural networks are trained in floats. That means in order to put a neural network model zk/blockchain friendly, it need to transformed into a fix point arithmetic representation with full computational trace. This could sacrifice the model performance since parameters have lower precision.
Cross language translation: Neural network AI models are written in python and cpp while ZKP circuits require rust. So we need to have a translation layer to convert models to ZKP based runtime. Normally this type of translation layer is model specific and it’s hard to design a universal one.
Computational costs of ZKP: Basically the ZKP cost will be much higher than the original ML computations. According to an experiment from Modulus labs, for a model with 20M parameters, it will take more than 1–5 minutes to generate the proof and the memory consumption is around 20–60GB depending on different ZK proving systems.
Even with those challenges, we have seen ZKML has raised quite a lot of interest in the crypto community and there are some great teams exploring this field.
Model compiler:
With the main bottleneck of ZKML being converting the AI model in to ZK circuits, several teams are working on the infra layer like ZK model compiler. Starting from logistic regression model or simple CNN model 1 year ago, the space has moving quite fast into more complex models.
EZKL project are now supporting model up to 100mm parameters. It uses ONNX format and halo2 ZKP system. The library also support only committing a part of a model.
ZKML library already supports the ZKP of GPT2 and Bert and diffusion models!
ZKVM:
ZKML compiler has also falls into the domain of some more general zero knowledge virtual machines.
Risc Zero is a zkVM using the open source RiscV instruction set, so it can support the ZKP of c++ and rust. This zkDTP projects shows how to convert a decision tree ML model to rust and run it on Risc Zero.
We also see some teams are trying to bring AI models onchain with on Startnet(Giza) and Aleo (zero gravity)
Apart from infra initiatives, other teams are starting to explore the applications of ZKML
Defi:
One example DeFi use case is AI powered vault where the mechanism is defined by a AI model instead of a fixed strategy. These strategies can take in onchain and offchain data to predict the market trend and execute the trading. ZKML guarantees that the onchain model is consistent. This can enable the whole process to be automatic and trustless. Mondulus Labs is building RockyBot. The team trains an onchain AI model to predict the ETH price and builds a smart contract to trade with the model automatically.
Other potential DeFi use cases include AI powered DEX and lending protocols. Oracles can also leverage ZKML to provide new kind of data source generated from offchain data.
Gaming:
NFT/Creator Economy:
Identity:
Considering the high cost of the zero knowledge proof of AI models. We think the adoption of ZKML could start with some crypto native use cases where the cost of trust is high.
Another market we should consider is the industry where data privacy is very critical like healthcare. There are other like Federated Learning and secure MPC AI for this purpose but ZKML could have advantage of scalable incentive network with blockchain.
More broad mass adoption of ZKML could depend on people’s trust of existing big AI providers. Would there be some incident that raise the awareness of the whole industry and drive users consider verifiable AI technologies.
ZKML is still in its early stage and has many challenges to overcome. But with the improvement of ZK technology, we think people will soon find out several ZKML use cases with strong product market fit. These use cases could look niche at the start. But as the centralized AI gets more and more power and penetrates every industry and even human life, people may find greater value in ZKML.
If you are building ZKML applications or infrastructure, please reach out @alanwwu on Twitter! Would love to chat.
Website: https://avant.fund
Twitter: https://twitter.com/avantfund