Kuaaangwen commited on
Commit
fee5ced
·
1 Parent(s): 1750d29

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
app.py CHANGED
@@ -25,14 +25,15 @@ if submit_button:
25
 
26
  # Perform calculations
27
 
28
- sentence_embeddings = model.encode(sentences)
29
-
30
  sentences.append(sentence_1)
31
  sentences.append(sentence_2)
32
 
33
- for sentence, embedding in zip(sentences, sentence_embeddings):
34
- st.write("Sentence:", sentence)
35
- st.write("Embedding:", embedding)
36
- st.write("")
37
 
38
-
 
 
 
 
25
 
26
  # Perform calculations
27
 
28
+ # Append input sentences to 'sentences' list
 
29
  sentences.append(sentence_1)
30
  sentences.append(sentence_2)
31
 
32
+ # Create embeddings for both sentences
33
+ sentence_embeddings = model.encode(sentences)
34
+
 
35
 
36
+ st.write('Similarity between {} and {} is {}'.format(sentence_1,
37
+ sentence_2,
38
+ cosine_similarity(sentence_embeddings[0].reshape(1, -1),
39
+ sentence_embeddings[1].reshape(1, -1))[0][0]))