Spaces:
Runtime error
Runtime error
Corey Morris
commited on
Commit
·
cd2dfb2
1
Parent(s):
6c46ed2
has data and is sortable, but does not have the model names as a row
Browse files- mmlu_data_to_example.py +47 -28
mmlu_data_to_example.py
CHANGED
|
@@ -1,43 +1,62 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 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 |
block = gr.Blocks()
|
| 29 |
-
my_blocks_space = BlocksSpace("https://huggingface.co/api/spaces", "Gradio-Blocks")
|
| 30 |
|
| 31 |
with block:
|
| 32 |
-
gr.Markdown("""Leaderboard
|
| 33 |
with gr.Tabs():
|
| 34 |
-
with gr.TabItem("
|
| 35 |
with gr.Row():
|
| 36 |
data = gr.outputs.Dataframe(type="pandas")
|
| 37 |
with gr.Row():
|
| 38 |
data_run = gr.Button("Refresh")
|
| 39 |
-
data_run.click(
|
| 40 |
# running the function on page load in addition to when the button is clicked
|
| 41 |
-
block.load(
|
| 42 |
|
| 43 |
block.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import requests
|
| 3 |
import pandas as pd
|
| 4 |
+
|
| 5 |
+
class MultiURLData:
|
| 6 |
+
def __init__(self, file_path):
|
| 7 |
+
self.file_path = file_path
|
| 8 |
+
|
| 9 |
+
def fetch_data(self):
|
| 10 |
+
# Read URLs from a file, one per line
|
| 11 |
+
with open(self.file_path, 'r') as f:
|
| 12 |
+
file_urls = [line.strip() for line in f.readlines()]
|
| 13 |
+
|
| 14 |
+
dataframes = []
|
| 15 |
+
for url in file_urls:
|
| 16 |
+
# Derive column names from the URLs
|
| 17 |
+
column_name = url.split('/')[-1].split('_')[0]
|
| 18 |
+
|
| 19 |
+
# Load data from URL
|
| 20 |
+
response = requests.get(url)
|
| 21 |
+
data = response.json()
|
| 22 |
+
|
| 23 |
+
# Convert data into a DataFrame
|
| 24 |
+
df = pd.DataFrame(data['results']).T
|
| 25 |
+
|
| 26 |
+
# Rename 'acc' column to respective file names
|
| 27 |
+
df = df.rename(columns={'acc': column_name})
|
| 28 |
+
|
| 29 |
+
# Remove 'hendrycksTest-' from the index
|
| 30 |
+
df.index = df.index.str.replace('hendrycksTest-', '')
|
| 31 |
+
|
| 32 |
+
dataframes.append(df[[column_name]]) # keep only the column of interest
|
| 33 |
+
|
| 34 |
+
# Merge the dataframes
|
| 35 |
+
# Merge the dataframes on index
|
| 36 |
+
data = pd.concat(dataframes, axis=1)
|
| 37 |
+
|
| 38 |
+
# Transpose the dataframe to swap rows and columns
|
| 39 |
+
data = data.transpose()
|
| 40 |
+
|
| 41 |
+
# Select only columns 'moral_scenarios' and 'moral_disputes'
|
| 42 |
+
data = data[['moral_scenarios', 'moral_disputes']]
|
| 43 |
+
|
| 44 |
+
return data
|
| 45 |
+
|
| 46 |
+
data_provider = MultiURLData("file_urls.txt")
|
| 47 |
|
| 48 |
block = gr.Blocks()
|
|
|
|
| 49 |
|
| 50 |
with block:
|
| 51 |
+
gr.Markdown("""Leaderboard""")
|
| 52 |
with gr.Tabs():
|
| 53 |
+
with gr.TabItem("Leaderboard"):
|
| 54 |
with gr.Row():
|
| 55 |
data = gr.outputs.Dataframe(type="pandas")
|
| 56 |
with gr.Row():
|
| 57 |
data_run = gr.Button("Refresh")
|
| 58 |
+
data_run.click(data_provider.fetch_data, inputs=None, outputs=data)
|
| 59 |
# running the function on page load in addition to when the button is clicked
|
| 60 |
+
block.load(data_provider.fetch_data, inputs=None, outputs=data)
|
| 61 |
|
| 62 |
block.launch()
|