Spaces:
Paused
Paused
feat: Updated record data format
Browse files
app.py
CHANGED
|
@@ -46,6 +46,7 @@ def new_comparison(dialog_dict: dict) -> Tuple[str, str, str, str, gr.Row, gr.Ro
|
|
| 46 |
|
| 47 |
def update_scores(score_a: Optional[int],
|
| 48 |
score_b: Optional[int],
|
|
|
|
| 49 |
m1: str,
|
| 50 |
m2: str,
|
| 51 |
d1: str,
|
|
@@ -62,12 +63,14 @@ def update_scores(score_a: Optional[int],
|
|
| 62 |
scores["A"] = score_a
|
| 63 |
if score_b is not None:
|
| 64 |
scores["B"] = score_b
|
|
|
|
|
|
|
| 65 |
|
| 66 |
# Save the data
|
| 67 |
-
if "A" in scores and "B" in scores:
|
| 68 |
# if not is_dev:
|
| 69 |
with open(result_file_path, "a") as f:
|
| 70 |
-
f.write(f"{scores['A']}\t{scores['B']}\t{m1}\t{m2}\n")
|
| 71 |
|
| 72 |
new_m1, new_d1, new_m2, new_d2 = sample_pair(dialog_dict)
|
| 73 |
return (
|
|
@@ -144,6 +147,8 @@ with gr.Blocks(title="1:1 Outpatient Model Simulation Arena", css=css) as demo:
|
|
| 144 |
gr.Markdown("# 🤖 Model Arena Evaluation")
|
| 145 |
gr.Markdown("### Compare two model simulations and choose the better one!")
|
| 146 |
gr.Markdown("### This scenario assumes that the patient called the hospital's administrative office for an outpatient inquiry.")
|
|
|
|
|
|
|
| 147 |
gr.Markdown("<br><br>")
|
| 148 |
gr.Markdown("---")
|
| 149 |
|
|
@@ -189,28 +194,28 @@ with gr.Blocks(title="1:1 Outpatient Model Simulation Arena", css=css) as demo:
|
|
| 189 |
)
|
| 190 |
|
| 191 |
# First step: Arena, Choose the only one!
|
|
|
|
| 192 |
vote1.click(
|
| 193 |
-
fn=lambda:
|
| 194 |
-
inputs=[],
|
| 195 |
-
outputs=[scoreA_row, scoreB_row, vote1_row, vote2_row, msg],
|
| 196 |
)
|
| 197 |
vote2.click(
|
| 198 |
-
fn=lambda:
|
| 199 |
-
inputs=[],
|
| 200 |
-
outputs=[scoreA_row, scoreB_row, vote1_row, vote2_row, msg],
|
| 201 |
)
|
| 202 |
|
| 203 |
# Second step: Rate, Rate the each score!
|
| 204 |
-
score_state = gr.State({})
|
| 205 |
for btn in scoreA_buttons:
|
| 206 |
btn.click(
|
| 207 |
-
fn=lambda score, m1, m2, d1, d2, scores: update_scores(int(score), None, m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 208 |
inputs=[gr.State(btn.value), model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 209 |
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 210 |
)
|
| 211 |
for btn in scoreB_buttons:
|
| 212 |
btn.click(
|
| 213 |
-
fn=lambda score, m1, m2, d1, d2, scores: update_scores(None, int(score), m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 214 |
inputs=[gr.State(btn.value), model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 215 |
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 216 |
)
|
|
|
|
| 46 |
|
| 47 |
def update_scores(score_a: Optional[int],
|
| 48 |
score_b: Optional[int],
|
| 49 |
+
win: Optional[int],
|
| 50 |
m1: str,
|
| 51 |
m2: str,
|
| 52 |
d1: str,
|
|
|
|
| 63 |
scores["A"] = score_a
|
| 64 |
if score_b is not None:
|
| 65 |
scores["B"] = score_b
|
| 66 |
+
if win is not None:
|
| 67 |
+
scores["win"] = win
|
| 68 |
|
| 69 |
# Save the data
|
| 70 |
+
if "A" in scores and "B" in scores and "win" in scores:
|
| 71 |
# if not is_dev:
|
| 72 |
with open(result_file_path, "a") as f:
|
| 73 |
+
f.write(f"{scores['win']}\t{scores['A']}\t{scores['B']}\t{m1}\t{m2}\n")
|
| 74 |
|
| 75 |
new_m1, new_d1, new_m2, new_d2 = sample_pair(dialog_dict)
|
| 76 |
return (
|
|
|
|
| 147 |
gr.Markdown("# 🤖 Model Arena Evaluation")
|
| 148 |
gr.Markdown("### Compare two model simulations and choose the better one!")
|
| 149 |
gr.Markdown("### This scenario assumes that the patient called the hospital's administrative office for an outpatient inquiry.")
|
| 150 |
+
gr.Markdown("* First step: Arena! Choose the better one between the two simulations.")
|
| 151 |
+
gr.Markdown("* Second step: Rate the score! Rate both simulations on a scale of 1 to 5. If the two simulations are similar, you may give them the same score regardless of your first choice.")
|
| 152 |
gr.Markdown("<br><br>")
|
| 153 |
gr.Markdown("---")
|
| 154 |
|
|
|
|
| 194 |
)
|
| 195 |
|
| 196 |
# First step: Arena, Choose the only one!
|
| 197 |
+
score_state = gr.State({})
|
| 198 |
vote1.click(
|
| 199 |
+
fn=lambda m1, m2, d1, d2, scores: update_scores(None, None, 'A', m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 200 |
+
inputs=[model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 201 |
+
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 202 |
)
|
| 203 |
vote2.click(
|
| 204 |
+
fn=lambda m1, m2, d1, d2, scores: update_scores(None, None, 'B', m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 205 |
+
inputs=[model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 206 |
+
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 207 |
)
|
| 208 |
|
| 209 |
# Second step: Rate, Rate the each score!
|
|
|
|
| 210 |
for btn in scoreA_buttons:
|
| 211 |
btn.click(
|
| 212 |
+
fn=lambda score, m1, m2, d1, d2, scores: update_scores(int(score), None, None, m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 213 |
inputs=[gr.State(btn.value), model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 214 |
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 215 |
)
|
| 216 |
for btn in scoreB_buttons:
|
| 217 |
btn.click(
|
| 218 |
+
fn=lambda score, m1, m2, d1, d2, scores: update_scores(None, int(score), None, m1, m2, d1, d2, dialog_dict, scores, is_dev, result_save_path),
|
| 219 |
inputs=[gr.State(btn.value), model1_name, model2_name, dialog1_box, dialog2_box, score_state],
|
| 220 |
outputs=[model1_name, dialog1_box, model2_name, dialog2_box, arena_row, scoreA_row, scoreB_row, vote1_row, vote2_row, msg, score_state],
|
| 221 |
)
|