hacpdsae2023 commited on
Commit
4b945ef
·
1 Parent(s): 376e087

Adding the score relative to the selected topic

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -22,15 +22,18 @@ sentence = ['This framework generates embeddings for each input sentence']
22
 
23
 
24
  #Sentences are encoded by calling model.encode()
25
- embedding_sentence = model.encode([input_sentence])
26
  embedding_topics = model.encode(['Space','Transportation','Health'])
 
27
 
28
  #x = st.slider('Select a value')
29
  #embedding = model.encode(input_sentence)
30
  #st.write(x, 'squared is', x * x, 'embedding', embedding[0][0])
31
  #st.write('The embedding of', '"' + input_sentence + '"', 'at position',x,'is',embedding[0][int(x)])
32
 
33
- st.write('Score for topic', input_topic, ':')
 
 
34
 
35
  st.markdown('## ')
36
  uploaded_file1 = st.file_uploader("Choose a file: sentence list")
 
22
 
23
 
24
  #Sentences are encoded by calling model.encode()
25
+ embedding_sentence = model.encode(input_sentence)
26
  embedding_topics = model.encode(['Space','Transportation','Health'])
27
+ embedding_input_topic = model.encode(input_topic)
28
 
29
  #x = st.slider('Select a value')
30
  #embedding = model.encode(input_sentence)
31
  #st.write(x, 'squared is', x * x, 'embedding', embedding[0][0])
32
  #st.write('The embedding of', '"' + input_sentence + '"', 'at position',x,'is',embedding[0][int(x)])
33
 
34
+ cos_scores = util.cos_sim(embedding_input_topic, embedding_sentence)[0]
35
+
36
+ st.write('Score for topic', input_topic, ':', cos_scores)
37
 
38
  st.markdown('## ')
39
  uploaded_file1 = st.file_uploader("Choose a file: sentence list")