sitammeur commited on
Commit
44ed7b9
·
verified ·
1 Parent(s): 4efdbb5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +55 -52
app.py CHANGED
@@ -1,52 +1,55 @@
1
- # Necessary imports
2
- import gradio as gr
3
- from src.modernbert.classifier import ZeroShotTextClassification
4
-
5
-
6
- # Examples to display in the interface
7
- examples = [
8
- [
9
- "I have a problem with my iPhone that needs to be resolved asap!",
10
- "urgent, not urgent, phone, tablet, computer",
11
- False,
12
- ],
13
- [
14
- "Angela Merkel is a politician in Germany and leader of the CDU",
15
- "politics, economy, entertainment, environment",
16
- False,
17
- ],
18
- [
19
- "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
20
- "refund, legal, faq",
21
- True,
22
- ],
23
- ]
24
-
25
- # Title and description and article for the interface
26
- title = "Zero Shot Text Classification"
27
- description = "Classify text using zero-shot classification with ModernBERT-large zeroshot model! Provide a text input and a list of candidate labels separated by commas. Read more at the links below."
28
- article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2412.13663' target='_blank'>Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference</a> | <a href='https://huggingface.co/MoritzLaurer/ModernBERT-large-zeroshot-v2.0' target='_blank'>Model Page</a></p>"
29
-
30
-
31
- # Launch the interface
32
- demo = gr.Interface(
33
- fn=ZeroShotTextClassification,
34
- inputs=[
35
- gr.Textbox(label="Input", placeholder="Enter text to classify"),
36
- gr.Textbox(
37
- label="Candidate Labels",
38
- placeholder="Enter candidate labels separated by commas",
39
- ),
40
- gr.Checkbox(label="Multi-Label", value=False),
41
- ],
42
- outputs=gr.Label(label="Classification"),
43
- title=title,
44
- description=description,
45
- article=article,
46
- examples=examples,
47
- cache_examples=True,
48
- cache_mode="lazy",
49
- theme="Soft",
50
- flagging_mode="never",
51
- )
52
- demo.launch(debug=False)
 
 
 
 
1
+ # Necessary imports
2
+ import warnings
3
+ warnings.filterwarnings("ignore")
4
+
5
+ import gradio as gr
6
+ from src.modernbert.classifier import ZeroShotTextClassification
7
+
8
+
9
+ # Examples to display in the interface
10
+ examples = [
11
+ [
12
+ "I have a problem with my iPhone that needs to be resolved asap!",
13
+ "urgent, not urgent, phone, tablet, computer",
14
+ False,
15
+ ],
16
+ [
17
+ "Angela Merkel is a politician in Germany and leader of the CDU",
18
+ "politics, economy, entertainment, environment",
19
+ False,
20
+ ],
21
+ [
22
+ "Hi, I recently bought a device from your company but it is not working as advertised and I would like to get reimbursed!",
23
+ "refund, legal, faq",
24
+ True,
25
+ ],
26
+ ]
27
+
28
+ # Title and description and article for the interface
29
+ title = "Zero Shot Text Classification"
30
+ description = "Classify text using zero-shot classification with ModernBERT-large zeroshot model! Provide a text input and a list of candidate labels separated by commas. Read more at the links below."
31
+ article = "<p style='text-align: center'><a href='https://arxiv.org/abs/2412.13663' target='_blank'>Smarter, Better, Faster, Longer: A Modern Bidirectional Encoder for Fast, Memory Efficient, and Long Context Finetuning and Inference</a> | <a href='https://huggingface.co/MoritzLaurer/ModernBERT-large-zeroshot-v2.0' target='_blank'>Model Page</a></p>"
32
+
33
+
34
+ # Launch the interface
35
+ demo = gr.Interface(
36
+ fn=ZeroShotTextClassification,
37
+ inputs=[
38
+ gr.Textbox(label="Input", placeholder="Enter text to classify"),
39
+ gr.Textbox(
40
+ label="Candidate Labels",
41
+ placeholder="Enter candidate labels separated by commas",
42
+ ),
43
+ gr.Checkbox(label="Multi-Label", value=False),
44
+ ],
45
+ outputs=gr.Label(label="Classification"),
46
+ title=title,
47
+ description=description,
48
+ article=article,
49
+ examples=examples,
50
+ cache_examples=True,
51
+ cache_mode="lazy",
52
+ theme="Soft",
53
+ flagging_mode="never",
54
+ )
55
+ demo.launch(debug=False)