Spaces:
Runtime error
Runtime error
Updated app.py
Browse files
app.py
CHANGED
@@ -21,42 +21,49 @@ st.title(" Your Top 3 Important Sessions")
|
|
21 |
st.markdown("This application is a dashboard for displaying your top 3 Sessions at the summit")
|
22 |
|
23 |
doc_emb = np.loadtxt("abstract-embed.txt", dtype=float)
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
32 |
# Query
|
33 |
-
|
|
|
|
|
|
|
34 |
|
|
|
|
|
|
|
35 |
#Encode query and documents
|
36 |
-
query_emb = model.encode(query).astype(float)
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
#
|
39 |
-
|
40 |
|
41 |
-
|
42 |
-
doc_score_pairs = list(zip(docs, scores, titles, start_times, end_times, locations))
|
43 |
|
44 |
-
#
|
45 |
-
|
46 |
-
print(" Your top", top_k, "most similar sessions in the Summit:")
|
47 |
|
48 |
-
#Sort by decreasing score
|
49 |
-
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
|
50 |
|
|
|
|
|
51 |
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
print("Location: %s" %location)
|
59 |
-
f"From {start_time} to {end_time}"
|
60 |
-
print('\n')
|
61 |
-
|
62 |
-
|
|
|
21 |
st.markdown("This application is a dashboard for displaying your top 3 Sessions at the summit")
|
22 |
|
23 |
doc_emb = np.loadtxt("abstract-embed.txt", dtype=float)
|
24 |
+
def main():
|
25 |
+
# display the front end aspect
|
26 |
+
st.markdown(html_temp, unsafe_allow_html = True)
|
27 |
+
|
28 |
+
# Get attributes from dataframe
|
29 |
+
docs = list(df["Description"])
|
30 |
+
titles = list(df["Name"])
|
31 |
+
start_times = list(df["Start Time"])
|
32 |
+
end_times = list(df["End Time"])
|
33 |
+
locations = list(df["Location Name"])
|
34 |
# Query
|
35 |
+
# Load model
|
36 |
+
model = SentenceTransformer('sentence-transformers/multi-qa-MiniLM-L6-cos-v1')
|
37 |
+
|
38 |
+
query = st.text_input("Enter your query: ")
|
39 |
|
40 |
+
if query:
|
41 |
+
#st.text_area('Text area')
|
42 |
+
#age = st.number_input("Age in Years")
|
43 |
#Encode query and documents
|
44 |
+
query_emb = model.encode(query).astype(float)
|
45 |
+
|
46 |
+
#Compute dot score between query and all document embeddings
|
47 |
+
scores = util.dot_score(query_emb, doc_emb.astype(float))[0].cpu().tolist()
|
48 |
+
|
49 |
+
#Combine docs & scores with other attributes
|
50 |
+
doc_score_pairs = list(zip(docs, scores, titles, start_times, end_times, locations))
|
51 |
|
52 |
+
# top_k results to return
|
53 |
+
top_k=3
|
54 |
|
55 |
+
print(" Your top", top_k, "most similar sessions in the Summit:")
|
|
|
56 |
|
57 |
+
#Sort by decreasing score
|
58 |
+
doc_score_pairs = sorted(doc_score_pairs, key=lambda x: x[1], reverse=True)
|
|
|
59 |
|
|
|
|
|
60 |
|
61 |
+
#Output presentation recommendations
|
62 |
+
for doc, score, title, start_time, end_time, location in doc_score_pairs[:top_k]:
|
63 |
|
64 |
+
st.write("Score: %f" %score)
|
65 |
+
st.write("Title: %s" %title)
|
66 |
+
st.write("Abstract: %s" %doc)
|
67 |
+
st.write("Location: %s" %location)
|
68 |
+
st.write(f"From {start_time} to {end_time}")
|
69 |
+
st.write('\n')
|
|
|
|
|
|
|
|
|
|