sh1gechan commited on
Commit
c163b21
1 Parent(s): bbdb195

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -18
app.py CHANGED
@@ -143,37 +143,43 @@ def filter_queries(query: str, filtered_df: pd.DataFrame):
143
  def filter_models(
144
  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
145
  ) -> pd.DataFrame:
146
- print(f"filter_models called with: type_query={type_query}, size_query={size_query}, precision_query={precision_query}, add_special_tokens_query={add_special_tokens_query}, num_few_shots_query={num_few_shots_query}")
147
  print(f"Initial df shape: {df.shape}")
148
  print(f"Initial df content:\n{df}")
149
 
150
  filtered_df = df
151
-
152
- # type_emoji = [t[0] for t in type_query]
153
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.model_type_symbol.name].isin(type_emoji)]
 
154
  print(f"After type filter: {filtered_df.shape}")
155
- print(f"After type filter content:\n{filtered_df}")
156
 
157
- # Precision filterをコメントアウト
158
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.precision.name].isin(precision_query + ["None"])]
159
  print(f"After precision filter: {filtered_df.shape}")
160
- print(f"After precision filter content:\n{filtered_df}")
161
 
162
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.add_special_tokens.name].isin(add_special_tokens_query)]
 
 
 
 
 
 
 
 
 
163
  print(f"After add_special_tokens filter: {filtered_df.shape}")
164
- print(f"After add_special_tokens filter content:\n{filtered_df}")
165
 
166
- # filtered_df = filtered_df[filtered_df[AutoEvalColumn.num_few_shots.name].isin(num_few_shots_query)]
 
167
  print(f"After num_few_shots filter: {filtered_df.shape}")
168
- print(f"After num_few_shots filter content:\n{filtered_df}")
169
 
170
- # numeric_interval = pd.IntervalIndex(sorted([NUMERIC_INTERVALS[s] for s in size_query]))
171
- # params_column = pd.to_numeric(filtered_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(f"After size filter content:\n{filtered_df}")
176
 
 
 
177
  return filtered_df
178
 
179
  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)
 
143
  def filter_models(
144
  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
145
  ) -> pd.DataFrame:
 
146
  print(f"Initial df shape: {df.shape}")
147
  print(f"Initial df content:\n{df}")
148
 
149
  filtered_df = df
150
+
151
+ # Model Type フィルタリング
152
+ type_emoji = [t.split()[0] for t in type_query]
153
+ filtered_df = filtered_df[filtered_df['T'].isin(type_emoji)]
154
  print(f"After type filter: {filtered_df.shape}")
 
155
 
156
+ # Precision フィルタリング
157
+ filtered_df = filtered_df[filtered_df['Precision'].isin(precision_query + ['Unknown', '?'])]
158
  print(f"After precision filter: {filtered_df.shape}")
 
159
 
160
+ # Model Size フィルタリング
161
+ if 'Unknown' in size_query:
162
+ size_mask = filtered_df['#Params (B)'].isna() | (filtered_df['#Params (B)'] == 0)
163
+ else:
164
+ size_mask = filtered_df['#Params (B)'].apply(lambda x: any(x in NUMERIC_INTERVALS[s] for s in size_query if s != 'Unknown'))
165
+ filtered_df = filtered_df[size_mask]
166
+ print(f"After size filter: {filtered_df.shape}")
167
+
168
+ # Add Special Tokens フィルタリング
169
+ filtered_df = filtered_df[filtered_df['Add Special Tokens'].isin(add_special_tokens_query + ['Unknown', '?'])]
170
  print(f"After add_special_tokens filter: {filtered_df.shape}")
 
171
 
172
+ # Num Few Shots フィルタリング
173
+ filtered_df = filtered_df[filtered_df['Few-shot'].astype(str).isin([str(x) for x in num_few_shots_query] + ['Unknown', '?'])]
174
  print(f"After num_few_shots filter: {filtered_df.shape}")
 
175
 
176
+ # Show deleted models フィルタリング
177
+ if not show_deleted:
178
+ filtered_df = filtered_df[filtered_df['Available on the hub'] == True]
179
+ print(f"After show_deleted filter: {filtered_df.shape}")
 
 
180
 
181
+ print("Filtered dataframe head:")
182
+ print(filtered_df.head())
183
  return filtered_df
184
 
185
  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)