sulcan commited on
Commit
bd53950
·
verified ·
1 Parent(s): 56858b7

Update src/app.py

Browse files
Files changed (1) hide show
  1. src/app.py +13 -12
src/app.py CHANGED
@@ -283,18 +283,19 @@ if model:
283
  st.markdown(colored_text_html, unsafe_allow_html=True)
284
  st.markdown("---")
285
 
286
- '''
287
- st.subheader("💡 Interactive Attention")
288
- st.markdown("Hover over any word to highlight other words it pays strong attention to.")
289
- start, end = st.session_state.start_index, st.session_state.end_index
290
- user_tokens, user_attention_matrix = st.session_state.full_tokens[start:end], st.session_state.attention_matrix
291
- max_attention = float(np.max(user_attention_matrix)) if user_attention_matrix.size > 0 else 0.1
292
- default_slider_val = min(0.1, max_attention) if max_attention > 0 else 0.1
293
- attention_threshold = st.slider("Attention Threshold", 0.0, max_attention, default_slider_val, 0.01, "%.2f")
294
- interactive_html = render_interactive_text(user_tokens, user_attention_matrix, start, attention_threshold)
295
- components.html(interactive_html, height=200, scrolling=True)
296
- st.markdown("---")
297
- '''
 
298
  if st.session_state.suspicious_phrases:
299
  st.warning("High-perplexity phrases identified:")
300
  for phrase in st.session_state.suspicious_phrases: st.markdown(f"- *{filter_token(phrase)}*")
 
283
  st.markdown(colored_text_html, unsafe_allow_html=True)
284
  st.markdown("---")
285
 
286
+
287
+ # Attention analysis
288
+ # st.subheader("💡 Interactive Attention")
289
+ # st.markdown("Hover over any word to highlight other words it pays strong attention to.")
290
+ # start, end = st.session_state.start_index, st.session_state.end_index
291
+ # user_tokens, user_attention_matrix = st.session_state.full_tokens[start:end], st.session_state.attention_matrix
292
+ # max_attention = float(np.max(user_attention_matrix)) if user_attention_matrix.size > 0 else 0.1
293
+ # default_slider_val = min(0.1, max_attention) if max_attention > 0 else 0.1
294
+ # attention_threshold = st.slider("Attention Threshold", 0.0, max_attention, default_slider_val, 0.01, "%.2f")
295
+ # interactive_html = render_interactive_text(user_tokens, user_attention_matrix, start, attention_threshold)
296
+ # components.html(interactive_html, height=200, scrolling=True)
297
+ # st.markdown("---")
298
+
299
  if st.session_state.suspicious_phrases:
300
  st.warning("High-perplexity phrases identified:")
301
  for phrase in st.session_state.suspicious_phrases: st.markdown(f"- *{filter_token(phrase)}*")