Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1 +1,33 @@
|
|
1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
BASE_MODEL = "nlpaueb/legal-bert-base-uncased"
|
5 |
+
|
6 |
+
mask_filler = pipeline("fill-mask", model=BASE_MODEL)
|
7 |
+
|
8 |
+
def mask_fill(text):
|
9 |
+
k = []
|
10 |
+
preds = mask_filler(text)
|
11 |
+
for pred in preds:
|
12 |
+
k.append(pred["sequence"])
|
13 |
+
final_string = '\n\n'.join(k)
|
14 |
+
return final_string
|
15 |
+
|
16 |
+
gradio_ui = gr.Interface(
|
17 |
+
fn=mask_fill,
|
18 |
+
title="Predicting masked words in legal text",
|
19 |
+
description="Enter a a sentence to predict the masked word",
|
20 |
+
inputs=[
|
21 |
+
gr.inputs.Textbox(lines=3),
|
22 |
+
],
|
23 |
+
outputs=[
|
24 |
+
gr.outputs.Textbox(label="Answer"),
|
25 |
+
],
|
26 |
+
examples=[
|
27 |
+
["The applicant submitted that her husband was subjected to treatment amounting to [MASK] whilst in the custody of police."],
|
28 |
+
],
|
29 |
+
enable_queue=True,
|
30 |
+
allow_screenshot=False,
|
31 |
+
allow_flagging=False,
|
32 |
+
)
|
33 |
+
gradio_ui.launch(debug=True)
|