Spaces:
Sleeping
Sleeping
elibrowne
commited on
Commit
·
ec65889
1
Parent(s):
95f47b4
State?
Browse files
app.py
CHANGED
|
@@ -258,10 +258,10 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 258 |
eval_satisfied = gr.Slider(1, 5, step = 0.5, label = "User Satisfaction", value = 3)
|
| 259 |
btn_g = gr.Button("Next")
|
| 260 |
|
| 261 |
-
def next_p(e0, e1, e2, e3, cur_step, mode,
|
| 262 |
step = cur_step + 1
|
| 263 |
# Add user data to the current response
|
| 264 |
-
|
| 265 |
# Next item
|
| 266 |
if step >= len(current_question["top10_e5"]): # should always be 10 (DEBUG: >= to avoid out of bounds)
|
| 267 |
# Step 10: all sources
|
|
@@ -281,7 +281,7 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 281 |
eval_3: gr.Slider(value = 0),
|
| 282 |
step: step,
|
| 283 |
mode: 1,
|
| 284 |
-
current_response:
|
| 285 |
}
|
| 286 |
else:
|
| 287 |
return {
|
|
@@ -294,17 +294,17 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 294 |
eval_3: gr.Slider(value = 0),
|
| 295 |
step: step,
|
| 296 |
mode: 1,
|
| 297 |
-
current_response:
|
| 298 |
}
|
| 299 |
|
| 300 |
-
def next_g(e_h, e_s, cur_step, mode,
|
| 301 |
step = cur_step + 1
|
| 302 |
|
| 303 |
if step == 11:
|
| 304 |
# Step 11: guaranteed to be generation
|
| 305 |
# Add user data to the current response as SET evaluation, which comes before the generation
|
| 306 |
# CHANGED FROM user_data["modes"][user_data["current"]] + "_set", as are all direct references to top10_e5
|
| 307 |
-
|
| 308 |
return {
|
| 309 |
selection: gr.HTML("""
|
| 310 |
<h2> Autogenerated Response </h2>
|
|
@@ -313,8 +313,8 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 313 |
eval_satisfied: gr.Slider(value = 3),
|
| 314 |
step: step,
|
| 315 |
mode: mode,
|
| 316 |
-
user_data:
|
| 317 |
-
current_response:
|
| 318 |
}
|
| 319 |
# Steps 12 and 13 are gold passage + gold passage generation IF it is applicable
|
| 320 |
if step > 11: # and not current_question["top10_contains_gold_passage"]
|
|
@@ -336,7 +336,7 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 336 |
if step == 12:
|
| 337 |
# The user just evaluated a generation for mode 1
|
| 338 |
# CHANGE from user_data["modes"][user_data["current"]] + "_generation"
|
| 339 |
-
|
| 340 |
return {
|
| 341 |
selection: gr.HTML("""
|
| 342 |
<h2> Retrieved Passage </h2>
|
|
@@ -346,12 +346,12 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 346 |
eval_satisfied: gr.Slider(value = 3),
|
| 347 |
step: step,
|
| 348 |
mode: mode,
|
| 349 |
-
user_data:
|
| 350 |
-
current_response:
|
| 351 |
}
|
| 352 |
elif step == 13:
|
| 353 |
# The user just evaluated the gold passage
|
| 354 |
-
|
| 355 |
return {
|
| 356 |
selection: gr.HTML("""
|
| 357 |
<h2> Autogenerated Response </h2>
|
|
@@ -361,16 +361,16 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 361 |
eval_satisfied: gr.Slider(value = 3),
|
| 362 |
step: step,
|
| 363 |
mode: mode,
|
| 364 |
-
user_data:
|
| 365 |
-
current_response:
|
| 366 |
}
|
| 367 |
else: # step = 14
|
| 368 |
# The user just evaluated the gold passage generation
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
update_huggingface(user_id) # persistence — update progress online, save answers
|
| 373 |
-
current_question = load_current_question(
|
| 374 |
return {
|
| 375 |
selection: gr.Markdown("Advancing to the next question..."),
|
| 376 |
forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
|
|
@@ -378,8 +378,8 @@ with gr.Blocks(theme = theme) as user_eval:
|
|
| 378 |
eval_satisfied: gr.Slider(value = 3),
|
| 379 |
step: step,
|
| 380 |
mode: mode,
|
| 381 |
-
user_data:
|
| 382 |
-
current_response:
|
| 383 |
}
|
| 384 |
|
| 385 |
btn_p.click(fn = next_p, inputs = [eval_0, eval_1, eval_2, eval_3, step, mode, current_response], outputs = [selection, scores_p, scores_g, eval_0, eval_1, eval_2, eval_3, step, mode, current_response])
|
|
|
|
| 258 |
eval_satisfied = gr.Slider(1, 5, step = 0.5, label = "User Satisfaction", value = 3)
|
| 259 |
btn_g = gr.Button("Next")
|
| 260 |
|
| 261 |
+
def next_p(e0, e1, e2, e3, cur_step, mode, cr):
|
| 262 |
step = cur_step + 1
|
| 263 |
# Add user data to the current response
|
| 264 |
+
cr["e5_scores"].append([e0, e1, e2, e3])
|
| 265 |
# Next item
|
| 266 |
if step >= len(current_question["top10_e5"]): # should always be 10 (DEBUG: >= to avoid out of bounds)
|
| 267 |
# Step 10: all sources
|
|
|
|
| 281 |
eval_3: gr.Slider(value = 0),
|
| 282 |
step: step,
|
| 283 |
mode: 1,
|
| 284 |
+
current_response: cr
|
| 285 |
}
|
| 286 |
else:
|
| 287 |
return {
|
|
|
|
| 294 |
eval_3: gr.Slider(value = 0),
|
| 295 |
step: step,
|
| 296 |
mode: 1,
|
| 297 |
+
current_response: cr
|
| 298 |
}
|
| 299 |
|
| 300 |
+
def next_g(e_h, e_s, cur_step, mode, ud, cr):
|
| 301 |
step = cur_step + 1
|
| 302 |
|
| 303 |
if step == 11:
|
| 304 |
# Step 11: guaranteed to be generation
|
| 305 |
# Add user data to the current response as SET evaluation, which comes before the generation
|
| 306 |
# CHANGED FROM user_data["modes"][user_data["current"]] + "_set", as are all direct references to top10_e5
|
| 307 |
+
cr["e5_set"] = [e_h, e_s]
|
| 308 |
return {
|
| 309 |
selection: gr.HTML("""
|
| 310 |
<h2> Autogenerated Response </h2>
|
|
|
|
| 313 |
eval_satisfied: gr.Slider(value = 3),
|
| 314 |
step: step,
|
| 315 |
mode: mode,
|
| 316 |
+
user_data: ud,
|
| 317 |
+
current_response: cr
|
| 318 |
}
|
| 319 |
# Steps 12 and 13 are gold passage + gold passage generation IF it is applicable
|
| 320 |
if step > 11: # and not current_question["top10_contains_gold_passage"]
|
|
|
|
| 336 |
if step == 12:
|
| 337 |
# The user just evaluated a generation for mode 1
|
| 338 |
# CHANGE from user_data["modes"][user_data["current"]] + "_generation"
|
| 339 |
+
cr["e5_generation"] = [e_h, e_s]
|
| 340 |
return {
|
| 341 |
selection: gr.HTML("""
|
| 342 |
<h2> Retrieved Passage </h2>
|
|
|
|
| 346 |
eval_satisfied: gr.Slider(value = 3),
|
| 347 |
step: step,
|
| 348 |
mode: mode,
|
| 349 |
+
user_data: ud,
|
| 350 |
+
current_response: cr
|
| 351 |
}
|
| 352 |
elif step == 13:
|
| 353 |
# The user just evaluated the gold passage
|
| 354 |
+
cr["gold_set"] = [e_h, e_s]
|
| 355 |
return {
|
| 356 |
selection: gr.HTML("""
|
| 357 |
<h2> Autogenerated Response </h2>
|
|
|
|
| 361 |
eval_satisfied: gr.Slider(value = 3),
|
| 362 |
step: step,
|
| 363 |
mode: mode,
|
| 364 |
+
user_data: ud,
|
| 365 |
+
current_response: cr
|
| 366 |
}
|
| 367 |
else: # step = 14
|
| 368 |
# The user just evaluated the gold passage generation
|
| 369 |
+
cr["gold_generation"] = [e_h, e_s]
|
| 370 |
+
ud["current"] += 1
|
| 371 |
+
ud["responses"].append(cr) # adds new answers to current list of responses
|
| 372 |
update_huggingface(user_id) # persistence — update progress online, save answers
|
| 373 |
+
current_question = load_current_question(ud, user_id)
|
| 374 |
return {
|
| 375 |
selection: gr.Markdown("Advancing to the next question..."),
|
| 376 |
forward_btn: gr.Textbox("changed" + str(user_data["current"])), # current forces event to trigger always
|
|
|
|
| 378 |
eval_satisfied: gr.Slider(value = 3),
|
| 379 |
step: step,
|
| 380 |
mode: mode,
|
| 381 |
+
user_data: ud,
|
| 382 |
+
current_response: cr
|
| 383 |
}
|
| 384 |
|
| 385 |
btn_p.click(fn = next_p, inputs = [eval_0, eval_1, eval_2, eval_3, step, mode, current_response], outputs = [selection, scores_p, scores_g, eval_0, eval_1, eval_2, eval_3, step, mode, current_response])
|