File size: 678 Bytes
b3f6fd8
809abd3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline

# Create the fill-mask pipeline
fill_mask_pipe = pipeline("fill-mask", model="ayoubkirouane/FILL-MAsk-RoBERTa-base")

def fill_mask(text):
    # Make a prediction using the fill-mask pipeline
    results = fill_mask_pipe(text)
    return results[0]["sequence"]

example = ["The capital of Algeria is <mask>."]
# Create a Gradio interface
iface = gr.Interface(
    fn=fill_mask,
    inputs="text",
    outputs="text",
    examples=example,
    title="FILL-MAsk-RoBERTa-base Demo",
    description="Enter a sentence with a masked token, and the model will predict the missing word.",
)

# Launch the Gradio app
iface.launch()