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