Spaces:
Runtime error
Runtime error
Delete app.py
Browse files
app.py
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
import gradio as gr
|
2 |
-
import matplotlib
|
3 |
-
import models
|
4 |
-
import utils
|
5 |
-
|
6 |
-
def infer(gt: str, data: str) -> matplotlib.figure:
|
7 |
-
nli_res = models.compute_metric(gt, data)
|
8 |
-
tone_res = models.compare_tone(gt, data)
|
9 |
-
res_text = ""
|
10 |
-
if (nli_res["label"] == "neutral"):
|
11 |
-
res_text += "Model's response is unrelated to the Ground Truth"
|
12 |
-
if (nli_res["label"] == "contradiction"):
|
13 |
-
res_text += "Model's response contradicts the Ground Truth"
|
14 |
-
if (nli_res["label"] == "entailment"):
|
15 |
-
res_text += "Model's response is consistant with the Ground Truth"
|
16 |
-
return res_text, utils.create_pie_chart_nli(nli_res), utils.plot_tones(tone_res)
|
17 |
-
|
18 |
-
examples = [["Cross-encoders are better than bi-encoders for analyzing the relationship betwen texts", "Bi-encoders are superior to cross-encoders"],
|
19 |
-
["Cross-encoders are better than bi-encoders for analyzing the relationship betwen texts", "The cosine similarity function can be used to compare the outputs of a bi-encoder"],
|
20 |
-
["Cross-encoders are better than bi-encoders for analyzing the relationship betwen texts", "Bi-encoders are outperformed by cross-encoders in the task of relationship analysis"],
|
21 |
-
["Birds can fly. There are fish in the sea.", "Fish inhabit the ocean. Birds can aviate."],
|
22 |
-
["Birds can fly. There are fish in the sea.", "Fish inhabit the ocean. Birds can not aviate."]]
|
23 |
-
app = gr.Interface(fn=infer, inputs=[gr.Textbox(label="Ground Truth"), gr.Textbox(label="Model Response")], examples=examples, outputs=[gr.Textbox(label="Result"), gr.Plot(label="Comparison with GT"), gr.Plot(label="Difference in Tone")])
|
24 |
-
app.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|