mmazuecos commited on
Commit
5117017
·
1 Parent(s): e633815

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -8
app.py CHANGED
@@ -2,19 +2,21 @@ import streamlit as st
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.text('Cosine Similarity: {0:.4f}'.format(sim))
10
-
11
  st.title("Sentence Embedding for Spanish with Bertin")
12
  st.text("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
 
 
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
 
8
  sent1 = st.text_area('Enter sentence 1')
9
  sent2 = st.text_area('Enter sentence 2')
10
 
11
+ if st.button('Compute similarity'):
12
+ if sent1 and sent2:
13
+ model = SentenceTransformer('hackathon-pln-es/bertin-roberta-base-finetuning-esnli')
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))
17
+ else:
18
+ st.write('Missing a sentences')
19
+ else:
20
+ pass
21
 
22