Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
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))
|