Spaces:
Runtime error
Runtime error
Commit
β’
73a04d8
1
Parent(s):
da8ee60
fix
Browse files
app.py
CHANGED
@@ -7,9 +7,13 @@ import pandas as pd
|
|
7 |
import gradio as gr
|
8 |
import os
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# read in the data
|
15 |
open_llm_race_dataset = pd.read_csv(
|
@@ -39,10 +43,26 @@ open_llm_race_dataset["type"] = open_llm_race_dataset["model"].apply(
|
|
39 |
lambda x: MODEL_TYPES[x].name if x in MODEL_TYPES else ModelType.Unknown.name
|
40 |
)
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
# Demo interface
|
48 |
demo = gr.Blocks()
|
@@ -52,98 +72,12 @@ with demo:
|
|
52 |
|
53 |
with gr.Tabs():
|
54 |
with gr.TabItem(label="Pretrained Models"):
|
55 |
-
|
56 |
-
ax.set_xlim(0, 100)
|
57 |
-
pretrained_dataset = open_llm_race_dataset[
|
58 |
-
open_llm_race_dataset["type"] == ModelType.PT.name
|
59 |
-
]
|
60 |
-
pretrained_dataset = pretrained_dataset.pivot(
|
61 |
-
index="date", columns="model", values="score"
|
62 |
-
)
|
63 |
-
pretrained_dataset.fillna(0, inplace=True)
|
64 |
-
pretrained_fig = bcr.bar_chart_race(
|
65 |
-
pretrained_dataset,
|
66 |
-
n_bars=10,
|
67 |
-
fixed_max=True,
|
68 |
-
period_length=1000,
|
69 |
-
steps_per_period=20,
|
70 |
-
end_period_pause=100,
|
71 |
-
bar_texttemplate="{x:.2f}",
|
72 |
-
filter_column_colors=True,
|
73 |
-
fig=pretrained_fig,
|
74 |
-
)
|
75 |
-
gr.HTML(pretrained_fig.data)
|
76 |
-
|
77 |
with gr.TabItem(label="Instructions Finetuend Models"):
|
78 |
-
|
79 |
-
ax.set_xlim(0, 100)
|
80 |
-
inst_finetuned_dataset = open_llm_race_dataset[
|
81 |
-
open_llm_race_dataset["type"] == ModelType.IFT.name
|
82 |
-
]
|
83 |
-
inst_finetuned_dataset = inst_finetuned_dataset.pivot(
|
84 |
-
index="date", columns="model", values="score"
|
85 |
-
)
|
86 |
-
inst_finetuned_dataset.fillna(0, inplace=True)
|
87 |
-
inst_finetuned_fig = bcr.bar_chart_race(
|
88 |
-
inst_finetuned_dataset,
|
89 |
-
n_bars=10,
|
90 |
-
fixed_max=True,
|
91 |
-
period_length=1000,
|
92 |
-
steps_per_period=20,
|
93 |
-
end_period_pause=100,
|
94 |
-
bar_texttemplate="{x:.2f}",
|
95 |
-
filter_column_colors=True,
|
96 |
-
fig=inst_finetuned_fig,
|
97 |
-
)
|
98 |
-
gr.HTML(inst_finetuned_fig.data)
|
99 |
|
100 |
with gr.TabItem(label="RLHF Models"):
|
101 |
-
|
102 |
-
ax.set_xlim(0, 100)
|
103 |
-
rl_dataset = open_llm_race_dataset[
|
104 |
-
open_llm_race_dataset["type"] == ModelType.IFT.name
|
105 |
-
]
|
106 |
-
rl_dataset = rl_dataset.pivot(index="date", columns="model", values="score")
|
107 |
-
rl_dataset.fillna(0, inplace=True)
|
108 |
-
rl_fig = bcr.bar_chart_race(
|
109 |
-
rl_dataset,
|
110 |
-
n_bars=10,
|
111 |
-
fixed_max=True,
|
112 |
-
period_length=1000,
|
113 |
-
steps_per_period=20,
|
114 |
-
end_period_pause=100,
|
115 |
-
bar_texttemplate="{x:.2f}",
|
116 |
-
filter_column_colors=True,
|
117 |
-
fig=rl_fig,
|
118 |
-
)
|
119 |
-
gr.HTML(rl_fig.data)
|
120 |
-
|
121 |
-
# with gr.TabItem(label="Finetuned Models"):
|
122 |
-
# finetuned_dataset = open_llm_race_dataset[
|
123 |
-
# open_llm_race_dataset["type"] == ModelType.FT.name
|
124 |
-
# ]
|
125 |
-
# finetuned_dataset = finetuned_dataset.pivot(
|
126 |
-
# index="date", columns="model", values="score"
|
127 |
-
# )
|
128 |
-
# finetuned_fig = bcr.bar_chart_race(
|
129 |
-
# finetuned_dataset,
|
130 |
-
# n_bars=10,
|
131 |
-
# fixed_max=True,
|
132 |
-
# period_length=1000,
|
133 |
-
# steps_per_period=20,
|
134 |
-
# end_period_pause=100,
|
135 |
-
# bar_texttemplate="{x:.2f}",
|
136 |
-
# filter_column_colors=True,
|
137 |
-
# fig=pretrained_fig,
|
138 |
-
# )
|
139 |
-
# gr.HTML(finetuned_fig.data)
|
140 |
-
|
141 |
-
|
142 |
-
def restart_space():
|
143 |
-
HfApi().restart_space(
|
144 |
-
repo_id="https://huggingface.co/spaces/IlyasMoutawwakil/llm-bar-race",
|
145 |
-
token=os.environ.get("HF_TOKEN", None),
|
146 |
-
)
|
147 |
|
148 |
|
149 |
# Restart space every hour
|
@@ -154,6 +88,4 @@ scheduler.add_job(
|
|
154 |
seconds=3600,
|
155 |
)
|
156 |
scheduler.start()
|
157 |
-
|
158 |
-
|
159 |
demo.queue(concurrency_count=10).launch()
|
|
|
7 |
import gradio as gr
|
8 |
import os
|
9 |
|
10 |
+
|
11 |
+
def restart_space():
|
12 |
+
HfApi().restart_space(
|
13 |
+
repo_id="https://huggingface.co/spaces/IlyasMoutawwakil/llm-bar-race",
|
14 |
+
token=os.environ.get("HF_TOKEN", None),
|
15 |
+
)
|
16 |
+
|
17 |
|
18 |
# read in the data
|
19 |
open_llm_race_dataset = pd.read_csv(
|
|
|
43 |
lambda x: MODEL_TYPES[x].name if x in MODEL_TYPES else ModelType.Unknown.name
|
44 |
)
|
45 |
|
46 |
+
|
47 |
+
def get_bar_chart(model_type: str):
|
48 |
+
fig, ax = plt.subplots(figsize=(12, 6))
|
49 |
+
ax.set_xlim(0, 100)
|
50 |
+
subset = open_llm_race_dataset[open_llm_race_dataset["type"] == model_type]
|
51 |
+
subset = subset.pivot(index="date", columns="model", values="score")
|
52 |
+
subset.fillna(0, inplace=True)
|
53 |
+
fig = bcr.bar_chart_race(
|
54 |
+
subset,
|
55 |
+
n_bars=10,
|
56 |
+
fixed_max=True,
|
57 |
+
period_length=1000,
|
58 |
+
steps_per_period=20,
|
59 |
+
end_period_pause=100,
|
60 |
+
bar_texttemplate="{x:.2f}",
|
61 |
+
filter_column_colors=True,
|
62 |
+
fig=fig,
|
63 |
+
)
|
64 |
+
gr.HTML(fig.data)
|
65 |
+
|
66 |
|
67 |
# Demo interface
|
68 |
demo = gr.Blocks()
|
|
|
72 |
|
73 |
with gr.Tabs():
|
74 |
with gr.TabItem(label="Pretrained Models"):
|
75 |
+
get_bar_chart(ModelType.PT.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
with gr.TabItem(label="Instructions Finetuend Models"):
|
77 |
+
get_bar_chart(ModelType.IFT.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
|
79 |
with gr.TabItem(label="RLHF Models"):
|
80 |
+
get_bar_chart(ModelType.RL.name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
|
83 |
# Restart space every hour
|
|
|
88 |
seconds=3600,
|
89 |
)
|
90 |
scheduler.start()
|
|
|
|
|
91 |
demo.queue(concurrency_count=10).launch()
|