File size: 743 Bytes
dd990bf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
"""Run: python examples/use.py  (network needed for first model download)."""
import json
from evidence_graph_reranker import EvidenceGraphReranker, rank_with_scores

query = "Who founded the company that released the Atlas device?"
with open("examples/passages.json", encoding="utf-8") as f:
    passages = json.load(f)

# Full pretrained MS MARCO -> graph reranking
reranker = EvidenceGraphReranker(backend="cross-encoder", device="cpu")
for passage in reranker.rank(query, passages, k=3):
    print(passage["index"], passage["title"], round(passage["step_score"], 4))

# If you already have neural relevance scores, the selector needs no checkpoint:
print([r["index"] for r in rank_with_scores(query, passages, [.91, .45, .20, .15], k=3)])