cmacdonald / pyterrier_bert

7 stars 8 forks source link

use BM25+RM3 with Passaging and CEDR #8

Open sarahgithu opened 2 years ago

sarahgithu commented 2 years ago

I'm trying to use BM25 and RM3 with passaging and CEDR (with this code)

`bm25_retr = pt.BatchRetrieve(index,wmodel="BM25", verbose=True, metadata=["docno", "body", "title"],num_results=100)

rm3 = pt.rewrite.RM3(index,fb_terms = 10,fb_docs=3,fb_lambda = 0.8)

rm3_qe = bm25_retr >> rm3 >> bm25_retr pipe_max_passage = rm3_qe >> \ SlidingWindowPassager(passage_length=150, passage_stride=75) >> \ CEDRPipeline(max_valid_rank=20) >> MaxPassage()

pipe_max_passage.fit(topicsTrain, qrelsTrain, topicsValid, qrelsTrain) `

and I got this error :

` in ----> 1 pipe_max_passage.fit(topicsTrain, qrelsTrain, topicsValid, qrelsTrain)

2 frames /usr/local/lib/python3.7/dist-packages/pyterrier/transformer.py in fit(self, topics_or_res_tr, qrels_tr, topics_or_res_va, qrels_va) 898 m.fit(topics_or_res_tr, qrels_tr, topics_or_res_va, qrels_va) 899 else: --> 900 topics_or_res_tr = m.transform(topics_or_res_tr) 901 # validation is optional for some learners 902 if topics_or_res_va is not None:

/usr/local/lib/python3.7/dist-packages/pyterrier/transformer.py in transform(self, topics) 885 def transform(self, topics): 886 for m in self.models: --> 887 topics = m.transform(topics) 888 return topics 889

/usr/local/lib/python3.7/dist-packages/pyterrier_bert/pyt_cedr.py in transform(self, queries_and_docs) 89 90 ---> 91 run_values = train.run_model(self.model, dataset, test_run, desc="CEDR") 92 run_df_rows = [] 93 for q, docs in run_values.items():

AttributeError: 'CEDRPipeline' object has no attribute 'model'`