Spaces:
Runtime error
Runtime error
Commit
β’
803d3a0
1
Parent(s):
356f27d
better dataset
Browse files- app.py +21 -31
- requirements.txt +0 -1
app.py
CHANGED
@@ -1,31 +1,28 @@
|
|
1 |
-
from apscheduler.schedulers.background import BackgroundScheduler
|
2 |
from model_types import MODEL_TYPES, ModelType
|
3 |
-
|
|
|
4 |
import matplotlib.pyplot as plt
|
5 |
import bar_chart_race as bcr
|
6 |
import pandas as pd
|
7 |
import gradio as gr
|
8 |
-
import requests
|
9 |
-
import os
|
10 |
|
|
|
11 |
|
12 |
-
def restart_space():
|
13 |
-
HfApi(token=os.environ.get("HF_TOKEN", None)).restart_space(
|
14 |
-
repo_id="IlyasMoutawwakil/llm-bar-race",
|
15 |
-
token=os.environ.get("HF_TOKEN", None),
|
16 |
-
)
|
17 |
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
-
if os.path.exists("open-llm-race-dataset.csv"):
|
20 |
-
open_llm_race_dataset = pd.read_csv("open-llm-race-dataset.csv")
|
21 |
-
else:
|
22 |
-
open_llm_race_dataset = pd.read_csv(
|
23 |
-
"https://huggingface.co/datasets/IlyasMoutawwakil/open-llm-race-dataset/resolve/main/open-llm-race-dataset.csv"
|
24 |
-
)
|
25 |
|
|
|
|
|
|
|
|
|
26 |
|
27 |
# resample for ever model to a daily frequency
|
28 |
-
open_llm_race_dataset["date"] = pd.to_datetime(open_llm_race_dataset["date"])
|
29 |
open_llm_race_dataset = (
|
30 |
open_llm_race_dataset.set_index("date", drop=True)
|
31 |
.groupby("model", as_index=False)
|
@@ -52,25 +49,25 @@ open_llm_race_dataset["type"] = open_llm_race_dataset["model"].apply(
|
|
52 |
def get_bar_chart(model_type: str, top_n: int = 10, title: str = ""):
|
53 |
fig, ax = plt.subplots(figsize=(12, 6))
|
54 |
ax.set_xlim(0, 100)
|
55 |
-
plt.subplots_adjust(left=0.
|
56 |
|
57 |
subset = open_llm_race_dataset[open_llm_race_dataset["type"] == model_type]
|
58 |
subset = subset.pivot(index="date", columns="model", values="score")
|
59 |
subset.fillna(0, inplace=True)
|
60 |
fig = bcr.bar_chart_race(
|
61 |
subset,
|
|
|
62 |
title=title,
|
63 |
n_bars=top_n,
|
64 |
fixed_max=True,
|
|
|
|
|
65 |
period_length=1000,
|
66 |
steps_per_period=20,
|
67 |
end_period_pause=100,
|
68 |
-
bar_texttemplate="{x:.2f}",
|
69 |
filter_column_colors=True,
|
70 |
-
|
71 |
-
|
72 |
-
bar_kwargs={"alpha": 0.2, "ec": "black", "lw": 3},
|
73 |
-
fig=fig,
|
74 |
)
|
75 |
return gr.HTML(fig)
|
76 |
|
@@ -88,14 +85,7 @@ with demo:
|
|
88 |
get_bar_chart(ModelType.IFT.name, title="Instructions Finetuned Models")
|
89 |
with gr.TabItem(label="RLHF Models"):
|
90 |
get_bar_chart(ModelType.RL.name, top_n=4, title="RLHF Models")
|
|
|
|
|
91 |
|
92 |
-
|
93 |
-
# Restart space every hour
|
94 |
-
scheduler = BackgroundScheduler()
|
95 |
-
scheduler.add_job(
|
96 |
-
func=restart_space,
|
97 |
-
trigger="interval",
|
98 |
-
seconds=3600,
|
99 |
-
)
|
100 |
-
scheduler.start()
|
101 |
demo.queue(concurrency_count=10).launch()
|
|
|
1 |
+
# from apscheduler.schedulers.background import BackgroundScheduler
|
2 |
from model_types import MODEL_TYPES, ModelType
|
3 |
+
|
4 |
+
# from huggingface_hub import HfApi
|
5 |
import matplotlib.pyplot as plt
|
6 |
import bar_chart_race as bcr
|
7 |
import pandas as pd
|
8 |
import gradio as gr
|
|
|
|
|
9 |
|
10 |
+
# import os
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
+
# def restart_space():
|
14 |
+
# HfApi(token=os.environ.get("HF_TOKEN", None)).restart_space(
|
15 |
+
# repo_id="IlyasMoutawwakil/llm-bar-race",
|
16 |
+
# token=os.environ.get("HF_TOKEN", None),
|
17 |
+
# )
|
18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
+
open_llm_race_dataset = pd.read_parquet(
|
21 |
+
"https://huggingface.co/datasets/IlyasMoutawwakil/llm-race-dataset/resolve/main/llm-race-dataset.parquet",
|
22 |
+
engine="pyarrow",
|
23 |
+
)
|
24 |
|
25 |
# resample for ever model to a daily frequency
|
|
|
26 |
open_llm_race_dataset = (
|
27 |
open_llm_race_dataset.set_index("date", drop=True)
|
28 |
.groupby("model", as_index=False)
|
|
|
49 |
def get_bar_chart(model_type: str, top_n: int = 10, title: str = ""):
|
50 |
fig, ax = plt.subplots(figsize=(12, 6))
|
51 |
ax.set_xlim(0, 100)
|
52 |
+
plt.subplots_adjust(left=0.30, right=0.98)
|
53 |
|
54 |
subset = open_llm_race_dataset[open_llm_race_dataset["type"] == model_type]
|
55 |
subset = subset.pivot(index="date", columns="model", values="score")
|
56 |
subset.fillna(0, inplace=True)
|
57 |
fig = bcr.bar_chart_race(
|
58 |
subset,
|
59 |
+
fig=fig,
|
60 |
title=title,
|
61 |
n_bars=top_n,
|
62 |
fixed_max=True,
|
63 |
+
bar_label_font=10,
|
64 |
+
tick_label_font=10,
|
65 |
period_length=1000,
|
66 |
steps_per_period=20,
|
67 |
end_period_pause=100,
|
|
|
68 |
filter_column_colors=True,
|
69 |
+
bar_texttemplate="{x:.2f}%",
|
70 |
+
bar_kwargs={"alpha": 0.5, "ec": "black", "lw": 2},
|
|
|
|
|
71 |
)
|
72 |
return gr.HTML(fig)
|
73 |
|
|
|
85 |
get_bar_chart(ModelType.IFT.name, title="Instructions Finetuned Models")
|
86 |
with gr.TabItem(label="RLHF Models"):
|
87 |
get_bar_chart(ModelType.RL.name, top_n=4, title="RLHF Models")
|
88 |
+
with gr.TabItem(label="Finetuned Models"):
|
89 |
+
get_bar_chart(ModelType.FT.name, title="Finetuned Models")
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
demo.queue(concurrency_count=10).launch()
|
requirements.txt
CHANGED
@@ -1,5 +1,4 @@
|
|
1 |
git+https://github.com/dexplo/bar_chart_race.git
|
2 |
huggingface_hub
|
3 |
-
APScheduler
|
4 |
pandas
|
5 |
tqdm
|
|
|
1 |
git+https://github.com/dexplo/bar_chart_race.git
|
2 |
huggingface_hub
|
|
|
3 |
pandas
|
4 |
tqdm
|