t0-0 commited on
Commit
7fd8d10
1 Parent(s): 6da486c

Change num_few_shots enum to handle int type

Browse files
Files changed (2) hide show
  1. app.py +6 -6
  2. src/display/utils.py +4 -9
app.py CHANGED
@@ -96,7 +96,7 @@ def filter_models(
96
  size_query: list[str],
97
  precision_query: list[str],
98
  add_special_tokens_query: list[str],
99
- num_few_shots_query: list[str],
100
  version_query: list[str],
101
  vllm_query: list[str],
102
  ) -> pd.DataFrame:
@@ -122,7 +122,7 @@ def filter_models(
122
  df = df[df["Add Special Tokens"].isin(add_special_tokens_query)]
123
 
124
  # Filter by number of few-shot examples
125
- df = df[df["Few-shot"].astype(str).isin(num_few_shots_query)]
126
 
127
  # Filter by evaluator version
128
  df = df[df["llm-jp-eval version"].isin(version_query)]
@@ -175,7 +175,7 @@ def update_table(
175
  precision_query: list[str],
176
  size_query: list[str],
177
  add_special_tokens_query: list[str],
178
- num_few_shots_query: list[str],
179
  version_query: list[str],
180
  vllm_query: list[str],
181
  query: str,
@@ -211,7 +211,7 @@ if len(leaderboard_df) > 0:
211
  list(NUMERIC_INTERVALS.keys()),
212
  [i.value.name for i in Precision],
213
  [i.value.name for i in AddSpecialTokens],
214
- [i.value.name for i in NumFewShots],
215
  [i.value.name for i in LLMJpEvalVersion],
216
  [i.value.name for i in VllmVersion],
217
  )
@@ -418,8 +418,8 @@ with gr.Blocks() as demo_leaderboard:
418
  )
419
  filter_columns_num_few_shots = gr.CheckboxGroup(
420
  label="Num Few Shots",
421
- choices=[i.value.name for i in NumFewShots],
422
- value=[i.value.name for i in NumFewShots],
423
  elem_id="filter-columns-num-few-shots",
424
  )
425
  filter_columns_version = gr.CheckboxGroup(
 
96
  size_query: list[str],
97
  precision_query: list[str],
98
  add_special_tokens_query: list[str],
99
+ num_few_shots_query: list[int],
100
  version_query: list[str],
101
  vllm_query: list[str],
102
  ) -> pd.DataFrame:
 
122
  df = df[df["Add Special Tokens"].isin(add_special_tokens_query)]
123
 
124
  # Filter by number of few-shot examples
125
+ df = df[df["Few-shot"].isin(num_few_shots_query)]
126
 
127
  # Filter by evaluator version
128
  df = df[df["llm-jp-eval version"].isin(version_query)]
 
175
  precision_query: list[str],
176
  size_query: list[str],
177
  add_special_tokens_query: list[str],
178
+ num_few_shots_query: list[int],
179
  version_query: list[str],
180
  vllm_query: list[str],
181
  query: str,
 
211
  list(NUMERIC_INTERVALS.keys()),
212
  [i.value.name for i in Precision],
213
  [i.value.name for i in AddSpecialTokens],
214
+ [i.value for i in NumFewShots],
215
  [i.value.name for i in LLMJpEvalVersion],
216
  [i.value.name for i in VllmVersion],
217
  )
 
418
  )
419
  filter_columns_num_few_shots = gr.CheckboxGroup(
420
  label="Num Few Shots",
421
+ choices=[i.value for i in NumFewShots],
422
+ value=[i.value for i in NumFewShots],
423
  elem_id="filter-columns-num-few-shots",
424
  )
425
  filter_columns_version = gr.CheckboxGroup(
src/display/utils.py CHANGED
@@ -147,18 +147,13 @@ class AddSpecialTokens(Enum):
147
 
148
 
149
  class NumFewShots(Enum):
150
- shots_0 = ModelDetails("0")
151
- shots_4 = ModelDetails("4")
152
 
153
  @staticmethod
154
- def from_str(shots: str) -> "NumFewShots":
155
  try:
156
- int_shots = int(shots)
157
- if int_shots == 0:
158
- return NumFewShots.shots_0
159
- if int_shots == 4:
160
- return NumFewShots.shots_4
161
- raise ValueError
162
  except ValueError:
163
  raise ValueError(f"Unsupported number of shots: {shots}. Must be either 0 or 4")
164
 
 
147
 
148
 
149
  class NumFewShots(Enum):
150
+ shots_0 = 0
151
+ shots_4 = 4
152
 
153
  @staticmethod
154
+ def from_int(shots: int) -> "NumFewShots":
155
  try:
156
+ return NumFewShots(shots)
 
 
 
 
 
157
  except ValueError:
158
  raise ValueError(f"Unsupported number of shots: {shots}. Must be either 0 or 4")
159