Remove DPR fallback
Browse files
src/passage_entity/retriever.py
CHANGED
|
@@ -387,12 +387,18 @@ class PassageEntityRetriever:
|
|
| 387 |
self.rerank_time += time.time() - rerank_t0
|
| 388 |
|
| 389 |
if len(top_facts) == 0:
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
|
| 397 |
top_docs = [
|
| 398 |
self.chunk_store.get_row(self.passage_node_keys[idx])["content"]
|
|
|
|
| 387 |
self.rerank_time += time.time() - rerank_t0
|
| 388 |
|
| 389 |
if len(top_facts) == 0:
|
| 390 |
+
# Reranker rejected all facts — use top facts by embedding score
|
| 391 |
+
logger.info("No facts after reranking -> using top facts by embedding score")
|
| 392 |
+
link_top_k = self.config.linking_top_k
|
| 393 |
+
if len(fact_scores) > 0:
|
| 394 |
+
top_indices = np.argsort(fact_scores)[-link_top_k:][::-1].tolist()
|
| 395 |
+
real_ids = [self.fact_node_keys[i] for i in top_indices]
|
| 396 |
+
rows = self.fact_store.get_rows(real_ids)
|
| 397 |
+
top_facts = [eval(rows[rid]["content"]) for rid in real_ids]
|
| 398 |
+
|
| 399 |
+
sorted_ids, sorted_scores = self._graph_search(
|
| 400 |
+
q, fact_scores, top_facts, top_indices
|
| 401 |
+
)
|
| 402 |
|
| 403 |
top_docs = [
|
| 404 |
self.chunk_store.get_row(self.passage_node_keys[idx])["content"]
|