zhichyu commited on
Commit
bcf5fd5
·
1 Parent(s): 4597c28

Fix graphrag + infinity bugs (#3681)

Browse files

### What problem does this PR solve?

Fix graphrag + infinity bugs

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

graphrag/search.py CHANGED
@@ -59,8 +59,8 @@ class KGSearch(Dealer):
59
  q_vec = matchDense.embedding_data
60
  src = req.get("fields", ["docnm_kwd", "content_ltks", "kb_id", "img_id", "title_tks", "important_kwd",
61
  "doc_id", f"q_{len(q_vec)}_vec", "position_list", "name_kwd",
62
- "q_1024_vec", "q_1536_vec", "available_int", "content_with_weight",
63
- "weight_int", "weight_flt", "rank_int"
64
  ])
65
 
66
  fusionExpr = FusionExpr("weighted_sum", 32, {"weights": "0.5, 0.5"})
 
59
  q_vec = matchDense.embedding_data
60
  src = req.get("fields", ["docnm_kwd", "content_ltks", "kb_id", "img_id", "title_tks", "important_kwd",
61
  "doc_id", f"q_{len(q_vec)}_vec", "position_list", "name_kwd",
62
+ "available_int", "content_with_weight",
63
+ "weight_int", "weight_flt"
64
  ])
65
 
66
  fusionExpr = FusionExpr("weighted_sum", 32, {"weights": "0.5, 0.5"})
rag/svr/task_executor.py CHANGED
@@ -114,6 +114,7 @@ def set_progress(task_id, from_page=0, to_page=-1, prog=None, msg="Processing...
114
  if prog is not None:
115
  d["progress"] = prog
116
  try:
 
117
  TaskService.update_progress(task_id, d)
118
  except Exception:
119
  logging.exception(f"set_progress({task_id}) got exception")
 
114
  if prog is not None:
115
  d["progress"] = prog
116
  try:
117
+ logging.info(f"set_progress({task_id}), progress: {prog}, progress_msg: {msg}")
118
  TaskService.update_progress(task_id, d)
119
  except Exception:
120
  logging.exception(f"set_progress({task_id}) got exception")
rag/utils/es_conn.py CHANGED
@@ -148,9 +148,9 @@ class ESConnection(DocStoreConnection):
148
  vector_similarity_weight = float(weights.split(",")[1])
149
  for m in matchExprs:
150
  if isinstance(m, MatchTextExpr):
151
- minimum_should_match = "0%"
152
- if "minimum_should_match" in m.extra_options:
153
- minimum_should_match = str(int(m.extra_options["minimum_should_match"] * 100)) + "%"
154
  bqry.must.append(Q("query_string", fields=m.fields,
155
  type="best_fields", query=m.matching_text,
156
  minimum_should_match=minimum_should_match,
 
148
  vector_similarity_weight = float(weights.split(",")[1])
149
  for m in matchExprs:
150
  if isinstance(m, MatchTextExpr):
151
+ minimum_should_match = m.extra_options.get("minimum_should_match", 0.0)
152
+ if isinstance(minimum_should_match, float):
153
+ minimum_should_match = str(int(minimum_should_match * 100)) + "%"
154
  bqry.must.append(Q("query_string", fields=m.fields,
155
  type="best_fields", query=m.matching_text,
156
  minimum_should_match=minimum_should_match,
rag/utils/infinity_conn.py CHANGED
@@ -231,15 +231,10 @@ class InfinityConnection(DocStoreConnection):
231
  if len(filter_cond) != 0:
232
  filter_fulltext = f"({filter_cond}) AND {filter_fulltext}"
233
  logging.debug(f"filter_fulltext: {filter_fulltext}")
234
- minimum_should_match = "0%"
235
- if "minimum_should_match" in matchExpr.extra_options:
236
- minimum_should_match = (
237
- str(int(matchExpr.extra_options["minimum_should_match"] * 100))
238
- + "%"
239
- )
240
- matchExpr.extra_options.update(
241
- {"minimum_should_match": minimum_should_match}
242
- )
243
  for k, v in matchExpr.extra_options.items():
244
  if not isinstance(v, str):
245
  matchExpr.extra_options[k] = str(v)
 
231
  if len(filter_cond) != 0:
232
  filter_fulltext = f"({filter_cond}) AND {filter_fulltext}"
233
  logging.debug(f"filter_fulltext: {filter_fulltext}")
234
+ minimum_should_match = matchExpr.extra_options.get("minimum_should_match", 0.0)
235
+ if isinstance(minimum_should_match, float):
236
+ str_minimum_should_match = str(int(minimum_should_match * 100)) + "%"
237
+ matchExpr.extra_options["minimum_should_match"] = str_minimum_should_match
 
 
 
 
 
238
  for k, v in matchExpr.extra_options.items():
239
  if not isinstance(v, str):
240
  matchExpr.extra_options[k] = str(v)