Spaces:
Runtime error
Runtime error
Commit
β’
b27966a
1
Parent(s):
803d3a0
fix
Browse files
app.py
CHANGED
@@ -1,21 +1,26 @@
|
|
1 |
-
|
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",
|
@@ -32,9 +37,9 @@ open_llm_race_dataset = (
|
|
32 |
)
|
33 |
# filter
|
34 |
open_llm_race_dataset["date"] = open_llm_race_dataset["date"].dt.strftime("%Y-%m-%d")
|
35 |
-
open_llm_race_dataset = open_llm_race_dataset[
|
36 |
-
|
37 |
-
]
|
38 |
open_llm_race_dataset = open_llm_race_dataset[["date", "score", "model"]]
|
39 |
# drop nan values
|
40 |
open_llm_race_dataset.dropna(inplace=True)
|
@@ -53,7 +58,7 @@ def get_bar_chart(model_type: str, top_n: int = 10, title: str = ""):
|
|
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,
|
@@ -84,8 +89,9 @@ with demo:
|
|
84 |
with gr.TabItem(label="Instructions Finetuned Models"):
|
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,
|
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()
|
|
|
1 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
2 |
from model_types import MODEL_TYPES, ModelType
|
3 |
+
from huggingface_hub import HfApi
|
|
|
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 os
|
9 |
|
|
|
10 |
|
11 |
+
def restart_space():
|
12 |
+
HfApi(token=os.environ.get("HF_TOKEN", None)).restart_space(
|
13 |
+
repo_id="IlyasMoutawwakil/llm-bar-race",
|
14 |
+
token=os.environ.get("HF_TOKEN", None),
|
15 |
+
)
|
16 |
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
scheduler = BackgroundScheduler()
|
19 |
+
scheduler.add_job(
|
20 |
+
func=restart_space,
|
21 |
+
trigger="interval",
|
22 |
+
seconds=60 * 60 * 6,
|
23 |
+
)
|
24 |
|
25 |
open_llm_race_dataset = pd.read_parquet(
|
26 |
"https://huggingface.co/datasets/IlyasMoutawwakil/llm-race-dataset/resolve/main/llm-race-dataset.parquet",
|
|
|
37 |
)
|
38 |
# filter
|
39 |
open_llm_race_dataset["date"] = open_llm_race_dataset["date"].dt.strftime("%Y-%m-%d")
|
40 |
+
# open_llm_race_dataset = open_llm_race_dataset[
|
41 |
+
# open_llm_race_dataset["date"] >= "2023-07-10"
|
42 |
+
# ]
|
43 |
open_llm_race_dataset = open_llm_race_dataset[["date", "score", "model"]]
|
44 |
# drop nan values
|
45 |
open_llm_race_dataset.dropna(inplace=True)
|
|
|
58 |
|
59 |
subset = open_llm_race_dataset[open_llm_race_dataset["type"] == model_type]
|
60 |
subset = subset.pivot(index="date", columns="model", values="score")
|
61 |
+
# subset.fillna(0, inplace=True)
|
62 |
fig = bcr.bar_chart_race(
|
63 |
subset,
|
64 |
fig=fig,
|
|
|
89 |
with gr.TabItem(label="Instructions Finetuned Models"):
|
90 |
get_bar_chart(ModelType.IFT.name, title="Instructions Finetuned Models")
|
91 |
with gr.TabItem(label="RLHF Models"):
|
92 |
+
get_bar_chart(ModelType.RL.name, title="RLHF Models")
|
93 |
with gr.TabItem(label="Finetuned Models"):
|
94 |
get_bar_chart(ModelType.FT.name, title="Finetuned Models")
|
95 |
|
96 |
+
scheduler.start()
|
97 |
demo.queue(concurrency_count=10).launch()
|