Spaces:
Runtime error
Runtime error
Commit
·
04b9234
1
Parent(s):
a100b48
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,9 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
| 5 |
|
| 6 |
def fill_mask(sentence):
|
| 7 |
masked_sentence = sentence.replace("[MASK]", unmasker.tokenizer.mask_token)
|
|
@@ -11,4 +13,4 @@ def fill_mask(sentence):
|
|
| 11 |
inputs = gr.inputs.Textbox(label="Enter a sentence with a masked word")
|
| 12 |
outputs = gr.outputs.Textbox(label="Predicted sequences")
|
| 13 |
|
| 14 |
-
gr.Interface(fn=fill_mask, inputs=inputs, outputs=outputs).launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline, BertTokenizer, BertModel
|
| 3 |
|
| 4 |
+
tokenizer = BertTokenizer.from_pretrained('bert-large-uncased')
|
| 5 |
+
model = BertModel.from_pretrained("bert-large-uncased")
|
| 6 |
+
unmasker = pipeline('fill-mask', model=model, tokenizer=tokenizer)
|
| 7 |
|
| 8 |
def fill_mask(sentence):
|
| 9 |
masked_sentence = sentence.replace("[MASK]", unmasker.tokenizer.mask_token)
|
|
|
|
| 13 |
inputs = gr.inputs.Textbox(label="Enter a sentence with a masked word")
|
| 14 |
outputs = gr.outputs.Textbox(label="Predicted sequences")
|
| 15 |
|
| 16 |
+
gr.Interface(fn=fill_mask, inputs=inputs, outputs=outputs).launch(share=true)
|