pulkitmehtawork commited on
Commit
b9b2b14
1 Parent(s): 4e02de1

Fill mask modern bert

Browse files
Files changed (2) hide show
  1. app.py +29 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # app.py
2
+ import torch
3
+ from transformers import pipeline
4
+ import gradio as gr
5
+
6
+ # Initialize the model pipeline
7
+ pipe = pipeline(
8
+ "fill-mask",
9
+ model="answerdotai/ModernBERT-base",
10
+ torch_dtype=torch.bfloat16,
11
+ )
12
+
13
+
14
+ # Function to run the model
15
+ def fill_mask(input_text):
16
+ return pipe(input_text)[0]["sequence"]
17
+
18
+
19
+ # Set up the Gradio interface
20
+ iface = gr.Interface(
21
+ fn=fill_mask,
22
+ inputs="text",
23
+ outputs="text",
24
+ title="Mask Filling with ModernBERT",
25
+ description="Enter a sentence with a [MASK] token, and the model will predict the missing word.",
26
+ )
27
+
28
+ # Launch the interface
29
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ transformers @ git+https://github.com/huggingface/transformers.git
3
+ gradio
4
+