Spaces:
Runtime error
Runtime error
File size: 521 Bytes
c346e15 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
import gradio as gr
from transformers import pipeline
unmasker = pipeline('fill-mask', model="CenIA/distillbert-base-spanish-uncased")
def fill_mask(text):
text += " [MASK]"
unmasked = unmasker(text, top_k=8)
output = {}
for unmask in unmasked:
output[unmask["token_str"]] = unmask["score"]
return output
examples = [["quiero comer "], ["me gustaría ir a"]]
demo = gr.Interface(fn=fill_mask, inputs=gr.Textbox(lines=1, label="Input"), outputs=gr.Label(label="Output"), examples=examples)
demo.launch()
|