Spaces:
Runtime error
Runtime error
first commit
Browse files- README.md +2 -4
- app.py +41 -0
- requirements.txt +1 -0
README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
---
|
2 |
-
title: Qanom End
|
3 |
emoji: 🦀
|
4 |
colorFrom: gray
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
-
pinned:
|
9 |
---
|
10 |
-
|
11 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces#reference
|
|
|
1 |
---
|
2 |
+
title: Qanom End-To-End Pipeline Demo
|
3 |
emoji: 🦀
|
4 |
colorFrom: gray
|
5 |
colorTo: indigo
|
6 |
sdk: gradio
|
7 |
app_file: app.py
|
8 |
+
pinned: true
|
9 |
---
|
|
|
|
app.py
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from qanom.qanom_end_to_end_pipeline import QANomEndToEndPipeline
|
3 |
+
|
4 |
+
|
5 |
+
models = ["kleinay/qanom-seq2seq-model-baseline",
|
6 |
+
"kleinay/qanom-seq2seq-model-joint"]
|
7 |
+
pipelines = {model: QANomEndToEndPipeline(model) for model in models}
|
8 |
+
|
9 |
+
|
10 |
+
description = f"""This is a demo of the full QANom Pipeline - identifying deverbal nominalizations and parsing them with question-answer driven semantic role labeling (QASRL) """
|
11 |
+
title="QANom End-to-End Pipeline Demo"
|
12 |
+
examples = [[models[0], "The doctor was interested in Luke 's treatment .", 0.75],
|
13 |
+
[models[1], "The Veterinary student was interested in Luke 's treatment of sea animals .", 0.75],
|
14 |
+
[models[1], "Some reviewers agreed that the criticism raised by the AC is mostly justified .", 0.75]]
|
15 |
+
|
16 |
+
input_sent_box_label = "Insert sentence here, or select from the examples below"
|
17 |
+
links = """<p style='text-align: center'>
|
18 |
+
<a href='https://www.qasrl.org' target='_blank'>QASRL Website</a> | <a href='https://huggingface.co/kleinay/qanom-seq2seq-model-baseline' target='_blank'>Model Repo at Huggingface Hub</a>
|
19 |
+
</p>"""
|
20 |
+
|
21 |
+
|
22 |
+
def call(model_name, sentence, detection_threshold):
|
23 |
+
|
24 |
+
pipeline = pipelines[model_name]
|
25 |
+
pipe_out_pred_infos = pipeline([sentence], detection_threshold=detection_threshold)[0]
|
26 |
+
def pretty_pred_output(pred_info) -> str:
|
27 |
+
return "\n".join([f"{qa['question']} --- {';'.join(qa['answers'])}"
|
28 |
+
for qa in pred_info['QAs']])
|
29 |
+
pretty_output = "\n".join(pretty_pred_output(pred_info) for pred_info in pipe_out_pred_infos)
|
30 |
+
return pretty_output, pipe_out_pred_infos
|
31 |
+
|
32 |
+
iface = gr.Interface(fn=call,
|
33 |
+
inputs=[gr.inputs.Radio(choices=models, default=models[0], label="Model"),
|
34 |
+
gr.inputs.Textbox(placeholder=input_sent_box_label, label="Sentence", lines=4),
|
35 |
+
gr.inputs.Slider(minimum=0., maximum=1., step=0.01, default=0.5, label="Nominalization Detection Threshold")],
|
36 |
+
outputs=[gr.outputs.Textbox(label="Model Output"), gr.outputs.JSON(label="Model Output - JSON")],
|
37 |
+
title=title,
|
38 |
+
description=description,
|
39 |
+
article=links,
|
40 |
+
examples=examples)
|
41 |
+
iface.launch()
|
requirements.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
qanom
|