Spaces:
Sleeping
Sleeping
Commit
·
2423a57
1
Parent(s):
ea84696
init
Browse files- app.py +21 -26
- config.json +5 -0
app.py
CHANGED
@@ -1,35 +1,30 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
-
|
|
|
4 |
|
5 |
-
|
|
|
|
|
|
|
6 |
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
8 |
|
|
|
9 |
examples = [
|
10 |
-
[
|
|
|
11 |
]
|
12 |
|
13 |
-
|
14 |
-
io2 = gr.Interface.load("huggingface/bert-base-uncased")
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
else:
|
20 |
-
outlabel = io2(inputtext)
|
21 |
-
return outlabel
|
22 |
-
|
23 |
-
inputs = gr.Textbox(label="Context", lines=10)
|
24 |
-
model_choice = gr.Dropdown(choices=["bert-base-cased", "bert-base-uncased"], label="Model")
|
25 |
-
outputs = gr.Textbox(label="Output")
|
26 |
-
|
27 |
-
gr.Interface(
|
28 |
-
fn=inference,
|
29 |
-
inputs=[inputs, model_choice],
|
30 |
-
outputs=outputs,
|
31 |
-
examples=examples,
|
32 |
-
article=article,
|
33 |
-
title=title,
|
34 |
-
description=description
|
35 |
-
).launch(enable_queue=True)
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
|
4 |
+
# Load the SteelBERT model for mask filling
|
5 |
+
fill_mask = pipeline("fill-mask", model="MGE-LLMs/SteelBERT")
|
6 |
|
7 |
+
# Define the Gradio interface
|
8 |
+
def mask_filler(text):
|
9 |
+
result = fill_mask(text)
|
10 |
+
return result[0]["sequence"]
|
11 |
|
12 |
+
iface = gr.Interface(
|
13 |
+
fn=mask_filler,
|
14 |
+
inputs=gr.Textbox(lines=3, label="Enter a sentence with [MASK] token"),
|
15 |
+
outputs=gr.Textbox(label="Completed sentence"),
|
16 |
+
title="SteelBERT Mask Filler",
|
17 |
+
description="Fill in the masked token using SteelBERT.",
|
18 |
+
)
|
19 |
|
20 |
+
# Add some example inputs for the interface
|
21 |
examples = [
|
22 |
+
["SteelBERT is a [MASK] model for filling in missing information."],
|
23 |
+
["I have a [MASK] of apples and oranges."],
|
24 |
]
|
25 |
|
26 |
+
iface.examples = examples
|
|
|
27 |
|
28 |
+
# Launch the interface
|
29 |
+
if __name__ == "__main__":
|
30 |
+
iface.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"environments": ["python"],
|
3 |
+
"command": "python app.py"
|
4 |
+
}
|
5 |
+
|