Spaces:
Sleeping
Sleeping
bikram-riverus
commited on
model compare
Browse files
app.py
CHANGED
@@ -4,19 +4,28 @@ from sentence_transformers import SentenceTransformer
|
|
4 |
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
import spacy
|
6 |
|
|
|
|
|
|
|
|
|
7 |
nlp = spacy.load("en_core_web_sm")
|
|
|
|
|
8 |
model = SentenceTransformer("rufimelo/Legal-BERTimbau-sts-base")
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
|
|
15 |
|
16 |
-
|
|
|
17 |
|
18 |
-
|
19 |
-
|
20 |
|
21 |
-
|
|
|
22 |
st.dataframe(s)
|
|
|
4 |
from sklearn.metrics.pairwise import cosine_similarity
|
5 |
import spacy
|
6 |
|
7 |
+
left_text = st.text_input('First', 'This is a test')
|
8 |
+
right_text = st.text_input('Second', 'This is another test')
|
9 |
+
|
10 |
+
st.toast("Loading spacy...")
|
11 |
nlp = spacy.load("en_core_web_sm")
|
12 |
+
|
13 |
+
st.toast("Loading rufimelo/Legal-BERTimbau-sts-base...")
|
14 |
model = SentenceTransformer("rufimelo/Legal-BERTimbau-sts-base")
|
15 |
|
16 |
+
st.toast("Legal-BERTimbau-sts-base: computing embeddings...")
|
17 |
+
embeddings = model.encode([left_text, right_text])
|
18 |
+
|
19 |
+
st.toast("Legal-BERTimbau-sts-base: computing similarity...")
|
20 |
+
similarity = cosine_similarity(embeddings[: 1], embeddings[1 :])
|
21 |
+
st.dataframe(s)
|
22 |
|
23 |
+
st.toast("Loading nlpaueb/legal-bert-base-uncased...")
|
24 |
+
model = SentenceTransformer("nlpaueb/legal-bert-base-uncased")
|
25 |
|
26 |
+
st.toast("legal-bert-base-uncased: computing embeddings...")
|
27 |
+
embeddings = model.encode([left_text, right_text])
|
28 |
|
29 |
+
st.toast("legal-bert-base-uncased: computing similarity...")
|
30 |
+
similarity = cosine_similarity(embeddings[: 1], embeddings[1 :])
|
31 |
st.dataframe(s)
|