ArthurChen189 commited on
Commit
4c54fb1
1 Parent(s): 23cefb2

update app

Browse files
app.py CHANGED
@@ -11,7 +11,7 @@ sys.path.append(str(path_root))
11
  encoder_index_map = {
12
  'uniCOIL': ('UniCoil', 'castorini/unicoil-noexp-msmarco-passage', 'index-unicoil'),
13
  'SPLADE++ Ensemble Distil': ('SpladePlusPlusEnsembleDistil', 'naver/splade-cocondenser-ensembledistil', 'index-splade-pp-ed'),
14
- 'SPLADE++ Self Distil': ('SpladePlusPlusSelfDistil', 'naver/splade-cocondenser-ensembledistil', 'index-splade-pp-sd')
15
  }
16
 
17
  index = 'index-splade-pp-ed'
@@ -65,7 +65,6 @@ with col2:
65
  if search_query or button_clicked:
66
  num_results = None
67
  t_0 = time.time()
68
- print("search query is:\t", search_query)
69
  search_results = searcher.search(search_query, k=10)
70
  search_time = time.time() - t_0
71
  st.write(
@@ -73,7 +72,12 @@ if search_query or button_clicked:
73
  for i, result in enumerate(search_results[:10]):
74
  result_score = result.score
75
  result_id = result.docid
76
- contents = json.loads(result.raw)["contents"]
 
 
 
 
 
77
  output = f'<div class="row"> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id} | <b>Score</b>:{result_score:.2f}</div>'
78
 
79
  try:
 
11
  encoder_index_map = {
12
  'uniCOIL': ('UniCoil', 'castorini/unicoil-noexp-msmarco-passage', 'index-unicoil'),
13
  'SPLADE++ Ensemble Distil': ('SpladePlusPlusEnsembleDistil', 'naver/splade-cocondenser-ensembledistil', 'index-splade-pp-ed'),
14
+ 'SPLADE++ Self Distil': ('SpladePlusPlusSelfDistil', 'naver/splade-cocondenser-selfdistil', 'index-splade-pp-sd')
15
  }
16
 
17
  index = 'index-splade-pp-ed'
 
65
  if search_query or button_clicked:
66
  num_results = None
67
  t_0 = time.time()
 
68
  search_results = searcher.search(search_query, k=10)
69
  search_time = time.time() - t_0
70
  st.write(
 
72
  for i, result in enumerate(search_results[:10]):
73
  result_score = result.score
74
  result_id = result.docid
75
+ if result.raw:
76
+ contents = json.loads(result.raw)
77
+ contents = contents['contents'] if 'contents' in contents else contents['content']
78
+ else:
79
+ contents = ''
80
+
81
  output = f'<div class="row"> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id} | <b>Score</b>:{result_score:.2f}</div>'
82
 
83
  try:
pyserini/search/lucene/__pycache__/_impact_searcher.cpython-310.pyc CHANGED
Binary files a/pyserini/search/lucene/__pycache__/_impact_searcher.cpython-310.pyc and b/pyserini/search/lucene/__pycache__/_impact_searcher.cpython-310.pyc differ
 
pyserini/search/lucene/_impact_searcher.py CHANGED
@@ -142,8 +142,9 @@ class LuceneImpactSearcher:
142
 
143
  encoded_query = self.encode(q)
144
 
145
- jquery = JHashMap()
146
  if self.encoder_type == 'pytorch':
 
147
  for (token, weight) in encoded_query.items():
148
  if token in self.idf and self.idf[token] > self.min_idf:
149
  jquery.put(token, JFloat(weight))
 
142
 
143
  encoded_query = self.encode(q)
144
 
145
+ jquery = encoded_query
146
  if self.encoder_type == 'pytorch':
147
+ jquery = JHashMap()
148
  for (token, weight) in encoded_query.items():
149
  if token in self.idf and self.idf[token] > self.min_idf:
150
  jquery.put(token, JFloat(weight))