montagovian commited on
Commit
8062deb
·
verified ·
1 Parent(s): e840a29

Restore meme outcome filters

Browse files
Files changed (2) hide show
  1. app.py +14 -10
  2. data.py +9 -17
app.py CHANGED
@@ -103,9 +103,9 @@ def _render(
103
 
104
 
105
  def apply_filters(
106
- search: str, model_id: str, result: str, hide_ground_truth: bool
107
  ) -> tuple[Any, ...]:
108
- ids = DATA.filtered_ids(search, model_id, result)
109
  return (ids, *_render(ids, 0, hide_ground_truth, model_id))
110
 
111
 
@@ -255,15 +255,15 @@ def build_app() -> gr.Blocks:
255
  min_width=210,
256
  scale=2,
257
  )
258
- result = gr.Dropdown(
259
  choices=[
260
- ("Any result", "all"),
261
- ("Consensus correct", "correct"),
262
- ("Consensus incorrect", "incorrect"),
263
- ("Judge disagreement", "disagreement"),
264
  ],
265
  value="all",
266
- label="Result",
267
  show_label=False,
268
  min_width=180,
269
  scale=2,
@@ -307,12 +307,16 @@ def build_app() -> gr.Blocks:
307
  predictions,
308
  ]
309
  filter_outputs = [ids_state, *render_outputs]
310
- filter_inputs = [search, model, result, hide_ground_truth]
311
 
312
  demo.load(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
313
  search.submit(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
314
  model.change(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
315
- result.change(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
 
 
 
 
316
  previous.click(
317
  lambda ids, idx, hidden, selected: step_item(
318
  ids, idx, -1, hidden, selected
 
103
 
104
 
105
  def apply_filters(
106
+ search: str, model_id: str, outcome: str, hide_ground_truth: bool
107
  ) -> tuple[Any, ...]:
108
+ ids = DATA.filtered_ids(search, model_id, outcome)
109
  return (ids, *_render(ids, 0, hide_ground_truth, model_id))
110
 
111
 
 
255
  min_width=210,
256
  scale=2,
257
  )
258
+ outcome = gr.Dropdown(
259
  choices=[
260
+ ("Any outcome", "all"),
261
+ ("All got it right", "all_correct"),
262
+ ("All got it wrong", "all_incorrect"),
263
+ ("Mixed", "mixed"),
264
  ],
265
  value="all",
266
+ label="Outcome",
267
  show_label=False,
268
  min_width=180,
269
  scale=2,
 
307
  predictions,
308
  ]
309
  filter_outputs = [ids_state, *render_outputs]
310
+ filter_inputs = [search, model, outcome, hide_ground_truth]
311
 
312
  demo.load(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
313
  search.submit(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
314
  model.change(apply_filters, inputs=filter_inputs, outputs=filter_outputs)
315
+ outcome.change(
316
+ apply_filters,
317
+ inputs=filter_inputs,
318
+ outputs=filter_outputs,
319
+ )
320
  previous.click(
321
  lambda ids, idx, hidden, selected: step_item(
322
  ids, idx, -1, hidden, selected
data.py CHANGED
@@ -108,7 +108,7 @@ class BenchmarkData:
108
  self,
109
  search: str = "",
110
  model_id: str = "all",
111
- result: str = "all",
112
  ) -> list[str]:
113
  needle = search.strip().casefold()
114
  matches: list[str] = []
@@ -127,24 +127,16 @@ class BenchmarkData:
127
  predictions = self.predictions(post_id, model_id)
128
  if model_id != "all" and not predictions:
129
  continue
130
- if result == "correct" and not any(
131
- row.get("consensus_verdict") == "correct" for row in predictions
132
- ):
 
 
 
133
  continue
134
- if result == "incorrect" and not any(
135
- row.get("consensus_verdict") == "incorrect" for row in predictions
136
- ):
137
  continue
138
- if result == "disagreement" and not any(
139
- len(
140
- {
141
- judgment.get("verdict")
142
- for judgment in self.judgments(int(row["prediction_id"]))
143
- }
144
- )
145
- > 1
146
- for row in predictions
147
- ):
148
  continue
149
  matches.append(post_id)
150
  return matches
 
108
  self,
109
  search: str = "",
110
  model_id: str = "all",
111
+ outcome: str = "all",
112
  ) -> list[str]:
113
  needle = search.strip().casefold()
114
  matches: list[str] = []
 
127
  predictions = self.predictions(post_id, model_id)
128
  if model_id != "all" and not predictions:
129
  continue
130
+ verdicts = {
131
+ row.get("consensus_verdict")
132
+ for row in predictions
133
+ if row.get("consensus_verdict") in {"correct", "incorrect"}
134
+ }
135
+ if outcome == "all_correct" and verdicts != {"correct"}:
136
  continue
137
+ if outcome == "all_incorrect" and verdicts != {"incorrect"}:
 
 
138
  continue
139
+ if outcome == "mixed" and verdicts != {"correct", "incorrect"}:
 
 
 
 
 
 
 
 
 
140
  continue
141
  matches.append(post_id)
142
  return matches