Spaces:
Sleeping
Sleeping
Sharathhebbar24
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -4,30 +4,12 @@ from transformers import AutoTokenizer, AutoModel
|
|
4 |
from sentence_transformers import util
|
5 |
class SentenceSimiliarity():
|
6 |
|
7 |
-
def __init__(self, sentence1, sentence2):
|
8 |
self.sentence1 = sentence1
|
9 |
self.sentence2 = sentence2
|
10 |
-
|
|
|
11 |
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
12 |
-
|
13 |
-
|
14 |
-
def model_selection(self):
|
15 |
-
available_models = [
|
16 |
-
"distilbert-base-uncased",
|
17 |
-
"bert-base-uncased",
|
18 |
-
"sentence-transformers/all-MiniLM-L6-v2",
|
19 |
-
"sentence-transformers/all-mpnet-base-v2",
|
20 |
-
"intfloat/multilingual-e5-base",
|
21 |
-
"togethercomputer/m2-bert-80M-32k-retrieval",
|
22 |
-
"togethercomputer/m2-bert-80M-8k-retrieval",
|
23 |
-
"togethercomputer/m2-bert-80M-2k-retrieval",
|
24 |
-
]
|
25 |
-
self.model_name = st.sidebar.selectbox(
|
26 |
-
label="Select Your Models",
|
27 |
-
options=available_models,
|
28 |
-
)
|
29 |
-
self.model = AutoModel.from_pretrained(self.model_name)
|
30 |
-
|
31 |
|
32 |
def tokenize(self):
|
33 |
tokenized1 = self.tokenizer(
|
@@ -83,9 +65,26 @@ class UI():
|
|
83 |
help='Check Sentence Similarity'
|
84 |
)
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
def result(self):
|
87 |
self.get()
|
88 |
-
ss = SentenceSimiliarity(self.sentence1, self.sentence2)
|
89 |
|
90 |
if self.button:
|
91 |
st.text(ss.results())
|
|
|
4 |
from sentence_transformers import util
|
5 |
class SentenceSimiliarity():
|
6 |
|
7 |
+
def __init__(self, model_name, model, sentence1, sentence2):
|
8 |
self.sentence1 = sentence1
|
9 |
self.sentence2 = sentence2
|
10 |
+
self.model_name = model_name
|
11 |
+
self.model = model
|
12 |
self.tokenizer = AutoTokenizer.from_pretrained(self.model_name)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
def tokenize(self):
|
15 |
tokenized1 = self.tokenizer(
|
|
|
65 |
help='Check Sentence Similarity'
|
66 |
)
|
67 |
|
68 |
+
def model_selection(self):
|
69 |
+
available_models = [
|
70 |
+
"distilbert-base-uncased",
|
71 |
+
"bert-base-uncased",
|
72 |
+
"sentence-transformers/all-MiniLM-L6-v2",
|
73 |
+
"sentence-transformers/all-mpnet-base-v2",
|
74 |
+
"intfloat/multilingual-e5-base",
|
75 |
+
"togethercomputer/m2-bert-80M-32k-retrieval",
|
76 |
+
"togethercomputer/m2-bert-80M-8k-retrieval",
|
77 |
+
"togethercomputer/m2-bert-80M-2k-retrieval",
|
78 |
+
]
|
79 |
+
self.model_name = st.sidebar.selectbox(
|
80 |
+
label="Select Your Models",
|
81 |
+
options=available_models,
|
82 |
+
)
|
83 |
+
self.model = AutoModel.from_pretrained(self.model_name)
|
84 |
+
|
85 |
def result(self):
|
86 |
self.get()
|
87 |
+
ss = SentenceSimiliarity(self.model_name, self.model, self.sentence1, self.sentence2)
|
88 |
|
89 |
if self.button:
|
90 |
st.text(ss.results())
|