77 <img alt="GitHub release" src="https://img.shields.io/github/release/beir-cellar/beir.svg">
88 </a>
99 <a href="https://www.python.org/">
10- <img alt="Build" src="https://img.shields.io/badge/Made%20with-Python-1f425f.svg? color=purple ">
10+ <img alt="Build" src="https://img.shields.io/pypi/pyversions/beir?logo=pypi&style=flat& color=blue ">
1111 </a>
1212 <a href="https://github.com/beir-cellar/beir/blob/master/LICENSE">
13- <img alt="License" src="https://img.shields.io/github/license/beir-cellar/beir.svg? color=green">
13+ <img alt="License" src="https://img.shields.io/github/license/beir-cellar/beir?logo=github&style=flat& color=green">
1414 </a>
1515 <a href="https://colab.research.google.com/drive/1HfutiEhHMJLXiWGT8pcipxT5L2TpYEdt?usp=sharing">
1616 <img alt="Open In Colab" src="https://colab.research.google.com/assets/colab-badge.svg">
1717 </a>
1818 <a href="https://pepy.tech/project/beir">
19- <img alt="Downloads" src="https://static.pepy.tech/personalized-badge/ beir?period=total&units=international_system&left_color=grey&right_color= orange&left_text=Downloads ">
19+ <img alt="Downloads" src="https://img.shields.io/pypi/dm/ beir?logo=pypi&style=flat&color= orange">
2020 </a>
2121 <a href="https://github.com/beir-cellar/beir/">
22- <img alt="Downloads " src="https://badges.frapsoft.com/os/v1/open-source.svg?v=103">
22+ <img alt="Open Source " src="https://badges.frapsoft.com/os/v1/open-source.svg?v=103">
2323 </a>
2424</p >
2525
@@ -59,7 +59,7 @@ For **Leaderboard**, checkout out **Eval AI** page: [https://eval.ai/web/challen
5959For more information, checkout out our publications:
6060
6161- [ BEIR: A Heterogenous Benchmark for Zero-shot Evaluation of Information Retrieval Models] ( https://openreview.net/forum?id=wCu6T5xFjeJ ) (NeurIPS 2021, Datasets and Benchmarks Track)
62- - [ Resources for Brewing BEIR: Reproducible Reference Models and an Official Leaderboard] ( https://arxiv. org/abs/2306.07471 ) (Arxiv 2023 )
62+ - [ Resources for Brewing BEIR: Reproducible Reference Models and an Official Leaderboard] ( https://dl.acm. org/doi/10.1145/3626772.3657862 ) (SIGIR 2024 Resource Track )
6363
6464## :beers : Installation
6565
@@ -77,7 +77,7 @@ $ cd beir
7777$ pip install - e .
7878```
7979
80- Tested with python versions 3.6 and 3.7
80+ Tested with python versions 3.9+
8181
8282## :beers : Features
8383
@@ -109,20 +109,37 @@ logging.basicConfig(format='%(asctime)s - %(message)s',
109109
110110# ### Download scifact.zip dataset and unzip the dataset
111111dataset = " scifact"
112- url = " https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets/{} .zip" .format(dataset)
112+ url = f " https://public.ukp.informatik.tu-darmstadt.de/thakur/BEIR/datasets/ { dataset } .zip "
113113out_dir = os.path.join(pathlib.Path(__file__ ).parent.absolute(), " datasets" )
114114data_path = util.download_and_unzip(url, out_dir)
115115
116116# ### Provide the data_path where scifact has been downloaded and unzipped
117117corpus, queries, qrels = GenericDataLoader(data_folder = data_path).load(split = " test" )
118118
119119# ### Load the SBERT model and retrieve using cosine-similarity
120- model = DRES(models.SentenceBERT(" msmarco-distilbert-base-tas-b" ), batch_size = 16 )
121- retriever = EvaluateRetrieval(model, score_function = " dot" ) # or "cos_sim" for cosine similarity
120+ model = DRES(models.SentenceBERT(" Alibaba-NLP/gte-modernbert-base" ), batch_size = 16 )
121+
122+ # ## Or load models directly from HuggingFace
123+ # model = DRES(models.HuggingFace(
124+ # "intfloat/e5-large-unsupervised",
125+ # max_length=512,
126+ # pooling="mean",
127+ # normalize=True,
128+ # prompts={"query": "query: ", "passage": "passage: "}), batch_size=16)
129+
130+ retriever = EvaluateRetrieval(model, score_function = " cos_sim" ) # or "dot" for dot product
122131results = retriever.retrieve(corpus, queries)
123132
124133# ### Evaluate your model with NDCG@k, MAP@K, Recall@K and Precision@K where k = [1,3,5,10,100,1000]
125134ndcg, _map, recall, precision = retriever.evaluate(qrels, results, retriever.k_values)
135+
136+ # ## If you want to save your results and runfile (useful for reranking)
137+ results_dir = os.path.join(pathlib.Path(__file__ ).parent.absolute(), " results" )
138+ os.makedirs(results_dir, exist_ok = True )
139+
140+ # ### Save the evaluation runfile & results
141+ util.save_runfile(os.path.join(results_dir, f " { dataset} .run.trec " ), results)
142+ util.save_results(os.path.join(results_dir, f " { dataset} .json " ), ndcg, _map, recall, precision, mrr)
126143```
127144
128145## :beers : Available Datasets
0 commit comments