Spaces:
Runtime error
Runtime error
allow for ties or both being bad
Browse files
app.py
CHANGED
|
@@ -174,7 +174,7 @@ def chat(history1, history2, system_msg):
|
|
| 174 |
sleep(0.15)
|
| 175 |
|
| 176 |
|
| 177 |
-
def chosen_one(label,
|
| 178 |
# Generate a uuid for each submission
|
| 179 |
arena_battle_id = str(uuid.uuid4())
|
| 180 |
|
|
@@ -188,17 +188,19 @@ def chosen_one(label, choice0_history, choice1_history, system_msg, nudge_msg, r
|
|
| 188 |
'timestamp': timestamp,
|
| 189 |
'system_msg': system_msg,
|
| 190 |
'nudge_prefix': nudge_msg,
|
| 191 |
-
'
|
| 192 |
-
'choice0': choice0_history,
|
| 193 |
-
'choice1_name': state["models"][1],
|
| 194 |
'choice1': choice1_history,
|
|
|
|
|
|
|
| 195 |
'label': label,
|
| 196 |
'rlhf_persona': rlhf_persona,
|
| 197 |
}
|
| 198 |
)
|
| 199 |
|
| 200 |
-
chosen_one_first = functools.partial(chosen_one,
|
| 201 |
-
chosen_one_second = functools.partial(chosen_one,
|
|
|
|
|
|
|
| 202 |
|
| 203 |
with gr.Blocks() as arena:
|
| 204 |
with gr.Row():
|
|
@@ -217,8 +219,10 @@ with gr.Blocks() as arena:
|
|
| 217 |
with gr.Column():
|
| 218 |
chatbot2 = gr.Chatbot()
|
| 219 |
with gr.Row():
|
| 220 |
-
choose1 = gr.Button(value="Prefer left", variant="secondary", visible=False).style(full_width=True)
|
| 221 |
-
choose2 = gr.Button(value="Prefer right", variant="secondary", visible=False).style(full_width=True)
|
|
|
|
|
|
|
| 222 |
with gr.Row():
|
| 223 |
reveal1 = gr.Textbox(label="Model Name", value="", interactive=False, visible=False).style(full_width=True)
|
| 224 |
reveal2 = gr.Textbox(label="Model Name", value="", interactive=False, visible=False).style(full_width=True)
|
|
@@ -281,34 +285,66 @@ with gr.Blocks() as arena:
|
|
| 281 |
fn=chosen_one_first, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 282 |
).then(
|
| 283 |
lambda *args: (
|
|
|
|
|
|
|
| 284 |
gr.update(visible=False),
|
| 285 |
gr.update(visible=False),
|
| 286 |
gr.update(visible=True),
|
| 287 |
gr.update(visible=True),
|
| 288 |
gr.update(visible=True),
|
| 289 |
),
|
| 290 |
-
inputs=[], outputs=[choose1, choose2, dismiss_reveal, reveal1, reveal2], queue=True
|
| 291 |
)
|
| 292 |
|
| 293 |
choose2_click_event = choose2.click(
|
| 294 |
fn=chosen_one_second, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 295 |
).then(
|
| 296 |
lambda *args: (
|
|
|
|
|
|
|
| 297 |
gr.update(visible=False),
|
| 298 |
gr.update(visible=False),
|
| 299 |
gr.update(visible=True),
|
| 300 |
gr.update(visible=True),
|
| 301 |
gr.update(visible=True),
|
| 302 |
),
|
| 303 |
-
inputs=[], outputs=[choose1, choose2, dismiss_reveal, reveal1, reveal2], queue=True
|
| 304 |
)
|
| 305 |
|
| 306 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 307 |
lambda *args: (
|
| 308 |
-
gr.update(visible=True, interactive=True),
|
| 309 |
gr.update(visible=False),
|
| 310 |
gr.update(visible=False),
|
| 311 |
gr.update(visible=False),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 312 |
gr.update(visible=True),
|
| 313 |
gr.update(visible=True),
|
| 314 |
gr.update(visible=False),
|
|
@@ -316,7 +352,7 @@ with gr.Blocks() as arena:
|
|
| 316 |
None,
|
| 317 |
None,
|
| 318 |
),
|
| 319 |
-
inputs=[], outputs=[message,
|
| 320 |
)
|
| 321 |
|
| 322 |
arena.queue(concurrency_count=5, max_size=16).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 174 |
sleep(0.15)
|
| 175 |
|
| 176 |
|
| 177 |
+
def chosen_one(label, choice1_history, choice2_history, system_msg, nudge_msg, rlhf_persona, state):
|
| 178 |
# Generate a uuid for each submission
|
| 179 |
arena_battle_id = str(uuid.uuid4())
|
| 180 |
|
|
|
|
| 188 |
'timestamp': timestamp,
|
| 189 |
'system_msg': system_msg,
|
| 190 |
'nudge_prefix': nudge_msg,
|
| 191 |
+
'choice1_name': state["models"][0],
|
|
|
|
|
|
|
| 192 |
'choice1': choice1_history,
|
| 193 |
+
'choice2_name': state["models"][1],
|
| 194 |
+
'choice2': choice2_history,
|
| 195 |
'label': label,
|
| 196 |
'rlhf_persona': rlhf_persona,
|
| 197 |
}
|
| 198 |
)
|
| 199 |
|
| 200 |
+
chosen_one_first = functools.partial(chosen_one, 1)
|
| 201 |
+
chosen_one_second = functools.partial(chosen_one, 2)
|
| 202 |
+
chosen_one_tie = functools.partial(chosen_one, 0)
|
| 203 |
+
chosen_one_suck = functools.partial(chosen_one, 1)
|
| 204 |
|
| 205 |
with gr.Blocks() as arena:
|
| 206 |
with gr.Row():
|
|
|
|
| 219 |
with gr.Column():
|
| 220 |
chatbot2 = gr.Chatbot()
|
| 221 |
with gr.Row():
|
| 222 |
+
choose1 = gr.Button(value="π Prefer left", variant="secondary", visible=False).style(full_width=True)
|
| 223 |
+
choose2 = gr.Button(value="π Prefer right", variant="secondary", visible=False).style(full_width=True)
|
| 224 |
+
choose3 = gr.Button(value="π€ Tie", variant="secondary", visible=False).style(full_width=True)
|
| 225 |
+
choose4 = gr.Button(value="π Both are bad", variant="secondary", visible=False).style(full_width=True)
|
| 226 |
with gr.Row():
|
| 227 |
reveal1 = gr.Textbox(label="Model Name", value="", interactive=False, visible=False).style(full_width=True)
|
| 228 |
reveal2 = gr.Textbox(label="Model Name", value="", interactive=False, visible=False).style(full_width=True)
|
|
|
|
| 285 |
fn=chosen_one_first, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 286 |
).then(
|
| 287 |
lambda *args: (
|
| 288 |
+
gr.update(visible=False),
|
| 289 |
+
gr.update(visible=False),
|
| 290 |
gr.update(visible=False),
|
| 291 |
gr.update(visible=False),
|
| 292 |
gr.update(visible=True),
|
| 293 |
gr.update(visible=True),
|
| 294 |
gr.update(visible=True),
|
| 295 |
),
|
| 296 |
+
inputs=[], outputs=[choose1, choose2, choose3, choose4, dismiss_reveal, reveal1, reveal2], queue=True
|
| 297 |
)
|
| 298 |
|
| 299 |
choose2_click_event = choose2.click(
|
| 300 |
fn=chosen_one_second, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 301 |
).then(
|
| 302 |
lambda *args: (
|
| 303 |
+
gr.update(visible=False),
|
| 304 |
+
gr.update(visible=False),
|
| 305 |
gr.update(visible=False),
|
| 306 |
gr.update(visible=False),
|
| 307 |
gr.update(visible=True),
|
| 308 |
gr.update(visible=True),
|
| 309 |
gr.update(visible=True),
|
| 310 |
),
|
| 311 |
+
inputs=[], outputs=[choose1, choose2, choose3, choose4, dismiss_reveal, reveal1, reveal2], queue=True
|
| 312 |
)
|
| 313 |
|
| 314 |
+
choose3_click_event = choose3.click(
|
| 315 |
+
fn=chosen_one_tie, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 316 |
+
).then(
|
| 317 |
+
lambda *args: (
|
| 318 |
+
gr.update(visible=False),
|
| 319 |
+
gr.update(visible=False),
|
| 320 |
+
gr.update(visible=False),
|
| 321 |
+
gr.update(visible=False),
|
| 322 |
+
gr.update(visible=True),
|
| 323 |
+
gr.update(visible=True),
|
| 324 |
+
gr.update(visible=True),
|
| 325 |
+
),
|
| 326 |
+
inputs=[], outputs=[choose1, choose2, choose3, choose4, dismiss_reveal, reveal1, reveal2], queue=True
|
| 327 |
+
)
|
| 328 |
+
|
| 329 |
+
choose4_click_event = choose4.click(
|
| 330 |
+
fn=chosen_one_suck, inputs=[chatbot1, chatbot2, system_msg, nudge_msg, rlhf_persona, state], outputs=[], queue=True
|
| 331 |
+
).then(
|
| 332 |
lambda *args: (
|
|
|
|
| 333 |
gr.update(visible=False),
|
| 334 |
gr.update(visible=False),
|
| 335 |
gr.update(visible=False),
|
| 336 |
+
gr.update(visible=False),
|
| 337 |
+
gr.update(visible=True),
|
| 338 |
+
gr.update(visible=True),
|
| 339 |
+
gr.update(visible=True),
|
| 340 |
+
),
|
| 341 |
+
inputs=[], outputs=[choose1, choose2, choose3, choose4, dismiss_reveal, reveal1, reveal2], queue=True
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
dismiss_click_event = dismiss_reveal.click(
|
| 345 |
+
lambda *args: (
|
| 346 |
+
gr.update(visible=True, interactive=True),
|
| 347 |
+
gr.update(visible=False),
|
| 348 |
gr.update(visible=True),
|
| 349 |
gr.update(visible=True),
|
| 350 |
gr.update(visible=False),
|
|
|
|
| 352 |
None,
|
| 353 |
None,
|
| 354 |
),
|
| 355 |
+
inputs=[], outputs=[message, dismiss_reveal, clear, submit, reveal1, reveal2, chatbot1, chatbot2], queue=True
|
| 356 |
)
|
| 357 |
|
| 358 |
arena.queue(concurrency_count=5, max_size=16).launch(debug=True, server_name="0.0.0.0", server_port=7860)
|