File size: 903 Bytes
4547fcf
 
 
 
abc1971
 
 
6688dca
d0935e7
abc1971
4547fcf
a71f9d4
4547fcf
9423c98
 
 
5117017
 
abc1971
5117017
 
 
 
 
 
 
4547fcf
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import streamlit as st
from sentence_transformers.util import cos_sim
from sentence_transformers import SentenceTransformer

@st.cache
def load_model():
    model = SentenceTransformer('hackathon-pln-es/bertin-roberta-base-finetuning-esnli')
    model.eval()
    return model
    
st.title("Sentence Embedding for Spanish with Bertin")
st.write("Sentence embedding for spanish trained on NLI. Used for Sentence Textual Similarity. Based on the model hackathon-pln-es/bertin-roberta-base-finetuning-esnli.")

sent1 = st.text_area('Enter sentence 1')
sent2 = st.text_area('Enter sentence 2')

if st.button('Compute similarity'):
  if sent1 and sent2:
    model = load_model()
    encodings = model.encode([sent1, sent2])
    sim = cos_sim(encodings[0], encodings[1]).numpy().tolist()[0][0]
    st.text('Cosine Similarity: {0:.4f}'.format(sim))
  else:
      st.write('Missing a sentences')
else:
  pass