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_csadrmse_sans").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 | 126384 | wholly-proud-bison | -9.86728 | Your query goes here! | All - We have saved ... | 0 |
23| 1 | 90929 | namely-clean-horse | -10.2112 | Your query goes here! | -----Original Messag... | 1 |
24| 1 | 108431 | poorly-trusty-dove | -10.4667 | Your query goes here! | I got the queries to... | 2 |
25| 1 | 83963 | mainly-moving-ray | -10.6175 | Your query goes here! | -----Original Messag... | 3 |
26| 1 | 114876 | safely-quick-gecko | -10.8912 | Your query goes here! | Casey, I ran curve q... | 4 |
27| 1 | 1998 | badly-big-pigeon | -10.9679 | Your query goes here! | Geoff, Attached is y... | 5 |
28| 1 | 5496 | badly-star-bat | -11.0066 | Your query goes here! | <!DOCTYPE HTML PUBLI... | 6 |
29| 1 | 48895 | fully-pet-alpaca | -11.3932 | Your query goes here! | Anna, I just left yo... | 7 |
30| 1 | 72466 | lately-joint-fawn | -12.4583 | Your query goes here! | David, Here's the in... | 8 |
31| 1 | 43652 | firmly-well-dassie | -16.6341 | Your query goes here! | My impression is tha... | 9 |