xuandin commited on
Commit
4af1026
·
verified ·
1 Parent(s): d8e959c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -17
app.py CHANGED
@@ -132,7 +132,6 @@ with st.container():
132
  </p>
133
  </div>
134
  """, unsafe_allow_html=True)
135
- # st.markdown("<p class='sub-title'>Enter the claim and context to verify its accuracy</p>", unsafe_allow_html=True)
136
 
137
  # Sidebar: Global Settings
138
  with st.sidebar.expander("⚙️ Settings", expanded=True):
@@ -203,29 +202,31 @@ with st.container():
203
 
204
  # Extract evidence
205
  evidence_start_time = time.time()
206
- evidence = extract_evidence_tfidf_qatc(
207
- claim, context, model_qatc, tokenizer_qatc,
208
- "cuda" if torch.cuda.is_available() else "cpu",
209
- confidence_threshold=tfidf_threshold,
210
- length_ratio_threshold=length_ratio_threshold
211
- )
 
212
  evidence_time = time.time() - evidence_start_time
213
 
214
  # Classify the claim
215
  verdict = "NEI"
216
  details = ""
217
  verdict_start_time = time.time()
218
- prob2class, pred_bc = 0, "Not used"
219
- prob3class, pred_tc = classify_claim(
220
- claim, evidence, model_tc, tokenizer_tc,
221
- "cuda" if torch.cuda.is_available() else "cpu"
222
- )
223
- if pred_tc != 0:
224
- prob2class, pred_bc = classify_claim(
225
- claim, evidence, model_bc, tokenizer_bc,
226
  "cuda" if torch.cuda.is_available() else "cpu"
227
  )
228
- verdict = "SUPPORTED" if pred_bc == 0 else "REFUTED" if prob2class > prob3class else ["NEI", "SUPPORTED", "REFUTED"][pred_tc]
 
 
 
 
 
229
  verdict_time = time.time() - verdict_start_time
230
  if show_details:
231
  details = f"""
@@ -286,4 +287,4 @@ with st.container():
286
  for idx, record in enumerate(reversed(st.session_state.history), 1):
287
  st.markdown(f"**{idx}. Claim:** {record['claim']} \n**Result:** {verdict_icons.get(record['verdict'], '')} {record['verdict']}")
288
  else:
289
- st.write("No verification history yet.")
 
132
  </p>
133
  </div>
134
  """, unsafe_allow_html=True)
 
135
 
136
  # Sidebar: Global Settings
137
  with st.sidebar.expander("⚙️ Settings", expanded=True):
 
202
 
203
  # Extract evidence
204
  evidence_start_time = time.time()
205
+ with torch.no_grad():
206
+ evidence = extract_evidence_tfidf_qatc(
207
+ claim, context, model_qatc, tokenizer_qatc,
208
+ "cuda" if torch.cuda.is_available() else "cpu",
209
+ confidence_threshold=tfidf_threshold,
210
+ length_ratio_threshold=length_ratio_threshold
211
+ )
212
  evidence_time = time.time() - evidence_start_time
213
 
214
  # Classify the claim
215
  verdict = "NEI"
216
  details = ""
217
  verdict_start_time = time.time()
218
+ with torch.no_grad():
219
+ prob2class, pred_bc = 0, "Not used"
220
+ prob3class, pred_tc = classify_claim(
221
+ claim, evidence, model_tc, tokenizer_tc,
 
 
 
 
222
  "cuda" if torch.cuda.is_available() else "cpu"
223
  )
224
+ if pred_tc != 0:
225
+ prob2class, pred_bc = classify_claim(
226
+ claim, evidence, model_bc, tokenizer_bc,
227
+ "cuda" if torch.cuda.is_available() else "cpu"
228
+ )
229
+ verdict = "SUPPORTED" if pred_bc == 0 else "REFUTED" if prob2class > prob3class else ["NEI", "SUPPORTED", "REFUTED"][pred_tc]
230
  verdict_time = time.time() - verdict_start_time
231
  if show_details:
232
  details = f"""
 
287
  for idx, record in enumerate(reversed(st.session_state.history), 1):
288
  st.markdown(f"**{idx}. Claim:** {record['claim']} \n**Result:** {verdict_icons.get(record['verdict'], '')} {record['verdict']}")
289
  else:
290
+ st.write("No verification history yet.")