Spaces:
Sleeping
Sleeping
File size: 4,351 Bytes
478332b 0765653 9f4a5ad 0765653 478332b 0765653 ff2df59 0765653 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad 478332b 9f4a5ad |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
"""
Streamlit dashboard for the Dippy Roleplay Subnet Leaderboard
"""
import requests
import streamlit as st
import pandas as pd
st.set_page_config(layout="wide")
import pandas as pd
import numpy as np
REMOTE_LEADERBOARD_URL = "https://dippy-bittensor-subnet.com/minerboard"
def iswin(score_i, score_j, block_i, block_j):
MAX_PENALTY = 0.03 # Adjust this value as needed
penalty = MAX_PENALTY
score_i = (1 - penalty) * score_i if block_i > block_j else score_i
score_j = (1 - penalty) * score_j if block_j > block_i else score_j
return score_i > score_j
def calculate_win_rate(df):
n = len(df)
win_counts = np.zeros(n)
for i in range(n):
for j in range(n):
if i != j:
if iswin(df.loc[i, 'total_score'], df.loc[j, 'total_score'],
df.loc[i, 'block'], df.loc[j, 'block']):
win_counts[i] += 1
return win_counts / (n - 1) # Divide by (n-1) as each row isn't compared with itself
def leaderboard_dashboard():
# load the logo from image.txt file as base64
with open("image.txt", "r") as f:
image = f.read()
st.markdown(
f"""
<div style="text-align: center;">
<img src="data:image/png;base64,{image}" alt="Dippy Roleplay Logo" width="600" height="300" style="margin-bottom: 2rem;">
<h1 style="margin-top: 0;">SN11-Dippy-Roleplay Leaderboard</h1>
<div style="font-size: 18px;">This is the leaderboard for the Dippy validation API hosted by SN11.</div>
</div>
""",
unsafe_allow_html=True,
)
# Add emojis based on the status
status_emojis = {
'COMPLETED': '✅COMPLETED',
'FAILED': '❌FAILED',
'QUEUED': '🕒QUEUED',
'RUNNING': '🏃RUNNING'
}
# Get the minerboard data from the API
# response = requests.get("http://34.41.206.211:8000/minerboard")
response = requests.get(REMOTE_LEADERBOARD_URL)
if response.status_code != 200:
st.error("Failed to fetch minerboard data.")
return
# Parse the response JSON data
minerboard_data = response.json()
# Convert the data to a DataFrame
minerboard = pd.DataFrame(minerboard_data)
minerboard['status'] = minerboard['status'].map(lambda status: status_emojis.get(status, status))
# Sort the minerboard_winrate by the total_score column
minerboard = minerboard.sort_values(by='total_score', ascending=False, ignore_index=True)
front_order = ['uid', 'hotkey', 'total_score', 'status', 'chat_template_type', 'hash']
# move status column to the front
column_order = front_order + [column for column in minerboard.columns if column not in front_order]
minerboard = minerboard[column_order]
minerboard_winrate = pd.DataFrame(minerboard_data)
minerboard_winrate['status'] = minerboard_winrate['status'].map(lambda status: status_emojis.get(status, status))
minerboard_winrate['win_rate'] = calculate_win_rate(minerboard_winrate)
minerboard_winrate = minerboard_winrate.sort_values(by='win_rate', ascending=False, ignore_index=True)
column_order = ['uid', 'win_rate', 'hotkey', 'repo_namespace', 'repo_name', 'total_score', 'block', 'vibe_score', 'qualitative_score', 'creativity_score', 'coherence_score', 'model_size_score']
# Create a new DataFrame with only the specified columns
minerboard_winrate = minerboard_winrate[column_order]
st.header("Leaderboard by Win Rate ")
st.dataframe(minerboard_winrate, hide_index=True)
with st.expander("See detailed calculation method"):
st.write("The win rate is calculated by comparing each miner against every other miner. Note that this board is only an approximation as queued miners have a score of 0, validators are omitted, etc.")
st.code("""
Example of calculating a win:
def iswin(score_i, score_j, block_i, block_j):
penalty = 0.03
score_i = (1 - penalty) * score_i if block_i > block_j else score_i
score_j = (1 - penalty) * score_j if block_j > block_i else score_j
return score_i > score_j
""")
st.markdown("---")
st.header("Minerboard")
st.dataframe(minerboard, hide_index=True)
st.markdown("---")
if __name__ == '__main__':
leaderboard_dashboard()
|