- Part 1: AI on Blockchain — What’s the catch?- Part 2: AI Smart Contracts — The Past, Present, and Future- Part 3: Running Artificial Intelligence on the Blockchain- Part 4: Cortex AI on Blockchain Ecosystem- Part 5: AI on Blockchain Use Cases
Smart contracts, known to be used with the blockchain technology, is a computer program that directly controls the transfer of digital currencies or assets between parties under certain conditions. However, there is one particular characteristic that is lacking which ceases a wider application for smart contracts. In spite of many games and pyramid scheme DApps, this feature is a prominent reason why smart contracts have not been very successful thus far — AI Smart Contracts.
Artificial Intelligence (AI) is not a new term, it has been around since the 1950s. Artificial Intelligence can be defined as human intelligence exhibited by Machines. Earlier works of AI used methods like A*, fuzzy logic, expert systems, and good old-fashioned AI (GOFAI), the same if-then rules that are used in coding most applications including smart contracts. Deep Blue, the AI created by IBM that defeated the world chess champion Garry Kasparov in 1997, used a method called search algorithms to evaluate millions of moves at every turn.
Deep Blue vs Garry Kasparov
When we speak of AI nowadays, we are actually talking about Machine Learning, an approach to achieve Artificial Intelligence.
Machine Learning works by building models that capture weights and relationships between features from historical data and then use these models for predicting future outcomes.
In 1959, Arthur Samuel, one of the first pioneers of machine learning, developed the first-ever machine learning program that learned how to play checkers better than him. Nowadays, advanced statistics and data are readily available on the internet such as Basketball-Reference.com for NBA statistics and Kaggle, heaven for data scientists to discuss their findings and gather datasets. There are open-source courses like Fast.ai and deeplearning.ai that make deep learning, a technique for implementing machine learning, accessible to everyone. Which sports geek wouldn’t like to create their own system for predicting matches?
A visually stunning presentation of NBA match using data from stat.nba.com by panos
In 2016, Alpha Go defeated Go world champion Lee Sedol in board game Go (Go is a Chinese board game which the aim is to surround more territory than the opponent). Alpha Go, developed by Google, used a combination of machine learning and tree search techniques which was trained with a database of around 30 million moves then used reinforcement learning, a subset of machine learning, to play against itself to improve its play.
Alpha GO vs Lee Sedol
In a recent interview with MIT Technology Review, Yoshua Bengio, one of the fathers of AI, has expressed his concerns with just a few companies dominating the field of AI. He believes in democracy in AI research as AI research tends to lead to concentrations of power and money. Jeremy Howard, Kaggle master and CEO of Fast.ai, stated that "For its(AI) full potential to be met, the technology needs to be much easier to use, more reliable, and more intuitive than it is today."
AI could leverage blockchain in various ways:
It is not an easy task to allow machine learning models to run on the blockchain.
Let’s take an example, as shown in the image above, the parameters of the original deep learning neural network are float variables that need 32-bits storage space. If the model can be converted into a state with only three values (-1, 0, +1), the storage would only take up 2-bits, which significantly compresses the storage space. Moving from 32-bits to 2-bits, we get (almost) 16x reduction in memory. Lower bit-widths allows more data into the same caches which reduce the frequency to access from RAM. In addition, having floating point arithmetic is not ideal as it is not well-supported on microcontrollers on some low-power embedded devices (like IoT devices).
And the answers suggest we could modify the models that require less storage and computation power but with lower precision — Compression and Quantization.
Compression modifies the large cumbersome models that reduce the memory requirements while retaining as much of its precision as possible. Lighter models mean less storage space and easier to share over smaller bandwidths.
Quantization is the process of reducing the number of bits needed to store an integer value by reducing the precision of the integer. Quantization in deep learning combines high performance with lightweight inference which reduces the computation and memory costs. Quantization allows models to be executed on the blockchain with relatively low cost but also provides consistent inferred results.
TinyPNG uses quantization to convert 24-bit PNG files to much smaller 8-bit indexed colour images
With model compression and quantization in place, Cortex proposed “Synapse”, an integer inference engine to do deterministic AI inference, to make machine learning accessible on the blockchain. One of the core Synapse capabilities is to guarantees exactly the same result of an AI model in heterogenetic computing environments (you can try out the TestNet now). determinacy is crucial in the blockchain, as consensus has to be formed upon smart contract outputs. It is non-trivial for widely-used AI inference engines (TVM, NNVM, etc.) to guarantee the determinacy because modern GPU introduces parallelism into the execution flow. Synapse utilizes both quantizations of AI models and deterministic GPU acceleration to make AI DApps available. With the help of GPU hardware acceleration, AI inference subroutines could behave like a dedicated SHA function in the blockchain’s virtual machine, public verifiable and deterministic.
If you are interested in learning deep learning, check out Jeremy Howard's Fast.ai and Andrew Ng's deeplearning.ai! There are also many GPU cloud services that offer a free trial (like Digital Ocean)and free cloud computational environments (like Google Colab and Kaggle Kernels)to get you started with ease.