Towhidul commited on
Commit
479dd5b
·
1 Parent(s): 606cf69

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -32
app.py CHANGED
@@ -346,38 +346,38 @@ def gen_qa_who(df):
346
  evidence=df["evidence"][i]
347
  #time.sleep(10)
348
  if srl!="":
349
- try:
350
- for j in range(0,len(answer)):
351
- FACT_TO_GENERATE_QUESTION_FROM = f"""{answer[j]} [SEP] {claim}"""
352
- #FACT_TO_GENERATE_QUESTION_FROM = f"""generate_who_based_question_from_context_using_the_next_answer:{answer[j]} [SEP] context:{claim}"""
353
- #time.sleep(10)
354
- question_ids = query({"inputs":FACT_TO_GENERATE_QUESTION_FROM,
355
- "num_beams":5,
356
- "early_stopping":True,
357
- "min_length": 100,"wait_for_model":True})[0]['generated_text'].capitalize()
358
- question_ids = rephrase_question_who(question_ids)
359
- list_of_ques_who.append(f"""Q{j+1}:{question_ids}""")
360
- list_of_ans_who.append(f"""Ans{j+1}:{answer[j]}""")
361
- input_evidence = f"answer_the_next_question_from_context: {question_ids} context: {evidence}"
362
- #time.sleep(10)
363
- answer_evidence = query_evidence({"inputs":input_evidence,"truncation":True,"wait_for_model":True})[0]['generated_text']
364
- if answer_evidence.lower() in evidence.lower():
365
- list_of_evidence_answer_who.append(f"""Evidence{j+1}:{answer_evidence}""")
366
- else:
367
- answer_evidence=""
368
- list_of_evidence_answer_who.append(f"""No mention of 'who'in any related documents.""")
369
- threshold = 0.2
370
- list_of_pairs = [(answer_evidence, answer[j])]
371
- rouge_l_score = calc_rouge_l_score(answer_evidence, answer[j])
372
- if rouge_l_score >= threshold:
373
- verification_status = 'Verified Valid'
374
- elif rouge_l_score == 0:
375
- verification_status = 'Not verifiable'
376
- else:
377
- verification_status = 'Verified False'
378
- rouge_l_scores.append(verification_status)
379
- except:
380
- pass
381
  else:
382
  list_of_ques_who="No claims"
383
  list_of_ans_who=""
 
346
  evidence=df["evidence"][i]
347
  #time.sleep(10)
348
  if srl!="":
349
+ # try:
350
+ for j in range(0,len(answer)):
351
+ FACT_TO_GENERATE_QUESTION_FROM = f"""{answer[j]} [SEP] {claim}"""
352
+ #FACT_TO_GENERATE_QUESTION_FROM = f"""generate_who_based_question_from_context_using_the_next_answer:{answer[j]} [SEP] context:{claim}"""
353
+ #time.sleep(10)
354
+ question_ids = query({"inputs":FACT_TO_GENERATE_QUESTION_FROM,
355
+ "num_beams":5,
356
+ "early_stopping":True,
357
+ "min_length": 100,"wait_for_model":True})[0]['generated_text'].capitalize()
358
+ question_ids = rephrase_question_who(question_ids)
359
+ list_of_ques_who.append(f"""Q{j+1}:{question_ids}""")
360
+ list_of_ans_who.append(f"""Ans{j+1}:{answer[j]}""")
361
+ input_evidence = f"answer_the_next_question_from_context: {question_ids} context: {evidence}"
362
+ #time.sleep(10)
363
+ answer_evidence = query_evidence({"inputs":input_evidence,"truncation":True,"wait_for_model":True})[0]['generated_text']
364
+ if answer_evidence.lower() in evidence.lower():
365
+ list_of_evidence_answer_who.append(f"""Evidence{j+1}:{answer_evidence}""")
366
+ else:
367
+ answer_evidence=""
368
+ list_of_evidence_answer_who.append(f"""No mention of 'who'in any related documents.""")
369
+ threshold = 0.2
370
+ list_of_pairs = [(answer_evidence, answer[j])]
371
+ rouge_l_score = calc_rouge_l_score(answer_evidence, answer[j])
372
+ if rouge_l_score >= threshold:
373
+ verification_status = 'Verified Valid'
374
+ elif rouge_l_score == 0:
375
+ verification_status = 'Not verifiable'
376
+ else:
377
+ verification_status = 'Verified False'
378
+ rouge_l_scores.append(verification_status)
379
+ # except:
380
+ # pass
381
  else:
382
  list_of_ques_who="No claims"
383
  list_of_ans_who=""