HarryLee commited on
Commit
62b04b6
·
1 Parent(s): 4206bd7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -11
app.py CHANGED
@@ -14,14 +14,14 @@ import pickle
14
  ## Main page
15
  ############
16
 
17
- st.write("# Code for Query Expansion")
18
 
19
  st.markdown("***Idea is to build a model which will take query as inputs and generate expansion information as outputs.***")
20
  image = Image.open('top.png')
21
  st.image(image)
22
 
23
- #st.sidebar.write("# Parameter Selection")
24
- #maxtags_sidebar = st.sidebar.slider('Number of query allowed?', 1, 10, 1, key='ehikwegrjifbwreuk')
25
  #user_query = st_tags(
26
  # label='# Enter Query:',
27
  # text='Press enter to add more',
@@ -83,21 +83,21 @@ def search(query):
83
  for idx in range(len(cross_scores)):
84
  hits[idx]['cross-score'] = cross_scores[idx]
85
 
86
- # Output of top-10 hits from bi-encoder
87
  st.write("\n-------------------------\n")
88
- st.write("Top-10 Bi-Encoder Retrieval hits")
89
  hits = sorted(hits, key=lambda x: x['score'], reverse=True)
90
- for hit in hits[0:10]:
91
  st.write("\t{:.3f}\t{}".format(hit['score'], passages[hit['corpus_id']].replace("\n", " ")))
92
 
93
- # Output of top-10 hits from re-ranker
94
  st.write("\n-------------------------\n")
95
- st.write("Top-10 Cross-Encoder Re-ranker hits")
96
  hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
97
- for hit in hits[0:10]:
98
  st.write("\t{:.3f}\t{}".format(hit['cross-score'], passages[hit['corpus_id']].replace("\n", " ")))
99
 
100
  st.write("## Results:")
101
- if st.button('Generate Sentence'):
102
  out = search(query = user_query)
103
- #st.success(out)
 
14
  ## Main page
15
  ############
16
 
17
+ st.write("# Demonstration for Etsy Query Expansion(Etsy-QE)")
18
 
19
  st.markdown("***Idea is to build a model which will take query as inputs and generate expansion information as outputs.***")
20
  image = Image.open('top.png')
21
  st.image(image)
22
 
23
+ st.sidebar.write("# Top-N Selection")
24
+ maxtags_sidebar = st.sidebar.slider('Number of query allowed?', 1, 20, 1, key='ehikwegrjifbwreuk')
25
  #user_query = st_tags(
26
  # label='# Enter Query:',
27
  # text='Press enter to add more',
 
83
  for idx in range(len(cross_scores)):
84
  hits[idx]['cross-score'] = cross_scores[idx]
85
 
86
+ # Output of top-N hits from bi-encoder
87
  st.write("\n-------------------------\n")
88
+ st.write("Top-N Bi-Encoder Retrieval hits")
89
  hits = sorted(hits, key=lambda x: x['score'], reverse=True)
90
+ for hit in hits[0:maxtags_sidebar]:
91
  st.write("\t{:.3f}\t{}".format(hit['score'], passages[hit['corpus_id']].replace("\n", " ")))
92
 
93
+ # Output of top-N hits from re-ranker
94
  st.write("\n-------------------------\n")
95
+ st.write("Top-N Cross-Encoder Re-ranker hits")
96
  hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
97
+ for hit in hits[0:maxtags_sidebar]:
98
  st.write("\t{:.3f}\t{}".format(hit['cross-score'], passages[hit['corpus_id']].replace("\n", " ")))
99
 
100
  st.write("## Results:")
101
+ if st.button('Generated Expansion'):
102
  out = search(query = user_query)
103
+ st.success(out)