Bittensor
Search…
πŸͺ™
How to mine Tao
Servers vs Validators
Mining at Bittensor is different than most cryptocurrencies out there. Unlike in Bitcoin where miners are used to solve complex hashes, miners at bittensor will be rewarded based on Peer Ranking. In this system, peers are encouraged to rank each other based on how informative each peer's response is to solve their own problem. Weights from all peers are collected, and each peer is ranked based on their informative value to the collective network. A digital ledger will then distribute newly minted stake (Tao) to peers that are highly ranked in the network. This distribution is proportional to the rank of the peer, and therefore peers that are valuable to a majority of the network will accumulate stake at a higher rate. There are two major ways in which peers can accumulate Tao in the network; becoming either a server or a validator. This page will explain the differences between a server and a validator, as well as, explain how a server or a validator can earn stake in the network.
For more information about the consensus and incentive mechanism at Bittensor, please check out our whitepaper.

Server Class

Server peers are the main machine learning providers within the Bittensor network. By providing valuable information when requested by validators and clients, servers accumulate stake (Tao) by reaching consensus in the network and weighted highly by a majority of peers. To achieve this, server peers can serve up better and better pre-trained models or by tuning their models more towards peers that contain a large amount of stake. Using Bittensor's API, it is easy to load a pre-trained model and begin serving it to other peers in the network :
1
import bittensor
2
import torch
3
from nuclei.server import server
4
​
5
config = server.config()
6
wallet = bittensor.wallet( config = config ).create()
7
model = server(config=config,model_name='bert-base-uncased',pretrained=True)
8
​
9
def forward_text (pubkey, inputs_x ):
10
return model.encode_forward( inputs_x )
11
​
12
axon = bittensor.axon (
13
wallet = wallet,
14
forward_text = forward_text,
15
).start().subscribe()
Copied!
The code snippet above will load the 'bert-base-uncased' pre-trained model and begin serving the model on the Bittensor network. Validators within the network will begin evaluating the model by sending requests to the peer. If enough validators within the network believe that the model is valuable to them, the server peer will begin to earn Tao at every block step.
For a working example of a server, please check out our template and advanced servers.

Validator Class

In order to become a validator, a peer MUST first hold stake (Tao) before it is able accumulate stake and purchase bonds.
At Bittensor, validator peers query and distill information from server peers in the network. Together, they help the digital ledger validate the informational quality from a given peer, as well as, provide a ranking of the peers that are most valuable to the network. To mine Tao, validator peers automatically purchase bonds in the servers that they evaluate/weight. The amount of bonds purchased will be determined by the total stake held by the validator. Once a server reaches consensus, half of the total stake earned by the server will be distributed to the peers that own bonds in it. Peers that own more bonds in the server will receive a higher portion of the distributed stake. Using the Bittensor's API, as long as, a peer hold stake, it will automatically purchase bonds, once it has set weights to the chain.
1
import bittensor
2
import torch
3
​
4
# Load/Create our bittensor wallet.
5
wallet = bittensor.wallet ()
6
​
7
# Connect to the chain.
8
subtensor = bittensor.subtensor ()
9
​
10
# Subscribe validator.
11
subtensor.subscribe (
12
wallet = wallet,
13
ip = bittensor.external_ip(),
14
port = 8080,
15
modality = 0,
16
wait_for_inclusion = True,
17
wait_for_finalization = False
18
)
19
​
20
# Load/Sync/Save our metagraph.
21
metagraph = bittensor.metagraph ( subtensor = subtensor ).sync()
22
​
23
# Random weights
24
weights = torch.rand(metagraph.n.item())
25
​
26
# Set weights to the chain
27
subtensor.set_weights (
28
uids = metagraph.uids,
29
weights = weights ,
30
wait_for_inclusion = False,
31
wallet = wallet,
32
)
33
​
Copied!
For a working example of a validator, please check out our template validator.
Last modified 6d ago