the AI in the blockchAIn

robin·Oct 11, 2023research

what is AI actually?

AI defines the computer capability of handling programs using human-intelligence, well, basically outperforming human.

a not so long time ago, when machines were just capable of undergoing mathematical operations with logical gates, there were some terms coined for the evolution of handling these calculations artificially.

many assumptions and works were initiated to create the "artificial brain", and with alan turing's computing machinery and intelligence method of imitation game, computer scientists were able to compute the machine intelligence of a system.

these groundworks from scientists and data engineers paved the way to the dawn of the AI era. an AI, for now, is just a machine predicting the next outcome from previously fed data, the more data, the more is the accuracy of "predicting". and for data, user-centric systems focuses on utilizing user resources in their learning, which is probably not good way of collecting information without the end-user knowledge and no benefits to them.

ai nets

AI is now seen as minimizing complex task, while still training from the information provided by the trainers, a centralized entitiy.

recent growths, however, were highly recognized as an effort towards the growth of artificial intelligence, there are stil some improvements to be done.


using the top 2 technologies of this century (by far) we can create revolutionary and more sustainable applications for the future. [ blockchain + AI ]

with AI on blockchain, the machine intelligence will garner more information using decentralization, distributed neural networks acting as the validator nodes for continous training of the AI.

mastering a specific field, with highly generative datasets will make an impact on more research procedures, decision making, data analytics, and many more submersive concepts that are yet to be discovered by humans. this AI, which is neither biased nor having a centralized control, will be helpful for reaching the infinite.


how?

blockchain requires nodes to validate transactions, miners to validate group of transactions into the block, and protocol to add the block into the blockchain.

AI could be conceptualized as having these components. in this framework, 'nodes' could be individual data points or features that the AI model evaluates, 'miners' could be the algorithms that process and make sense of these data points, and the 'protocol' could be the overarching training algorithm that adjusts the model based on the processed data, just like an training environment.

how highlight

nodes as data points

these data points are the raw material that AI models use to learn and make decisions. just as nodes in a blockchain scrutinize every transaction for validity, each data point in an AI model is evaluated and weighted, contributing to the model's overall understanding of the problem it's designed to solve. the idea here is that the role of nodes in blockchain can be linked to the role of data points or features in AI, serving as the foundational elements upon which more complex structures are built.

in a machine learning model, each data point represents an instance of the problem you're trying to solve, and features are the individual characteristics or attributes of that instance. for example, if you're building a machine learning model to predict house prices, each house is a data point, and its features could include the number of bedrooms, square footage, location, etc.

during the training process, the model learns the optimal weights to assign to each feature for the most accurate predictions. this is akin to how nodes validate each transaction before it's added to a block. in both cases, these foundational elements—whether they're nodes in a blockchain or data points in an AI model—undergo a validation process that contributes to the integrity of the larger system.

moreover, in a more advanced setup, one could even imagine a decentralized AI model where each 'node' or data point is stored across a distributed network, similar to a blockchain. this would allow for a more transparent and secure way to handle data, as each data point could be validated and encrypted independently. this decentralized approach could also make the model more robust against biased or malicious data, as the community of participants could have a say in the validation process, much like how transactions in a blockchain need to be verified by multiple nodes.

miners as the algorithms/layers

moving on to the concept of miners in blockchain, they serve a critical role in grouping individual transactions into blocks. this is a more complex operation that builds upon the simpler validations performed by nodes. in the context of AI, the algorithms that process and interpret these individual data points serve a similar function. algorithms like gradient descent or random forest classifiers take these 'nodes' of data points and process them into a coherent model. they adjust the weights and biases, fine-tuning the model for better performance. in essence, these algorithms act as the 'miners' of the AI world, taking the raw data and turning it into something more structured and meaningful.

this is more than just a simple aggregation; miners solve complex mathematical puzzles to find a hash that meets certain criteria, thereby proving that a significant amount of computational work has been done. this process, known as proof-of-work in many blockchains, ensures the integrity and chronological order of the blockchain. miners are essentially the algorithms that take the validated transactions (nodes) and turn them into a structured block of data that can be added to the blockchain.

drawing a parallel to artificial intelligence (AI), particularly in machine learning models like neural networks, the algorithms or training layers serve a similar function to miners. in a neural network, each layer processes the input data, applies a set of weights and biases, and passes the transformed data to the next layer. this is akin to how miners take individual, validated transactions and process them into a block. each layer in a neural network can be thought of as a 'miner' that takes the 'validated transactions' (features or data points) and processes them into a more complex and structured form (the output of the layer), which is then passed on for further processing or for making the final prediction or classification.

the training layers in a neural network are governed by algorithms like backpropagation, which adjust the weights and biases based on the error of the model's predictions. this iterative process of adjustment is similar to how miners compete to find the correct hash for a block. both processes involve a form of optimization: miners optimize for a hash that satisfies certain conditions, while training layers optimize for the most accurate predictions by adjusting weights and biases.

in both blockchain and AI, this middle layer of 'miners' or 'algorithms/training layers' serves as the mechanism that transforms individual, simpler units (transactions in blockchain, data points in AI) into a more complex and structured form (blocks in blockchain, trained models in AI). they are the workhorses that do the heavy computational lifting, ensuring that the system functions as intended.

