-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a389ea1
Showing
5 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<div align="center"> | ||
|
||
# **Omron SN2 (𝜏, β)** | ||
|
||
[![Discord Chat](https://img.shields.io/discord/308323056592486420.svg?logo=discord)](https://discord.gg/bittensor) | ||
|
||
### Proof of Inference | ||
|
||
[Documentation](https://docs.omron.ai/) • [X](https://twitter.com/omron_ai) • [Inference Labs](https://twitter.com/inference_labs) • [Explorer](https://taostats.io/) • [Dashboard](https://wandb.ai/inferencelabs/omron) | ||
|
||
</div> | ||
|
||
Omron represents a significant stride in enhancing the Bittensor network, aiming to create the world's largest peer-to-peer **Verified** Intelligence network, by building a Proof-of-Inference system for the Bittensor network. This initiative aligns with the Opentensor foundation's criteria for innovative subnet solutions. zk-ML allows AI models to be converted into a unique 'fingerprint,' a circuit that can be used to verify that a model's prediction was generated by a specific AI model, thereby providing what we term as Proof-of-Inference. | ||
|
||
## Proof of Weights SDK | ||
|
||
The proof of weights SDK allows validators from various subnets to publish their reward function inputs to validators within the omron subnet. | ||
|
||
## Usage | ||
|
||
The proof of weights SDK is available on PyPI as `proof-of-weights` (https://pypi.org/project/proof-of-weights/). | ||
|
||
```python | ||
import proof_of_weights | ||
proof_of_weights.submit_inputs(reward_function_inputs: list) | ||
proof_of_weights.get_proof() | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import hashlib | ||
import json | ||
import typing | ||
|
||
import bittensor | ||
import requests | ||
|
||
__VERSION__: typing.Final[str] = "0.0.1" | ||
OMRON_NETUID: typing.Final[int] = 2 | ||
|
||
|
||
class Proof_Of_Weights: | ||
def __init__(self, wallet_name: str, wallet_hotkey: str, omron_validator_ss58: str, netuid: int, network: str = "finney"): | ||
""" | ||
Initialize the Proof of Weights class with your wallet and a validator's hotkey from the omron subnet. | ||
""" | ||
self._wallet = bittensor.wallet(wallet_name, wallet_hotkey) | ||
self._btnetwork = bittensor.subtensor(network=network) | ||
self._omron_validator_ss58 = omron_validator_ss58 | ||
self._omron_validator_axon = self._bt_newtork.get_axon_info(netuid=OMRON_NETUID, hotkey_ss58=self.omron_validator_ss58) | ||
self._omron_validator_ip = self._omron_validator_axon.ip | ||
self._netuid = netuid | ||
self._last_transaction_hash = "" | ||
|
||
|
||
def submit_inputs(self, reward_function_inputs: list) -> str: | ||
""" | ||
Submit reward function inputs from network with netuid to a validator on the omron subnet. | ||
""" | ||
# serialize the reward function inputs as json bytes | ||
inputs_bytes = json.dumps(reward_function_inputs).encode() | ||
# sign the inputs with your hotkey | ||
signature = self._wallet.hotkey.sign(inputs_bytes) | ||
# send the reward function inputs and signature to the omron subnet on port 8000 | ||
response = requests.post(f"http://{self._omron_validator_ip}:8000/submit_inputs", data=inputs_bytes, signature=signature, sender=self._wallet.hotkey.ss58_address, netuid=self._netuid) | ||
if response.status_code != 200: | ||
return "" | ||
# get the transaction hash | ||
self._last_transaction_hash = hashlib.sha256(inputs_bytes + signature).hexdigest() | ||
return self._last_transaction_hash | ||
|
||
|
||
def get_proof(self) -> dict: | ||
""" | ||
Get the proof of weights from the omron subnet validator. | ||
""" | ||
response = requests.get(f"http://{self._omron_validator_ip}:8000/get_proof_of_weights/{self._last_transaction_hash}") | ||
if response.status_code != 200: | ||
return {} | ||
return response.json() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bittensor | ||
requests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import setuptools | ||
import proof_of_weights | ||
|
||
with open("README.md", "r") as f: | ||
long_description = f.read() | ||
|
||
setuptools.setup( | ||
name="Proof of Weights", | ||
version=proof_of_weights.__VERSION__, | ||
python_requires=">3.6.*", | ||
description="SDK for validators from various subnets to publish their reward function inputs to validators within the omron subnet.", | ||
long_description=long_description, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/inference-labs-inc/proof-of-weights-sdk", | ||
packages=["proof_of_weights"], | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
], | ||
requires=["requests", "bittensor"], | ||
) |