Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
@@ -55,9 +55,6 @@ except Exception:
|
|
55 |
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
56 |
original_df = LEADERBOARD_DF
|
57 |
leaderboard_df = original_df.copy()
|
58 |
-
print("Columns in COLS:", COLS)
|
59 |
-
print("Columns in leaderboard_df:", leaderboard_df.columns.tolist())
|
60 |
-
print("Data types:", leaderboard_df.dtypes.to_dict())
|
61 |
(
|
62 |
finished_eval_queue_df,
|
63 |
running_eval_queue_df,
|
@@ -132,20 +129,12 @@ def filter_queries(query: str, filtered_df: pd.DataFrame):
|
|
132 |
def filter_models(
|
133 |
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
|
134 |
) -> pd.DataFrame:
|
135 |
-
# filter_models関数の冒頭で
|
136 |
-
if 'T' in df.columns:
|
137 |
-
df = df.rename(columns={'T': 'Type_Symbol'})
|
138 |
-
elif 'Type_Symbol' not in df.columns:
|
139 |
-
df['Type_Symbol'] = '?'
|
140 |
-
|
141 |
# Show all models
|
142 |
if show_deleted:
|
143 |
filtered_df = df
|
144 |
else: # Show only still on the hub models
|
145 |
filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
|
146 |
|
147 |
-
print(f"After deletion filter: {filtered_df.shape}")
|
148 |
-
|
149 |
#if not show_merges:
|
150 |
# filtered_df = filtered_df[filtered_df[AutoEvalColumn.merged.name] == False]
|
151 |
|
@@ -153,36 +142,16 @@ def filter_models(
|
|
153 |
# filtered_df = filtered_df[filtered_df[AutoEvalColumn.flagged.name] == False]
|
154 |
|
155 |
type_emoji = [t[0] for t in type_query]
|
156 |
-
|
157 |
-
filtered_df = filtered_df[
|
158 |
-
|
159 |
-
|
160 |
-
filtered_df = filtered_df[filtered_df[AutoEvalColumn.precision.name].isin(precision_query + ['Unknown'])]
|
161 |
-
|
162 |
-
# add_special_tokensフィルタリングを条件付きで適用
|
163 |
-
filtered_df = filtered_df[filtered_df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query + ['Unknown'])]
|
164 |
-
|
165 |
-
# num_few_shotsフィルタリングを条件付きで適用
|
166 |
-
filtered_df = filtered_df[filtered_df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query + ['Unknown'])]
|
167 |
-
print(f"After num_few_shots filter: {filtered_df.shape}")
|
168 |
|
169 |
|
170 |
numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
171 |
params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
172 |
mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
173 |
filtered_df = filtered_df.loc[mask]
|
174 |
-
print(f"After size filter: {filtered_df.shape}")
|
175 |
-
print("Filtered dataframe head:")
|
176 |
-
print(filtered_df.head())
|
177 |
-
print("Column names:")
|
178 |
-
print(filtered_df.columns.tolist())
|
179 |
-
print("Column data types:")
|
180 |
-
print(filtered_df.dtypes)
|
181 |
-
filtered_df = filtered_df.rename(columns={'T': 'Type_Symbol'})
|
182 |
-
print("Final filtered dataframe columns:")
|
183 |
-
print(filtered_df.columns.tolist())
|
184 |
-
print("Final filtered dataframe sample:")
|
185 |
-
print(filtered_df.head().to_dict('records'))
|
186 |
return filtered_df
|
187 |
|
188 |
leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
|
@@ -268,13 +237,16 @@ with demo:
|
|
268 |
|
269 |
leaderboard_table = gr.components.Dataframe(
|
270 |
value=leaderboard_df[
|
271 |
-
[c for c in
|
|
|
|
|
272 |
],
|
273 |
-
headers=[c for c in
|
274 |
-
datatype=
|
275 |
elem_id="leaderboard-table",
|
276 |
interactive=False,
|
277 |
visible=True,
|
|
|
278 |
)
|
279 |
print(leaderboard_df.head()) # リーダーボードテーブルに渡される前のデータを確認
|
280 |
|
|
|
55 |
LEADERBOARD_DF = get_leaderboard_df(EVAL_RESULTS_PATH, EVAL_REQUESTS_PATH, COLS, BENCHMARK_COLS)
|
56 |
original_df = LEADERBOARD_DF
|
57 |
leaderboard_df = original_df.copy()
|
|
|
|
|
|
|
58 |
(
|
59 |
finished_eval_queue_df,
|
60 |
running_eval_queue_df,
|
|
|
129 |
def filter_models(
|
130 |
df: pd.DataFrame, type_query: list, size_query: list, precision_query: list, add_special_tokens_query: list, num_few_shots_query: list, show_deleted: bool, show_merges: bool, show_flagged: bool
|
131 |
) -> pd.DataFrame:
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
# Show all models
|
133 |
if show_deleted:
|
134 |
filtered_df = df
|
135 |
else: # Show only still on the hub models
|
136 |
filtered_df = df[df[AutoEvalColumn.still_on_hub.name] == True]
|
137 |
|
|
|
|
|
138 |
#if not show_merges:
|
139 |
# filtered_df = filtered_df[filtered_df[AutoEvalColumn.merged.name] == False]
|
140 |
|
|
|
142 |
# filtered_df = filtered_df[filtered_df[AutoEvalColumn.flagged.name] == False]
|
143 |
|
144 |
type_emoji = [t[0] for t in type_query]
|
145 |
+
filtered_df = filtered_df.loc[df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
|
146 |
+
filtered_df = filtered_df.loc[df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
|
147 |
+
filtered_df = filtered_df.loc[df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
|
148 |
+
filtered_df = filtered_df.loc[df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
|
150 |
|
151 |
numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
|
152 |
params_column = pd.to_numeric(df[AutoEvalColumn.params.name], errors="coerce")
|
153 |
mask = params_column.apply(lambda x: any(numeric_interval.contains(x)))
|
154 |
filtered_df = filtered_df.loc[mask]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
return filtered_df
|
156 |
|
157 |
leaderboard_df = filter_models(leaderboard_df, [t.to_str(" : ") for t in ModelType], list(NUMERIC_INTERVALS.keys()), [i.value.name for i in Precision], [i.value.name for i in AddSpecialTokens], [i.value.name for i in NumFewShots], False, False, False)
|
|
|
237 |
|
238 |
leaderboard_table = gr.components.Dataframe(
|
239 |
value=leaderboard_df[
|
240 |
+
[c.name for c in fields(AutoEvalColumn) if c.never_hidden]
|
241 |
+
+ shown_columns.value
|
242 |
+
# + [AutoEvalColumn.dummy.name]
|
243 |
],
|
244 |
+
headers=[c.name for c in fields(AutoEvalColumn) if c.never_hidden] + shown_columns.value,
|
245 |
+
datatype=TYPES,
|
246 |
elem_id="leaderboard-table",
|
247 |
interactive=False,
|
248 |
visible=True,
|
249 |
+
#column_widths=["2%", "33%"]
|
250 |
)
|
251 |
print(leaderboard_df.head()) # リーダーボードテーブルに渡される前のデータを確認
|
252 |
|