File size: 495 Bytes
17df930 5552924 17df930 da44bb5 17df930 5552924 17df930 1139d7b 17df930 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
import gradio as gr
from transformers import pipeline
unmasker = pipeline('fill-mask', model='bert-base-uncased')
def fill_mask(text):
unmasked = unmasker(text)
output = {}
for unmask in unmasked:
output[unmask["token_str"]] = unmask["score"]
return output
examples = [["Hello I'm a [MASK] model."], ["[MASK] is my favourite sports."]]
demo = gr.Interface(fn=fill_mask, inputs=gr.Textbox(lines=1, label="Input"), outputs=gr.Label(label="Output"), examples=examples)
demo.launch() |