ayushsinha commited on
Commit
edca1a0
·
verified ·
1 Parent(s): c310281

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +28 -0
  2. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ def check_duplicate(sentence1, sentence2):
5
+ model_name = "AventIQ-AI/albert-duplicate-sentence-detection"
6
+ classifier = pipeline("text-classification", model=model_name)
7
+
8
+ input_text = f"{sentence1} [SEP] {sentence2}"
9
+ result = classifier(input_text)[0]
10
+
11
+ label_map = {"LABEL_0": "Not Duplicate", "LABEL_1": "Duplicate"}
12
+ label = label_map.get(result['label'], "Unknown")
13
+
14
+ return f"Label: {label}, Confidence: {result['score']:.4f}"
15
+
16
+ iface = gr.Interface(
17
+ fn=check_duplicate,
18
+ inputs=[
19
+ gr.Textbox(label="Sentence 1"),
20
+ gr.Textbox(label="Sentence 2")
21
+ ],
22
+ outputs=gr.Textbox(label="Prediction"),
23
+ title="Duplicate Sentence Detection",
24
+ description="Enter two sentences to check if they are duplicates."
25
+ )
26
+
27
+ if __name__ == "__main__":
28
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ torch
2
+ transformers
3
+ gradio
4
+ sentencepiece