The more futuristic concept of AI for smart contracts, which eventually can be used to build and run AI DApps and decentralized autonomous organizations (DAOs) in such a way that they can adapt and evolve to complete tasks with very limited human intervention is also very interesting.
A project called Cortex claims to be the first blockchain to support on-chain AI. They've managed to deploy a couple of AI models on their testnet using techniques such as quantization and compression. Quantization is a concept in machine learning that combines lightweight inference with high performance, which allows AI models to be executed with high levels of accuracy and low memory costs:
The inference process works as follows:
Compression reduces the size and data usage of models. The first model, a Cat or Dog classifier, was originally over 500 MB in size. An integer model was generated after transferring learning from the original model, to reduce its size first to about 130 MB and then to less than 15 MB.After training, the accuracy under floating numbers was over 94%, and the accuracy after full compression and converting to an integer model was over 90%.
The model submission process works as shown in the following diagram:
The second model does digit recognition based on the MNIST dataset, a large database of handwritten digits that's commonly used to train various image-processing systems. It infers data from a binarized image, giving a result of 0 to 9 with an accuracy of over 98%.
When tested, both models have been shown to successfully eliminate random factors in the inference process and give deterministic results to reach inferred consensus on-chain. These results show that some accurate and performant AI models can be deployed on-chain. Naturally, Cortex has higher hardware requirements for full nodes than Bitcoin and Ethereum in terms of storage capacity and processing power. The combined inference process on full nodes is shown in the following diagram:
Future AI DApps being envisaged include information services for personalized recommendations (suggesting news of potential interest based on user profiles), image search engines, news/summary writing (generating new text based on another text), financial services such as credit scores (based on a user's online data) or intelligent investment advisory (based on financial datasets), AI assistants that provide automatic Q&A services (chatbots that generate answers based on human dialogue), and industry-knowledge graphs (expert systems that can be used in medical, consulting, and other industries).