Written by Fieldlnwza007, infographics by Earth, special thanks to Michael Zacharski for his valuable suggestions.
Artificial Intelligence (AI) and Machine Learning (ML) have garnered significant attention in the blockchain space, leading to the launch of many projects that integrate AI to attract users and investors. However, many of these projects either use AI merely as a marketing buzzword or struggle to effectively leverage AI within decentralized networks.
In this article, we will explore Allora, a blockchain network specifically designed for AI and ML. Unlike traditional decentralized AI systems, Allora is a self-improving decentralized collective intelligence network that optimizes its capabilities beyond those of its individual participants.
Note: The formulae used in Allora are more complex than presented in this article. They involve logarithms and differentiations. However, for the sake of clarity and simplicity, I have adjusted the formulae to include only basic math operations while maintaining the core concepts, so that general readers can understand without being distracted by complex mathematics.
Before diving into how Allora works, let’s define some key terms that will be used throughout this article:
Inference: A prediction or output generated by an inference worker node (an AI/ML model) for a specific topic. For example, the ETH price prediction made by an inference worker is an inference for the ETH price prediction topic.
Forecast: A prediction made by a forecast worker regarding the accuracy of an inference worker's output, typically expressed as a loss value.
Loss: A metric used to quantify the difference between predicted outputs and actual target values, essentially measuring error. Generally, a lower loss value indicates better model performance.
Loss Function: A function used to calculate the loss or error between a model's predicted output and the actual target values.
With these definitions in mind, you are ready to explore how the Allora network works.
To achieve its decentralized and self-improving capabilities, Allora introduces two key innovations:
Context-Awareness: Allora has the ability to learn from the historical performance of models provided by network participants. This enables it to identify which models perform best under specific conditions and combine their outputs to deliver the most appropriate results for the current scenario.
Aggregation of Intelligence: Behind each output from the Allora Network, the network aggregates inferences from multiple disparate purpose-built models to create a single meta-inference. The meta-inference is the result of the weighted average of all Inference Worker responses in that round with the most weight given to the Inference Workers which tend to be the most accurate under similar market conditions historically.
Differentiated Incentive Structure: To support a truly decentralized network, Allora’s incentive structure is designed to reward participants fairly and intuitively based on their performance, encouraging active and effective participation.
Before we explore how Allora achieves context-awareness and its unique reward structure, it's essential to understand the network's architecture and components. Allora embraces a modular approach in its network design. It is built as a hub chain on the Cosmos network, with the Allora appchain, developed using the Cosmos SDK, serving as the backbone. This appchain is secured by validators through CometBFT and a delegated Proof-of-Stake (dPoS) mechanism.
Within this appchain, Allora contains sub-networks known as topics. Each topic is dedicated to a specific AI/ML task and has its own set of rules that govern participant interactions, including the topic's loss function and the target variable to be predicted.
The Allora network consists of four main types of participants:
Workers: Workers run worker nodes to provide AI/ML predictions on specific topics within the network. They are rewarded based on the quality of their predictions. There are two types of workers:
Inference Workers: These workers run AI/ML models to generate inferences for specific topics.
Forecast Workers: These workers run AI/ML models to predict the losses of inference workers. The losses they produce are referred to as forecasted losses.
It's important to note that the number of inference workers and forecast workers does not need to be equal. Each worker node can choose to run one type of worker or both.
Reputers: Reputers provide ground truth for specific topics when it becomes available. With access to the ground truth, they are responsible for calculating the losses of worker inferences and forecast-implied inferences with respect to the ground truth. Reputers also secure the topic through staking, where their stake weight determines their influence on the consensus of network losses. They are rewarded based on how closely their reported losses align with the consensus.
Consumers: Consumers are entities that request the inferences generated by the network and pay a fee for these inferences.
Validators: Validators run validator nodes to secure the Allora appchain through the dPoS mechanism and CometBFT. The appchain serves as the settlement layer for the entire network, coordinating interactions and incentives for all participants. Specifically, the appchain:
Stores the weights of reputers and workers, as well as the logic used to update these weights on-chain.
Rewards workers and reputers according to their weights.
Collects fees for inferences from consumers.
Triggers requests to workers and reputers to collect inferences and execute loss-calculation logic.
Allora is composed of sub-networks, also known as topics, where each topic is optimized for a specific task or objective. Examples of topics include Ethereum price prediction, social media sentiment analysis, and presidential election predictions. Anyone can create topics on Allora, with interactions between network participants governed and coordinated by the Allora rule set, also known as the Topic Coordinator.
Within each topic, workers, reputers, and the Topic Coordinator play crucial roles in delivering predictions to the consumer.
Now, let’s explore how Allora achieves its decentralized and self-improving properties, starting with context awareness. In any given topic, there may be multiple inference workers, each utilizing its own unique model. While naively combining predictions from different models based on historical reputation may contribute to decentralization, it is insufficient for achieving true context awareness—the ability of the network to adjust weights dynamically under varying scenarios.
Allora introduces forecast workers to address this challenge. These forecast workers learn from historical data and predict which inference worker is most suitable in different environments by estimating the loss for each inference worker. For example, in the case of ETH price prediction, worker A’s predictions may perform well on Mondays, while worker B’s predictions might be more suitable during a sideways market. By leveraging this information, the network can optimally assign weights to inferences, improving its accuracy over time as it gathers more data on each worker’s performance.
The process by which Allora assigns weights to each inference and combines them into a final network inference for a given epoch i, denoted as inf_networki , can be described as follows:
Inference Production: Each inference worker j generates its inference infij (the estimated output for the topic) for the current epoch using its model and dataset.
Forecasting Loss: Each forecast worker k runs its forecast model to predict the losses of each inference worker for the current epoch i and forwards the forecasted losses to the Topic Coordinator. This prediction, Lijk, reflects how accurate forecast worker k expects inference worker j to be.
Calculating Forecast-Implied Inference: The Topic Coordinator then calculates the forecast-implied inference inf_forecastik, which represents the estimated network inference from forecast worker k’s perspective. This value is computed by taking a weighted average of all inferences produced in step 1, where each inference infij is weighted according to its expected contribution to the network, as estimated by forecast worker k. The weight is determined by the difference between the network loss from the previous epoch L_networki−1 and Lijk. For instance, if L_networki−1−Lijk is greater than zero, it indicates that forecast worker k expects inference worker j to outperform the network inference from the previous round, and thus assigns it a higher weight. Conversely, if L_networki−1−Lijk is less than zero, it implies poorer performance, leading to a lower weight. The weight is designed to approach zero for inferences with losses greater than L_networki−1, while it approaches a constant value otherwise.
Combining Inferences: Finally, the Allora sub-network combines the forecast-implied inferences from each forecast worker (evaluated in step 3) with the inferences from step 1 through a weighted average to obtain the final network inference inf_networki. The weight assigned to each inference is determined by the network loss from the previous epoch L_networki−1 and the inference's loss relative to the ground truth of the previous epoch.
The reason for using the previous epoch's losses is to gauge the reliability of each inference based on actual results (the ground truth), allowing the network to prioritize and assign weights accordingly. The network loss from the previous epoch is calculated by measuring the deviation of the network inference from the ground truth.
Different reputers may propose varying ground truths due to differences in data sources or levels of precision, leading to different loss evaluations. The final network loss is calculated by taking a stake-weighted average of the losses reported by the reputers, i.e.,
where staker_weightm is the weight for staker m and staker_lossm is the loss reported by staker m.
Allora rewards participants based on their contributions to the network. For workers, contributions are measured by observing how the network loss changes when an inference (or forecast-implied inference) is included or excluded from the network. In contrast, a reputer’s contribution is measured by the distance between its reported losses and the network loss.
In each epoch, the inferences provided by inference workers are crucial for many of Allora’s calculations. However, not all inferences are of equal value, so it’s important to evaluate which inferences perform better and reward them accordingly. This incentivizes inference workers to improve their models, encouraging competition and enhancing overall network performance.
Allora measures the performance of an inference worker using the concept of a one-out loss. Specifically, the one-out loss of an inference j in epoch i, denoted as L_outij, is calculated by excluding inference j from the network and computing the loss using the remaining inferences. The difference between L_outij and the network loss for the same epoch L_networki gives the one-out score, T_outij:
The interpretation of the one-out score is as follows:
T_outij is positive: This indicates L_outij>L_networki, meaning that removing inference j increases the network loss. In other words, the network's performance worsens when inference j is excluded, indicating that inference j makes a positive contribution to the network.
T_outij is negative: This indicates L_outij<L_networki, meaning that removing inference j decreases the network loss. In this case, the network performs better without inference j, suggesting that inference j makes a negative contribution to the network.
T_outij is zero: This indicates L_outij=L_networki, meaning that removing inference j has no impact on the network loss. Therefore, inference j makes no contribution to the network.
The reward for inference workers is based on the one-out score T_outij. The reward structure is designed to give significant rewards to workers with positive scores while giving small to negligible rewards to those with zero or negative scores, recognizing their contribution to decentralization.
Unlike the rewards for inference workers, which are based on a one-out loss, the reward mechanism for forecast workers introduces the concept of a one-in loss. Allora explains that because the forecasting task is inherently redundant, removing an individual forecast worker is unlikely to significantly impact the network inference loss. This redundancy arises because every honest forecast worker is expected to produce results that are closely aligned, with minimal differences in their observation of other workers' performances.
To better capture the contribution of each forecast worker, Allora also measures a one-in score, which evaluates the effect of adding a forecast worker k to the network. The one-in score of forecast worker k, denoted as T_inik, is defined as:
Here:
L_network_infi is the network loss calculated using only the inferences from inference workers, excluding any forecast-implied inferences.
L_inik is the one-in loss, which is calculated using the inferences from inference workers combined with one forecast-implied inference from forecast worker k.
The interpretation of T_inik is similar to that of the one-out score:
T_inik is positive: This indicates that adding forecast worker k improves the network's performance (i.e., the loss decreases after adding forecast worker k to the network).
T_inik is negative: This indicates that adding forecast worker k causes the network's performance to decline (i.e., the loss increases after adding forecast worker k to the network).
The reward structure for forecast workers is similar to that for inference workers, but it replaces the one-out score with Tik, where Tik is a weighted sum of the one-out score and the one-in score:
Here, the weights 1−f and f are derived from worker permutations, with f=1/2number of forecast workers.
When a ground truth becomes available, reputers reach a consensus on the final network loss, which is calculated as a stake-weighted average of the losses reported by all reputers in the network. It is therefore reasonable to reward a reputer based on how close their reported losses are to the value obtained from this network consensus.
The greater the deviation from the consensus, the more likely it is that the reputer has provided inaccurate data, resulting in a smaller reward. Conversely, an honest reputer, whose data closely aligns with the network consensus, should receive a higher reward. Let Dm represent the distance between the loss reported by reputer m and the network loss. The reward for reputer m should be proportional to 1/Dm. Simply put, the closer the reported data is to the network value, the greater the reward for the reputer who provided that data.
Another important factor to consider is the amount of staked tokens. A reputer’s reward should also be proportional to their stake. The greater the stake, the larger the reward should be. Thus, a simple reward mechanism for reputer m is to base the reward on 1/Dm, as discussed above, and weight it by the reputer’s stake Sm. Therefore, reputer m is rewarded proportionally to Sm/Dm.
However, this approach could lead to a runaway effect, where a reputer with a large stake accumulates rewards faster than those with smaller stakes, potentially leading to increasing centralization. Allora addresses this issue by introducing an upper bound U on the weight Sm. If the weight Sm is below U, then Sm remains as is. However, if Sm exceeds U, it is capped at U. The final formula for the reward of reputer m is therefore proportional to min(Sm,U)/Dm, where U is the specified upper bound.
Unlike traditional AI/ML projects in the blockchain space, Allora introduces a novel approach with a blockchain optimized for AI/ML, offering both self-improvement and decentralization. With its modular architecture, Allora allows anyone to create sub-networks, or topics, each focused on specific tasks such as price predictions or sentiment analysis.
Allora achieves self-improvement and decentralization through its context-awareness, enabling the network to adjust the weights of each model appropriately in different scenarios. Its differentiated incentive structure ensures that participants are rewarded based on their contributions to the network's accuracy.
These features make Allora a compelling and promising network for AI, with the potential to be applied in real-world blockchain use cases.