Spaces:
Runtime error
Runtime error
FEAT: new data source
Browse files- app.py +51 -5
- data/example_data.py +0 -0
app.py
CHANGED
@@ -108,12 +108,13 @@ option = st.selectbox("Choose type of input:",
|
|
108 |
"03 - JSON (example CA-OOD)",
|
109 |
"04 - JSON (example Elysai)",
|
110 |
"05 - Diagnostic mode",
|
111 |
-
"06 - JSON (example Elysai - large)"
|
|
|
112 |
|
113 |
progres_bar = st.progress(0.0, text="Inference")
|
114 |
|
115 |
-
|
116 |
-
|
117 |
context = st.text_area("Insert context here (one turn per line):")
|
118 |
actual_text = st.text_input("Insert current turn:")
|
119 |
context = list(filter(lambda x: len(x.strip()) >= 1, context.split("\n")))
|
@@ -131,7 +132,9 @@ with st.form("input_text"):
|
|
131 |
ax.pie([prop_follow, prop_not_follow], labels=["Probability - Follow", "Probability - Not Follow"],
|
132 |
autopct='%1.1f%%')
|
133 |
st.pyplot(fig)
|
134 |
-
|
|
|
|
|
135 |
from data.example_data import ca_ood, elysai, elysai_large
|
136 |
|
137 |
option: str
|
@@ -179,7 +182,9 @@ with st.form("input_text"):
|
|
179 |
df = pandas.DataFrame(results, columns=["Context", "Query", "Human Label", "Probability (follow)",
|
180 |
"Probability (not-follow)"])
|
181 |
st.dataframe(df)
|
182 |
-
|
|
|
|
|
183 |
context_size = 5
|
184 |
context = st.text_area("Insert dialogue here (one turn per line):")
|
185 |
submitted = st.form_submit_button("Submit")
|
@@ -203,6 +208,47 @@ with st.form("input_text"):
|
|
203 |
aggregated_result.append([line] + scores[idx].tolist())
|
204 |
st.table(aggregated_result)
|
205 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
st.markdown("## Description of models:")
|
207 |
for x in sorted(models.values(), key=lambda x: x["model"]):
|
208 |
st.write((str(x["model"] + " - " + x["description"])))
|
|
|
108 |
"03 - JSON (example CA-OOD)",
|
109 |
"04 - JSON (example Elysai)",
|
110 |
"05 - Diagnostic mode",
|
111 |
+
"06 - JSON (example Elysai - large)",
|
112 |
+
"07 - Dialogue Breakdown Challenge"])
|
113 |
|
114 |
progres_bar = st.progress(0.0, text="Inference")
|
115 |
|
116 |
+
if "01" in option:
|
117 |
+
with st.form("input_text"):
|
118 |
context = st.text_area("Insert context here (one turn per line):")
|
119 |
actual_text = st.text_input("Insert current turn:")
|
120 |
context = list(filter(lambda x: len(x.strip()) >= 1, context.split("\n")))
|
|
|
132 |
ax.pie([prop_follow, prop_not_follow], labels=["Probability - Follow", "Probability - Not Follow"],
|
133 |
autopct='%1.1f%%')
|
134 |
st.pyplot(fig)
|
135 |
+
|
136 |
+
if "02" in option or "03" in option or "04" in option or "06" in option:
|
137 |
+
with st.form("input_text"):
|
138 |
from data.example_data import ca_ood, elysai, elysai_large
|
139 |
|
140 |
option: str
|
|
|
182 |
df = pandas.DataFrame(results, columns=["Context", "Query", "Human Label", "Probability (follow)",
|
183 |
"Probability (not-follow)"])
|
184 |
st.dataframe(df)
|
185 |
+
|
186 |
+
if "05" in option:
|
187 |
+
with st.form("input_text"):
|
188 |
context_size = 5
|
189 |
context = st.text_area("Insert dialogue here (one turn per line):")
|
190 |
submitted = st.form_submit_button("Submit")
|
|
|
208 |
aggregated_result.append([line] + scores[idx].tolist())
|
209 |
st.table(aggregated_result)
|
210 |
|
211 |
+
if "07" in option:
|
212 |
+
from data.example_data import dbc
|
213 |
+
select_conversation = st.selectbox("Which dialogue to evaluate", list(range(len(dbc))), index=0)
|
214 |
+
context = st.text_area("Insert dialogue here (one turn per line):", value=json.dumps([dbc[int(select_conversation)]]))
|
215 |
+
st.markdown("# Formatted form")
|
216 |
+
context_json = json.loads(context)
|
217 |
+
output = ""
|
218 |
+
for conversation in context_json:
|
219 |
+
for utterance in conversation:
|
220 |
+
output += " * " + utterance["text"] + "\n"
|
221 |
+
output += "## ------------------------ "
|
222 |
+
st.markdown(output)
|
223 |
+
with st.form("input_text"):
|
224 |
+
context_size = 5
|
225 |
+
submitted = st.form_submit_button("Submit")
|
226 |
+
if submitted:
|
227 |
+
aggregated_result = []
|
228 |
+
for idx, conversation in enumerate(context_json):
|
229 |
+
data_for_evaluation = get_evaluation_data_from_dialogue([x["text"] for x in conversation])
|
230 |
+
lines = []
|
231 |
+
scores = np.zeros(shape=(len(data_for_evaluation), context_size))
|
232 |
+
for datapoint in data_for_evaluation:
|
233 |
+
progres_bar.progress(idx / len(data_for_evaluation), text="Inference")
|
234 |
+
for actual_sentence, contexts in datapoint.items():
|
235 |
+
lines.append(actual_sentence)
|
236 |
+
for c in contexts:
|
237 |
+
input_tensor = inference_tokenizer.get_item(context=c, actual_sentence=actual_sentence)
|
238 |
+
output_model = model(**input_tensor.data).logits
|
239 |
+
output_model = torch.softmax(output_model, dim=-1).detach().numpy()[0]
|
240 |
+
prop_follow = output_model[0]
|
241 |
+
prop_not_follow = output_model[1]
|
242 |
+
scores[len(lines) - 1][len(c) - 1] = prop_follow
|
243 |
+
|
244 |
+
for idx, line in enumerate(lines):
|
245 |
+
NB = conversation[idx]["NB"]
|
246 |
+
PB = conversation[idx]["PB"]
|
247 |
+
B = conversation[idx]["B"]
|
248 |
+
aggregated_result.append([line] + [f"{NB}/{PB}/{B}"] + scores[idx].tolist())
|
249 |
+
aggregated_result.append([["-"] * len(aggregated_result[-1])])
|
250 |
+
st.table(aggregated_result)
|
251 |
+
|
252 |
st.markdown("## Description of models:")
|
253 |
for x in sorted(models.values(), key=lambda x: x["model"]):
|
254 |
st.write((str(x["model"] + " - " + x["description"])))
|
data/example_data.py
CHANGED
The diff for this file is too large to render.
See raw diff
|
|