All Projects β†’ opentensor β†’ bittensor

opentensor / bittensor

Licence: MIT license
Internet-scale Neural Networks

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to bittensor

digital-assets-association-poland
πŸ‹ πŸ‹ https://meetup.com/Silesia-Blockchain-Meetup πŸ‹ πŸ‹
Stars: ✭ 14 (-85.57%)
Mutual labels:  substrate, polkadot
subsocial-node
NOTE: Development continues in https://github.com/dappforce/subsocial-parachain repo. Subsocial full node with Substrate/Polkadot pallets for decentralized communities: blogs, posts, comments, likes, reputation.
Stars: ✭ 73 (-24.74%)
Mutual labels:  substrate, polkadot
reef-chain
EVM compatible chain with NPoS/PoC consensus
Stars: ✭ 142 (+46.39%)
Mutual labels:  substrate, polkadot
nft-gallery
NFT Explorer πŸ—Ί 🧭 running on Kusama and Polkadot
Stars: ✭ 281 (+189.69%)
Mutual labels:  substrate, polkadot
Decentra-Network
This is an open source decentralized application network. In this network, you can develop and publish decentralized applications.
Stars: ✭ 58 (-40.21%)
Mutual labels:  p2p, p2p-network
substrate-debug-kit
A collection of debug tools, scripts and libraries on top of substrate.
Stars: ✭ 96 (-1.03%)
Mutual labels:  substrate, polkadot
jupiter
Wasm smart contract networks powered by Substrate FRAME Contracts pallet in Polkadot ecosystem.
Stars: ✭ 49 (-49.48%)
Mutual labels:  substrate, polkadot
mangata-node
Mangata ❀️ Substrate & Polkadot
Stars: ✭ 52 (-46.39%)
Mutual labels:  substrate, polkadot
common
Utilities and base libraries for use across polkadot-js for Polkadot and Substrate. Includes base libraries, crypto helpers and cross-environment helpers. Full documentation & examples available.
Stars: ✭ 221 (+127.84%)
Mutual labels:  substrate, polkadot
microsocial
Microsocial is an experimental social platform that takes a peer-to-peer approach to social media.
Stars: ✭ 21 (-78.35%)
Mutual labels:  p2p, p2p-network
ares
Completely decentralized oracle protocol
Stars: ✭ 51 (-47.42%)
Mutual labels:  substrate, polkadot
polkawallet-flutter
Replace to: https://github.com/polkawallet-io/app
Stars: ✭ 107 (+10.31%)
Mutual labels:  substrate, polkadot
polkascan-os
Polkascan Open Source
Stars: ✭ 52 (-46.39%)
Mutual labels:  substrate, polkadot
rmrk-substrate
Nested, conditional & Multi-resourced NFTs.
Stars: ✭ 44 (-54.64%)
Mutual labels:  substrate, polkadot
subwasm
Subwasm is a cli utility to help you know more about WASM Runtimes. It help downloading, inspecting and comparing Substrate based chains such as Polkadot or Kusama.
Stars: ✭ 53 (-45.36%)
Mutual labels:  substrate, polkadot
substrate-graph
a compact graph indexer stack for parity substrate, polkadot, kusama
Stars: ✭ 28 (-71.13%)
Mutual labels:  substrate, polkadot
blockchain
재미둜 μ‹œμž‘ν•œ p2p 블둝체인 개발
Stars: ✭ 17 (-82.47%)
Mutual labels:  p2p, p2p-network
polkadot-wiki-old
The Polkadot wiki.
Stars: ✭ 56 (-42.27%)
Mutual labels:  substrate, polkadot
substrate-tcr-ui
A react.js frontend for Substrate TCR runtime.
Stars: ✭ 14 (-85.57%)
Mutual labels:  substrate, polkadot
polkadot-apps
Fork of Polkadot.js Apps with Subsocial types.
Stars: ✭ 17 (-82.47%)
Mutual labels:  substrate, polkadot

Bittensor

Discord Chat PyPI version License: MIT


Internet-scale Neural Networks

Discord β€’ Docs β€’ Network β€’ Research β€’ Code

At Bittensor, we are creating an open, decentralized, peer-to-peer network that functions as a market system for the development of artificial intelligence. Our purpose is not only to accelerate the development of AI by creating an environment optimally condusive to its evolution, but to democratize the global production and use of this valuable commodity. Our aim is to disrupt the status quo: a system that is centrally controlled, inefficient and unsustainable. In developing the Bittensor API, we are allowing engineers to monetize their work, gain access to machine intelligence and join our community of creative, forward-thinking individuals. For more info, read our paper.

1. Documentation

https://app.gitbook.com/@opentensor/s/bittensor/

2. Install

Three ways to install Bittensor.

  1. Through the installer:
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/opentensor/bittensor/master/scripts/install.sh)"
  1. With pip:
$ pip3 install bittensor
  1. From source:
$ git clone https://github.com/opentensor/bittensor.git
$ python3 -m pip install -e bittensor/

3. Using Bittensor

The following examples showcase how to use the Bittensor API for 3 seperate purposes.

3.1. Client

Querying the network for representations.

