Views
No views yet
1from rankers import Cat
2import pyterrier as pt
3
4dataset = pt.get_dataset("irds:sara")
5
6# Index the corpus
7indexer = pt.IterDictIndexer('./indices/sara')
8indexer.index(dataset.get_corpus_iter())
9
10index_ref = pt.IndexRef.of('./indices/sara')
11bm25 = pt.BatchRetrieve(index_ref, wmodel='BM25')
12
13# Load the reranker
14reranker = Cat.from_pretrained("cost-sensitive-opt/sara_ce_ranknet_relevance").to_pyterrier()
15
16# Retrieval pipeline
17pipeline = bm25 % 10 >> dataset.text_loader() >> reranker
18
19pipeline.search("Your query goes here!")
20| qid | docid | docno | score | query | text | rank |
21|------:|--------:|:-------------------|---------:|:----------------------|:------------------------|-------:|
22| 1 | 5496 | badly-star-bat | -6.3265 | Your query goes here! | <!DOCTYPE HTML PUBLI... | 0 |
23| 1 | 90929 | namely-clean-horse | -7.01468 | Your query goes here! | -----Original Messag... | 1 |
24| 1 | 48895 | fully-pet-alpaca | -7.23318 | Your query goes here! | Anna, I just left yo... | 2 |
25| 1 | 72466 | lately-joint-fawn | -7.34253 | Your query goes here! | David, Here's the in... | 3 |
26| 1 | 126384 | wholly-proud-bison | -7.60162 | Your query goes here! | All - We have saved ... | 4 |
27| 1 | 43652 | firmly-well-dassie | -7.61348 | Your query goes here! | My impression is tha... | 5 |
28| 1 | 108431 | poorly-trusty-dove | -7.80046 | Your query goes here! | I got the queries to... | 6 |
29| 1 | 1998 | badly-big-pigeon | -7.92396 | Your query goes here! | Geoff, Attached is y... | 7 |
30| 1 | 114876 | safely-quick-gecko | -7.92852 | Your query goes here! | Casey, I ran curve q... | 8 |
31| 1 | 83963 | mainly-moving-ray | -8.26995 | Your query goes here! | -----Original Messag... | 9 |