Spaces:
Running
Running
sort the values
Browse files- app.py +11 -4
- src/display/formatting.py +1 -1
app.py
CHANGED
@@ -90,6 +90,7 @@ grouped_dfs = get_grouped_dfs()
|
|
90 |
domain_df, freq_df, term_length_df, variate_type_df, overall_df = grouped_dfs['domain'], grouped_dfs['frequency'], grouped_dfs['term_length'], grouped_dfs['univariate'], grouped_dfs['overall']
|
91 |
overall_df = rename_metrics(overall_df)
|
92 |
overall_df = format_df(overall_df)
|
|
|
93 |
domain_df = pivot_existed_df(domain_df, tab_name='domain')
|
94 |
print(f'Domain dataframe is {domain_df}')
|
95 |
freq_df = pivot_existed_df(freq_df, tab_name='frequency')
|
@@ -106,7 +107,7 @@ model_info_df = get_model_info_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH)
|
|
106 |
# ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
107 |
|
108 |
|
109 |
-
def init_leaderboard(ori_dataframe, model_info_df):
|
110 |
if ori_dataframe is None or ori_dataframe.empty:
|
111 |
raise ValueError("Leaderboard DataFrame is empty or None.")
|
112 |
model_info_col_list = [c.name for c in fields(ModelInfoColumn) if c.displayed_by_default if c.name not in ['#Params (B)', 'available_on_hub', 'hub', 'Model sha','Hub License']]
|
@@ -119,14 +120,19 @@ def init_leaderboard(ori_dataframe, model_info_df):
|
|
119 |
new_cols = ['T'] + [col for col in merged_df.columns if col != 'T']
|
120 |
merged_df = merged_df[new_cols]
|
121 |
print('Merged df: ', merged_df)
|
|
|
|
|
|
|
|
|
|
|
122 |
# get the data type
|
123 |
datatype_list = [col2type_dict[col] if col in col2type_dict else 'number' for col in merged_df.columns]
|
124 |
-
|
125 |
# print('merged_df.column: ', merged_df.columns)
|
126 |
# ipdb.set_trace()
|
127 |
return Leaderboard(
|
128 |
value=merged_df,
|
129 |
-
datatype=
|
130 |
select_columns=SelectColumns(
|
131 |
default_selection=default_selection_list,
|
132 |
# default_selection=[c.name for c in fields(ModelInfoColumn) if
|
@@ -158,6 +164,7 @@ def init_leaderboard(ori_dataframe, model_info_df):
|
|
158 |
ColumnFilter(ModelInfoColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
159 |
],
|
160 |
# bool_checkboxgroup_label="",
|
|
|
161 |
interactive=False,
|
162 |
)
|
163 |
|
@@ -169,7 +176,7 @@ with demo:
|
|
169 |
|
170 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
171 |
with gr.TabItem('π
Overall', elem_id="llm-benchmark-tab-table", id=5):
|
172 |
-
leaderboard = init_leaderboard(overall_df, model_info_df)
|
173 |
print(f'FINAL Overall LEADERBOARD {overall_df}')
|
174 |
with gr.TabItem("π
By Domain", elem_id="llm-benchmark-tab-table", id=0):
|
175 |
leaderboard = init_leaderboard(domain_df, model_info_df)
|
|
|
90 |
domain_df, freq_df, term_length_df, variate_type_df, overall_df = grouped_dfs['domain'], grouped_dfs['frequency'], grouped_dfs['term_length'], grouped_dfs['univariate'], grouped_dfs['overall']
|
91 |
overall_df = rename_metrics(overall_df)
|
92 |
overall_df = format_df(overall_df)
|
93 |
+
overall_df = overall_df.sort_values(by=['Rank'])
|
94 |
domain_df = pivot_existed_df(domain_df, tab_name='domain')
|
95 |
print(f'Domain dataframe is {domain_df}')
|
96 |
freq_df = pivot_existed_df(freq_df, tab_name='frequency')
|
|
|
107 |
# ) = get_evaluation_queue_df(EVAL_REQUESTS_PATH, EVAL_COLS)
|
108 |
|
109 |
|
110 |
+
def init_leaderboard(ori_dataframe, model_info_df, sort_val: str|None = None):
|
111 |
if ori_dataframe is None or ori_dataframe.empty:
|
112 |
raise ValueError("Leaderboard DataFrame is empty or None.")
|
113 |
model_info_col_list = [c.name for c in fields(ModelInfoColumn) if c.displayed_by_default if c.name not in ['#Params (B)', 'available_on_hub', 'hub', 'Model sha','Hub License']]
|
|
|
120 |
new_cols = ['T'] + [col for col in merged_df.columns if col != 'T']
|
121 |
merged_df = merged_df[new_cols]
|
122 |
print('Merged df: ', merged_df)
|
123 |
+
if sort_val:
|
124 |
+
if sort_val in merged_df.columns:
|
125 |
+
merged_df = merged_df.sort_values(by=[sort_val])
|
126 |
+
else:
|
127 |
+
print(f'Warning: cannot sort by {sort_val}')
|
128 |
# get the data type
|
129 |
datatype_list = [col2type_dict[col] if col in col2type_dict else 'number' for col in merged_df.columns]
|
130 |
+
print('datatype_list: ', datatype_list)
|
131 |
# print('merged_df.column: ', merged_df.columns)
|
132 |
# ipdb.set_trace()
|
133 |
return Leaderboard(
|
134 |
value=merged_df,
|
135 |
+
datatype=datatype_list,
|
136 |
select_columns=SelectColumns(
|
137 |
default_selection=default_selection_list,
|
138 |
# default_selection=[c.name for c in fields(ModelInfoColumn) if
|
|
|
164 |
ColumnFilter(ModelInfoColumn.model_type.name, type="checkboxgroup", label="Model types"),
|
165 |
],
|
166 |
# bool_checkboxgroup_label="",
|
167 |
+
column_widths=[40, 150] + [150 for _ in range(len(merged_df.columns)-2)],
|
168 |
interactive=False,
|
169 |
)
|
170 |
|
|
|
176 |
|
177 |
with gr.Tabs(elem_classes="tab-buttons") as tabs:
|
178 |
with gr.TabItem('π
Overall', elem_id="llm-benchmark-tab-table", id=5):
|
179 |
+
leaderboard = init_leaderboard(overall_df, model_info_df, sort_val='MAPE')
|
180 |
print(f'FINAL Overall LEADERBOARD {overall_df}')
|
181 |
with gr.TabItem("π
By Domain", elem_id="llm-benchmark-tab-table", id=0):
|
182 |
leaderboard = init_leaderboard(domain_df, model_info_df)
|
src/display/formatting.py
CHANGED
@@ -3,7 +3,7 @@ def model_hyperlink(link, model_name):
|
|
3 |
return model_name
|
4 |
# return f'<a target="_blank">{model_name}</a>'
|
5 |
# return f'<a target="_blank" href="{link}" rel="noopener noreferrer">{model_name}</a>'
|
6 |
-
return f'<a target="_blank" href="{link}">{model_name}</a>'
|
7 |
|
8 |
|
9 |
def make_clickable_model(model_name):
|
|
|
3 |
return model_name
|
4 |
# return f'<a target="_blank">{model_name}</a>'
|
5 |
# return f'<a target="_blank" href="{link}" rel="noopener noreferrer">{model_name}</a>'
|
6 |
+
return f'<a target="_blank" href="{link}" style="color: var(--link-text-color); text-decoration: underline;text-decoration-style: dotted;">{model_name}</a>'
|
7 |
|
8 |
|
9 |
def make_clickable_model(model_name):
|