hacpdsae2023 commited on
Commit
ad3e5f6
·
1 Parent(s): 22605df

Adding most likely topic

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -1,5 +1,6 @@
1
  import streamlit as st
2
  import pandas as pd
 
3
 
4
  st.markdown('# Semantic search and topic classification (v1)')
5
  st.markdown(' - Author: hcontreras')
@@ -35,6 +36,14 @@ cos_scores = util.cos_sim(embedding_input_topic, embedding_sentence)[0][0]
35
 
36
  st.write('Score for topic', input_topic, ':', cos_scores.tolist())
37
 
 
 
 
 
 
 
 
 
38
  st.markdown('## ')
39
  uploaded_file1 = st.file_uploader("Choose a file: sentence list")
40
  if uploaded_file1 is not None:
 
1
  import streamlit as st
2
  import pandas as pd
3
+ import numpy as np
4
 
5
  st.markdown('# Semantic search and topic classification (v1)')
6
  st.markdown(' - Author: hcontreras')
 
36
 
37
  st.write('Score for topic', input_topic, ':', cos_scores.tolist())
38
 
39
+ l_scores = []
40
+ for topic in ['Space','Transportation','Health']:
41
+ embedding_input_topic = model.encode(topic)
42
+ cos_scores = util.cos_sim(embedding_input_topic, embedding_sentence)[0][0]
43
+ l_scores.append(cos_scores.tolist())
44
+
45
+ st.write('Most likely topic:', ['Space','Transportation','Health'][np.argmax(l_scores)])
46
+
47
  st.markdown('## ')
48
  uploaded_file1 = st.file_uploader("Choose a file: sentence list")
49
  if uploaded_file1 is not None: