Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,10 @@ import streamlit as st
|
|
2 |
from sentence_transformers.util import cos_sim
|
3 |
from sentence_transformers import SentenceTransformer
|
4 |
|
|
|
|
|
|
|
|
|
5 |
st.title("Sentence Embedding for Spanish with Bertin")
|
6 |
st.text("Sentence embedding for spanish trained on NLI. Used for Sentence Textual Similarity.")
|
7 |
|
@@ -10,7 +14,7 @@ sent2 = st.text_area('Enter sentence 2')
|
|
10 |
|
11 |
if st.button('Compute similarity'):
|
12 |
if sent1 and sent2:
|
13 |
-
model =
|
14 |
encodings = model.encode([sent1, sent2])
|
15 |
sim = cos_sim(encodings[0], encodings[1]).numpy().tolist()[0][0]
|
16 |
st.text('Cosine Similarity: {0:.4f}'.format(sim))
|
|
|
2 |
from sentence_transformers.util import cos_sim
|
3 |
from sentence_transformers import SentenceTransformer
|
4 |
|
5 |
+
@st.cache
|
6 |
+
def load_model():
|
7 |
+
model = SentenceTransformer('hackathon-pln-es/bertin-roberta-base-finetuning-esnli')
|
8 |
+
|
9 |
st.title("Sentence Embedding for Spanish with Bertin")
|
10 |
st.text("Sentence embedding for spanish trained on NLI. Used for Sentence Textual Similarity.")
|
11 |
|
|
|
14 |
|
15 |
if st.button('Compute similarity'):
|
16 |
if sent1 and sent2:
|
17 |
+
model = load_model()
|
18 |
encodings = model.encode([sent1, sent2])
|
19 |
sim = cos_sim(encodings[0], encodings[1]).numpy().tolist()[0][0]
|
20 |
st.text('Cosine Similarity: {0:.4f}'.format(sim))
|