File size: 599 Bytes
f165449
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# app.py
import torch
from transformers import pipeline
import gradio as gr

# Initialize the model pipeline
pipe = pipeline(
    "fill-mask",
    model="answerdotai/ModernBERT-base",
    torch_dtype=torch.bfloat16,
)

# Function to run the model
def fill_mask(input_text):
    return pipe(input_text)

# Set up the Gradio interface
iface = gr.Interface(
    fn=fill_mask, 
    inputs="text", 
    outputs="json",
    title="Mask Filling with ModernBERT",
    description="Enter a sentence with a [MASK] token, and the model will predict the missing word."
)

# Launch the interface
iface.launch()