import bittensor
import torch
wallet = bittensor.wallet().create().register()
graph = bittensor.metagraph().sync()
representations, _, _ = bittensor.dendrite( wallet = wallet ).forward_text (
    endpoints = graph.endpoints,
    inputs = "The quick brown fox jumped over the lazy dog"
)
representations = // N tensors with shape (1, 9, 1024)
...
// Distill model. 
...
loss.backward() // Accumulate gradients on endpoints.

3.2. Server

Serving a custom model.

import bittensor
import torch
from transformers import GPT2Model, GPT2Config

model = GPT2Model( GPT2Config(vocab_size = bittensor.__vocab_size__, n_embd = bittensor.__network_dim__ , n_head = 8))
optimizer = torch.optim.SGD( [ {"params": model.parameters()} ], lr = 0.01 )

def forward_text( pubkey, inputs_x ):
    return model( inputs_x )
  
def backward_text( pubkey, inputs_x, grads_dy ):
    with torch.enable_grad():
        outputs_y = model( inputs_x.to(device) ).last_hidden_state
        torch.autograd.backward (
            tensors = [ outputs_y.to(device) ],
            grad_tensors = [ grads_dy.to(device) ]
        )
        optimizer.step()
        optimizer.zero_grad() 

wallet = bittensor.wallet().create().register()
axon = bittensor.axon (
    wallet = wallet,
    forward_text = forward_text,
    backward_text = backward_text
).start().serve()

3.3. Validator

Validating models by setting weights.

import bittensor
import torch

graph = bittensor.metagraph().sync()
dataset = bittensor.dataset()
chain_weights = torch.ones( [graph.n.item()], dtype = torch.float32 )

for batch in dataset.dataloader( 10 ):
    ...
    // Train chain_weights.
    ...
bittensor.subtensor().set_weights (
    weights = chain_weights,
    uids = graph.uids,
    wait_for_inclusion = True,
    wallet = bittensor.wallet(),
)

4. Features

4.1. CLI

Creating a new wallet.

$ btcli new_coldkey
$ btcli new_hotkey

Listing your wallets

$ btcli list

Registering a wallet

$ btcli register

Running a miner

$ btcli run

Checking balances

$ btcli overview

Checking the incentive mechanism.

$ btcli metagraph

Transfering funds

$ btcli transfer

Staking/Unstaking from a hotkey

$ btcli stake
$ btcli unstake

4.2. Selecting the network to join

There are two open Bittensor networks: staging (Nobunaga) and main (Nakamoto, Local).

  • Nobunaga (staging)
  • Nakamoto (main)
  • Local (localhost, mirrors nakamoto)
$ export NETWORK=local 
$ python (..) --subtensor.network $NETWORK
or
>> btcli run --subtensor.network $NETWORK

4.3. Running a template miner

The following command will run Bittensor's template miner

$ cd bittensor
$ python ./bittensor/_neuron/text/template_miner/main.py

or

>> import bittensor
>> bittensor.neurons.text.template_miner.neuron().run()

OR with customized settings

$ cd bittensor
$ python3 ./bittensor/_neuron/text/template_miner/main.py --wallet.name <WALLET NAME> --wallet.hotkey <HOTKEY NAME>

For the full list of settings, please run

$ python3 ~/.bittensor/bittensor/bittensor/_neuron/neurons/text/template_miner/main.py --help

4.4. Running a template server

The template server follows a similar structure as the template miner.

$ cd bittensor
$ python3 ./bittensor/_neuron/text/template_server/main.py --wallet.name <WALLET NAME> --wallet.hotkey <HOTKEY NAME>

or

>> import bittensor
>> bittensor.neurons.text.template_server.neuron().run()

For the full list of settings, please run

$ cd bittensor
$ python3 ./bittensor/_neuron/text/template_server/main.py --help

4.5. Serving an endpoint on the network

Endpoints are served to the bittensor network through the axon. The axon is instantiated via a wallet which holds an account on the Bittensor network.

import bittensor

wallet = bittensor.wallet().create().register()
axon = bittensor.axon (
    wallet = wallet,
    forward_text = forward_text,
    backward_text = backward_text
).start().serve()

4.6. Syncing with the chain/ Finding the ranks/stake/uids of other nodes

Information from the chain is collected/formated by the metagraph.

btcli metagraph

and

import bittensor

meta = bittensor.metagraph()
meta.sync()

# --- uid ---
print(meta.uids)

# --- hotkeys ---
print(meta.hotkeys)

# --- ranks ---
print(meta.R)

# --- stake ---
print(meta.S)

4.7. Finding and creating the endpoints for other nodes in the network

import bittensor

meta = bittensor.metagraph()
meta.sync()

### Address for the node uid 0
endpoint_as_tensor = meta.endpoints[0]
endpoint_as_object = meta.endpoint_objs[0]

4.8. Querying others in the network

import bittensor

meta = bittensor.metagraph()
meta.sync()

### Address for the node uid 0
endpoint_0 = meta.endpoints[0]

### Creating the wallet, and dendrite
wallet = bittensor.wallet().create().register()
den = bittensor.dendrite(wallet = wallet)
representations, _, _ = den.forward_text (
    endpoints = endpoint_0,
    inputs = "Hello World"
)

5. License

The MIT License (MIT) Copyright Β© 2021 Yuma Rao

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the β€œSoftware”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED β€œAS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

6. Acknowledgments

learning-at-home/hivemind

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].