mmazuecos's picture
Update app.py
9423c98
raw
history blame
759 Bytes
import streamlit as st
from sentence_transformers.util import cos_sim
from sentence_transformers import SentenceTransformer
def process(sent1, sent2):
if sent1 and sent2:
encodings = model.encode([sent1, sent2])
sim = cos_sim(encodings[0], encodings[1]).numpy().tolist()[0][0]
st.write('Cosine Similarity: {0:.4f}'.format(sim))
st.title("Sentence Embedding for Spanish with Bertin")
st.write("Sentence embedding for spanish trained on NLI. Used for Sentence Textual Similarity.")
model = SentenceTransformer('hackathon-pln-es/bertin-roberta-base-finetuning-esnli')
sent1 = st.text_area('Enter sentence 1')
sent2 = st.text_area('Enter sentence 2')
st.button('Compute similarity', key=None, help=None, on_click=process, args=(sent1, sent2))