The weight-adjustment function is used to score workers based on their revealed accuracy. It does this by altering the distribution of confidence other actors have placed in their peers. This update will typically occur by calculating the loss of a worker's inferences and then setting the new weights as a running average of those losses and the current weights.
In this page, we'll create a weight-adjustment function for our running example of building a topic for index levels. Each index level represents the relative performance of NFT collections part of the Yuga Labs brand over time.
To create a weight-adjustment function for your topic, follow the steps outlined in the tutorial below to create your first function on Blockless:
Once you have installed the Blockless CLI and created your initial sample function, you must modify it to implement the logic for assigning weights to the inferences made by registered workers on your topic.
You can see the function we used for the Indexes topic as an example once it is open-sourced.
To make tests in your function, you can invoke the function locally using:
bls function invoke
The output of your function needs to follow the same output as the example above, which looks like this:
Note that the keys of the
weights property are cosmos addresses of workers, and the values are the new weight values to be set.
After testing now, you can deploy your function using the following:
bls function deploy
After testing and deploying your function, save the
function_id and the
method (the name of the Wasm file) to use when creating your topic.
Updated 7 days ago