Spaces:
Runtime error
Runtime error
Update src/app.py
Browse files- 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 |
-
|
| 288 |
-
st.
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 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)}*")
|