Spaces:
Running
Running
added a checkbox with default false for word importances
Browse files
app.py
CHANGED
@@ -146,24 +146,30 @@ q2i_map = {
|
|
146 |
with st.expander('Expand to explore further'):
|
147 |
st.write(f'Your comment was rated as a QuAL score of **{results["qual"]["label"]}**, indicating **{qual_map[results["qual"]["label"]]}** quality feedback.')
|
148 |
|
|
|
|
|
|
|
149 |
st.markdown('### Level of Detail')
|
150 |
st.write(f"The model identified a **{q1_map[results['q1']['label']]}** level of detail in your comment.")
|
151 |
-
|
152 |
-
|
153 |
-
|
|
|
154 |
|
155 |
st.markdown('### Suggestion for Improvement')
|
156 |
st.write(f"The model **{q2i_map[results['q2i']['label']]}** predict that you provided a suggestion for improvement in your comment.")
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
160 |
|
161 |
if results['q2i']['label'] == 0:
|
162 |
st.markdown('### Suggestion Linking')
|
163 |
st.write(f"The model **{q2i_map[results['q3i']['label']]}** predict that you linked your suggestion")
|
164 |
-
|
165 |
-
|
166 |
-
|
|
|
167 |
|
168 |
|
169 |
# annotated_text(to_disp)
|
|
|
146 |
with st.expander('Expand to explore further'):
|
147 |
st.write(f'Your comment was rated as a QuAL score of **{results["qual"]["label"]}**, indicating **{qual_map[results["qual"]["label"]]}** quality feedback.')
|
148 |
|
149 |
+
do_word_importances = st.checkbox("Calculate word importance. This provides more detail on model reasoning below, but takes much longer to compute.",
|
150 |
+
value=False)
|
151 |
+
|
152 |
st.markdown('### Level of Detail')
|
153 |
st.write(f"The model identified a **{q1_map[results['q1']['label']]}** level of detail in your comment.")
|
154 |
+
if do_word_importances:
|
155 |
+
st.write("Below are words that pointed the model toward (green) or against (red) identifying a high level of detail:")
|
156 |
+
with st.spinner("Calculating word importances, may take a while..."):
|
157 |
+
annotated_text(get_explained_words(st.session_state['comment'], models['q1'], 'LABEL_3', RdYlGn_10))
|
158 |
|
159 |
st.markdown('### Suggestion for Improvement')
|
160 |
st.write(f"The model **{q2i_map[results['q2i']['label']]}** predict that you provided a suggestion for improvement in your comment.")
|
161 |
+
if do_word_importances:
|
162 |
+
st.write(f"Below are words that pointed the model toward (green) or against (red) identifying a suggestion for improvement:")
|
163 |
+
with st.spinner("Calculating word importances, may take a while..."):
|
164 |
+
annotated_text(get_explained_words(st.session_state['comment'], models['q2i'], 'LABEL_0', RdYlGn_10))
|
165 |
|
166 |
if results['q2i']['label'] == 0:
|
167 |
st.markdown('### Suggestion Linking')
|
168 |
st.write(f"The model **{q2i_map[results['q3i']['label']]}** predict that you linked your suggestion")
|
169 |
+
if do_word_importances:
|
170 |
+
st.write(f"Below are words that pointed the model toward (green) or against (red) identifying a linked suggestion:")
|
171 |
+
with st.spinner("Calculating word importances, may take a while..."):
|
172 |
+
annotated_text(get_explained_words(st.session_state['comment'], models['q3i'], 'LABEL_0', RdYlGn_10))
|
173 |
|
174 |
|
175 |
# annotated_text(to_disp)
|