the idea of integrating these two—having a decentralized network of 'miners' that contribute to the training of an AI model—could offer some intriguing possibilities.

blockchain as a training environment

protocol as training environment

lastly, the protocol in a blockchain environment sets the rules for how blocks are added to the chain, ensuring that all nodes and miners are in agreement. this is the overarching structure that governs the smaller operations. in AI, the training environment, which includes the training algorithm and hyperparameters, serves a similar purpose. it dictates how the model should adjust itself based on the processed data, setting the stage for iterative learning. just as the blockchain protocol ensures that all transactions are recorded in a consistent and immutable manner, the training environment in AI ensures that the model learns and adapts in a structured way.

it's the framework that ensures all the components—nodes, miners, and blocks—work in harmony to maintain the integrity, security, and functionality of the entire system. the protocol is what makes a blockchain a blockchain, setting the conditions under which the decentralized network operates.

similarly, in the realm of artificial intelligence (AI), particularly in machine learning, the training environment acts as the protocol. it's the set of conditions under which the model learns from data. this includes not just the algorithm used for learning, such as gradient descent for neural networks, but also the hyperparameters, the loss function, the learning rate, and even the data preprocessing steps. all of these elements come together to define how the model will learn from its data, just as the blockchain protocol defines how the network will operate.

in both cases, the protocol or training environment serves as the 'rulebook' that governs the behavior of the system's components. in a blockchain, the protocol ensures that transactions are processed in a specific way, that blocks are added under certain conditions, and that miners are rewarded according to predetermined rules. in an AI model, the training environment dictates how the model should adjust its internal parameters based on the input data, how it should measure its performance, and how it should adapt over time.

the training environment in AI, like the protocol in blockchain, also has a role in ensuring consistency and reliability. just as a blockchain protocol is carefully designed to prevent double-spending and to ensure secure, immutable record-keeping, the training environment for an AI model is designed to ensure that the model learns effectively and generalizes well to new, unseen data.

understanding this parallel opens up some fascinating avenues for exploration. for instance, could we see the development of decentralized training environments, governed by smart contracts, where multiple parties can contribute data or computational resources for AI training? could there be a blockchain-like 'consensus algorithm' for determining the optimal hyperparameters for a machine learning model? these are areas where the protocol-like nature of the training environment could intersect with blockchain concepts, potentially leading to more transparent, robust, and decentralized AI systems.


by understanding these parallels, we can start to imagine a future where AI models are trained and operate in a manner that is more transparent, decentralized, and secure. this could open up new avenues for community-driven AI development, ethical considerations, and even novel forms of decentralized decision-making.

training decentralized

using strategies like, distributed training using a server and worker nodes, for parallely computing train inputs. implementation in synchronous or asynchronous environment, where the path will be defined by the amount of data that has to trained on. there are multiple strategy in both tensorflow and pytorch, which includes - MirroredStrategy, TPUStrategy, MultiWorkerMirroredStrategy, CentralStorageStrategy, ParameterServerStrategy. I have worked with Mirrored, MultiWorkerMirrored and ParameterServer, each of them using custom configuration of how a data/model should be trained in sync/async manner. and with pytorch contributing with Distributed Data Parallel (DDP), Fully Shared Data Parallel (FSDP) and RPC Distributed Learning.

tensorflow parameter server image source

by far, the training from parameter server strategy is more efficient and a considerable approach of training data/model parallely on a distributed network using large-scale data. this strategy is designed to manage the complexities of synchronizing model parameters across multiple worker nodes, and it's especially useful for scenarios where the model and/or the dataset is too large to fit into the memory of a single machine.

the two main components of this - parameter server and worker nodes. parameter server are responsible for storing and managing the model parameters. they receive updates from worker nodes and apply these updates to the model parameters. there can be even be one or multiple parameter servers depending on the scale of the problem. whereas, worker nodes perform the actual computation, i.e., the forward and backward propagation of the neural network.

you can check out this tutorial on PSS for onboarding distributed computing. and, a work-on implementation of parameter server strategy using greenfield data architecture for managing bigdata - github repo

why?

it'll be fun experimenting two technologies of the decade, utilizing each other potential!

for?

the humanity, the ability to reach ∞

if? (evil AI)

one might be thinking, if AI got the blockchain, wouldn't it be creating it's own blockchain, and destroy humanity -- technology is not a joke! for instance, think of a self driving car, if the car's thinking capacity is at max, the more it can do is choose it's own way, and not be flying around (unless, it have the required machine parts :), similarly, AI on it's own will sure try to extend the boundaries by questioning?, that's how a human learns from nursery to graduation, the way of questioning. if we train well, we will all be in benefit. for acheiving the unknown, one must master the known.

now?

there's more to the play for AI in the world of blockchain, but less implemented. none are trusted, no one will give their 'data' in the name of research, unless they are being incentivized. data is the new oil. even big giants manipulate user data, for user to be benefit from this, blockchain is the solution. get paid, while training the decentralized AI, new solution revolutionize past problems (while creating new problems), and this will provide help to all of us.

i am onto creating an environment, where training and evaluation will be totally on a distributed network, using the ultimate potential of the blockchain. school for AI - a school where AI will be trained and mananged by a pure decentralized AI entity governing them.

please feel free to contribute or make changes using the below links.