Skip to content

bonsol-collective/bonsol-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Bonsol AI Demo

Introduction

This repo contains a demo of how you can run an AI model and commit its result on-chain, using Bonsol.

For this demo we created a small CNN, with two convolution layers and a fully connected output layer, about 2k params in total. We used the MNIST database and during training it achieved an accuracy of 95% approximately, not bad for such a small model.

Later we ported the model to RiscZero and Bonsol and it takes about 500ms to run and 5-10min to generate the proofs using CUDA.

How to run

To run it you must first start a Solana Test Validator and deploy the Bonsol program.

solana-test-validator --rpc-pubsub-enable-block-subscription --bpf-program BoNsHRcyLLNdtnoDf8hiCNZpyehMC4FDMxs6NTxFi3ew /PATH-TO-BONSOL/target/sbf-solana-solana/release/bonsol.so  --limit-ledger-size 100000

Now run the test server, to upload the Bonsol Image. Clone the bonsol repo:

cd bonsol 
cargo run -p local-zk-program-server

Then build and deploy the Bonsol program:

cd ai
bonsol build
bonsol deploy url --url http://localhost:8888 --manifest-path manifest.json

Now you can start the node using the default config from the Bonsol repo:

bonsol-node -f Node.toml

Finally, you can run the tests by doing:

cd ai-onchain
anchor test --skip-local-validator

About

Running an AI model and committing it on-chain using ZK proofs!

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors