Spaces:
Sleeping
Sleeping
restricting the number of rows to display on app
Browse files- src/display.py +21 -13
- src/load_data.py +29 -1
src/display.py
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
#from st_aggrid import GridOptionsBuilder, AgGrid
|
5 |
from st_aggrid import GridOptionsBuilder, AgGrid
|
6 |
import streamlit as st
|
7 |
-
from .load_data import load_dataframe, sort_by
|
8 |
from .plot import plot_radar_chart_name, plot_radar_chart_rows
|
9 |
|
10 |
|
@@ -12,16 +12,16 @@ def display_app():
|
|
12 |
st.markdown("# Open LLM Leaderboard Viz")
|
13 |
st.markdown("This is a visualization of the results in [open-llm-leaderboard/results](https://huggingface.co/datasets/open-llm-leaderboard/results)")
|
14 |
st.markdown("To select a model, click on the checkbox beside its name.")
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
#container = st.container(height = 150)
|
19 |
|
20 |
dataframe = load_dataframe()
|
21 |
|
22 |
-
sort_selection = st.selectbox(label = "Sort by:", options = list(dataframe.columns))
|
|
|
23 |
ascending = True
|
24 |
-
|
25 |
if sort_selection is None:
|
26 |
sort_selection = "model_name"
|
27 |
ascending = True
|
@@ -29,16 +29,26 @@ def display_app():
|
|
29 |
ascending = True
|
30 |
else:
|
31 |
ascending = False
|
|
|
|
|
32 |
name = st.text_input(label = ":mag: Search by name")
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
|
|
|
|
37 |
else:
|
38 |
dataframe = load_dataframe()
|
39 |
|
40 |
dataframe = sort_by(dataframe=dataframe, column_name=sort_selection, ascending= ascending)
|
41 |
dataframe_display = dataframe.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]].astype(float)
|
43 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] *100
|
44 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]].round(2)
|
@@ -52,8 +62,6 @@ def display_app():
|
|
52 |
column1,col3, column2 = st.columns([0.26, 0.05, 0.69], gap = "small")
|
53 |
|
54 |
with column1:
|
55 |
-
#with container:
|
56 |
-
#st.dataframe(dataframe_display)
|
57 |
grid_response = AgGrid(
|
58 |
dataframe_display,
|
59 |
gridOptions=gridOptions,
|
|
|
4 |
#from st_aggrid import GridOptionsBuilder, AgGrid
|
5 |
from st_aggrid import GridOptionsBuilder, AgGrid
|
6 |
import streamlit as st
|
7 |
+
from .load_data import load_dataframe, sort_by, show_dataframe_top, search_by_name
|
8 |
from .plot import plot_radar_chart_name, plot_radar_chart_rows
|
9 |
|
10 |
|
|
|
12 |
st.markdown("# Open LLM Leaderboard Viz")
|
13 |
st.markdown("This is a visualization of the results in [open-llm-leaderboard/results](https://huggingface.co/datasets/open-llm-leaderboard/results)")
|
14 |
st.markdown("To select a model, click on the checkbox beside its name.")
|
15 |
+
st.markdown("This displays the top 100 models by default, but you can change that using the number input below.")
|
16 |
+
st.markdown("By defalut as well, the maximum number of row you can display is 500, it is due to the problem with st__aggrid component loading.")
|
17 |
+
st.markdown("If your model doesn't show up, please search it by its name.")
|
|
|
18 |
|
19 |
dataframe = load_dataframe()
|
20 |
|
21 |
+
sort_selection = st.selectbox(label = "Sort by:", options = list(dataframe.columns), index = 7)
|
22 |
+
number_of_row = st.number_input("Number of top rows to display", min_value=100, max_value=500, value="min", step=100)
|
23 |
ascending = True
|
24 |
+
|
25 |
if sort_selection is None:
|
26 |
sort_selection = "model_name"
|
27 |
ascending = True
|
|
|
29 |
ascending = True
|
30 |
else:
|
31 |
ascending = False
|
32 |
+
|
33 |
+
|
34 |
name = st.text_input(label = ":mag: Search by name")
|
35 |
+
len_name_input = len(name)
|
36 |
+
if len_name_input > 0:
|
37 |
+
dataframe_by_search = search_by_name(name)
|
38 |
+
if len(dataframe_by_search) > 0:
|
39 |
+
#st.write("number of model name with name", len(dataframe_by_search))
|
40 |
+
dataframe = dataframe_by_search
|
41 |
else:
|
42 |
dataframe = load_dataframe()
|
43 |
|
44 |
dataframe = sort_by(dataframe=dataframe, column_name=sort_selection, ascending= ascending)
|
45 |
dataframe_display = dataframe.copy()
|
46 |
+
|
47 |
+
if len_name_input == 0:
|
48 |
+
# Show every only top n row
|
49 |
+
dataframe_display = show_dataframe_top(number_of_row,dataframe_display)
|
50 |
+
|
51 |
+
|
52 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]].astype(float)
|
53 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] *100
|
54 |
dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]] = dataframe_display[["ARC", "HellaSwag", "TruthfulQA", "Winogrande", "GSM8K" ,"MMLU", "Average"]].round(2)
|
|
|
62 |
column1,col3, column2 = st.columns([0.26, 0.05, 0.69], gap = "small")
|
63 |
|
64 |
with column1:
|
|
|
|
|
65 |
grid_response = AgGrid(
|
66 |
dataframe_display,
|
67 |
gridOptions=gridOptions,
|
src/load_data.py
CHANGED
@@ -13,6 +13,19 @@ def load_dataframe() -> pd.DataFrame:
|
|
13 |
dataframe = dataframe.drop(columns = "Unnamed: 0")
|
14 |
return dataframe
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
@st.cache_data
|
17 |
def sort_by(dataframe: pd.DataFrame, column_name: str, ascending:bool = False) -> pd.DataFrame:
|
18 |
"""
|
@@ -26,4 +39,19 @@ def sort_by(dataframe: pd.DataFrame, column_name: str, ascending:bool = False) -
|
|
26 |
Returns:
|
27 |
a sorted dataframe
|
28 |
"""
|
29 |
-
return dataframe.sort_values(by = column_name, ascending = ascending )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
dataframe = dataframe.drop(columns = "Unnamed: 0")
|
14 |
return dataframe
|
15 |
|
16 |
+
@st.cache_data
|
17 |
+
def show_dataframe_top(n:int , dataframe: pd.DataFrame) -> pd.DataFrame:
|
18 |
+
"""
|
19 |
+
read only the n-th first row
|
20 |
+
Arguments
|
21 |
+
-n: an integer telling the number of row
|
22 |
+
-dataframe: the dataframe to slice
|
23 |
+
Returns
|
24 |
+
dataframe: a pd.DataFrame of the average scores of the LLMs on each task
|
25 |
+
"""
|
26 |
+
|
27 |
+
return dataframe.head(n)
|
28 |
+
|
29 |
@st.cache_data
|
30 |
def sort_by(dataframe: pd.DataFrame, column_name: str, ascending:bool = False) -> pd.DataFrame:
|
31 |
"""
|
|
|
39 |
Returns:
|
40 |
a sorted dataframe
|
41 |
"""
|
42 |
+
return dataframe.sort_values(by = column_name, ascending = ascending )
|
43 |
+
|
44 |
+
@st.cache_data
|
45 |
+
def search_by_name(name: str) -> pd.DataFrame:
|
46 |
+
"""
|
47 |
+
Search a model by its name
|
48 |
+
|
49 |
+
Arguments:
|
50 |
+
- name: the name of the model or part of it
|
51 |
+
|
52 |
+
Returns:
|
53 |
+
a pandas Dataframe of every row that contains name
|
54 |
+
"""
|
55 |
+
dataframe = load_dataframe()
|
56 |
+
indexes = dataframe["model_name"].str.contains(name)
|
57 |
+
return dataframe[indexes]
|