|
---
|
|
configs:
|
|
- config_name: arguana-corpus
|
|
data_files:
|
|
- split: train
|
|
path: arguana/corpus/*
|
|
- config_name: arguana-queries
|
|
data_files:
|
|
- split: test
|
|
path: arguana/queries/test.parquet
|
|
- config_name: arguana-qrels
|
|
data_files:
|
|
- split: test
|
|
path: arguana/qrels/test.parquet
|
|
- config_name: bioasq-corpus
|
|
data_files:
|
|
- split: train
|
|
path: bioasq/corpus/*
|
|
- config_name: bioasq-queries
|
|
data_files:
|
|
- split: train
|
|
path: bioasq/queries/train.parquet
|
|
- split: test
|
|
path: bioasq/queries/test.parquet
|
|
- config_name: bioasq-qrels
|
|
data_files:
|
|
- split: train
|
|
path: bioasq/qrels/train.parquet
|
|
- split: test
|
|
path: bioasq/qrels/test.parquet
|
|
- config_name: climate-fever-corpus
|
|
data_files:
|
|
- split: train
|
|
path: climate-fever/corpus/*
|
|
- config_name: climate-fever-queries
|
|
data_files:
|
|
- split: test
|
|
path: climate-fever/queries/test.parquet
|
|
- config_name: climate-fever-qrels
|
|
data_files:
|
|
- split: test
|
|
path: climate-fever/qrels/test.parquet
|
|
- config_name: cqadupstack-android-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-android/corpus/*
|
|
- config_name: cqadupstack-android-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-android/queries/test.parquet
|
|
- config_name: cqadupstack-android-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-android/qrels/test.parquet
|
|
- config_name: cqadupstack-english-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-english/corpus/*
|
|
- config_name: cqadupstack-english-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-english/queries/test.parquet
|
|
- config_name: cqadupstack-english-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-english/qrels/test.parquet
|
|
- config_name: cqadupstack-gaming-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-gaming/corpus/*
|
|
- config_name: cqadupstack-gaming-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-gaming/queries/test.parquet
|
|
- config_name: cqadupstack-gaming-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-gaming/qrels/test.parquet
|
|
- config_name: cqadupstack-gis-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-gis/corpus/*
|
|
- config_name: cqadupstack-gis-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-gis/queries/test.parquet
|
|
- config_name: cqadupstack-gis-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-gis/qrels/test.parquet
|
|
- config_name: cqadupstack-mathematica-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-mathematica/corpus/*
|
|
- config_name: cqadupstack-mathematica-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-mathematica/queries/test.parquet
|
|
- config_name: cqadupstack-mathematica-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-mathematica/qrels/test.parquet
|
|
- config_name: cqadupstack-physics-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-physics/corpus/*
|
|
- config_name: cqadupstack-physics-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-physics/queries/test.parquet
|
|
- config_name: cqadupstack-physics-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-physics/qrels/test.parquet
|
|
- config_name: cqadupstack-programmers-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-programmers/corpus/*
|
|
- config_name: cqadupstack-programmers-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-programmers/queries/test.parquet
|
|
- config_name: cqadupstack-programmers-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-programmers/qrels/test.parquet
|
|
- config_name: cqadupstack-stats-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-stats/corpus/*
|
|
- config_name: cqadupstack-stats-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-stats/queries/test.parquet
|
|
- config_name: cqadupstack-stats-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-stats/qrels/test.parquet
|
|
- config_name: cqadupstack-text-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-text/corpus/*
|
|
- config_name: cqadupstack-text-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-text/queries/test.parquet
|
|
- config_name: cqadupstack-text-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-text/qrels/test.parquet
|
|
- config_name: cqadupstack-unix-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-unix/corpus/*
|
|
- config_name: cqadupstack-unix-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-unix/queries/test.parquet
|
|
- config_name: cqadupstack-unix-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-unix/qrels/test.parquet
|
|
- config_name: cqadupstack-webmasters-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-webmasters/corpus/*
|
|
- config_name: cqadupstack-webmasters-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-webmasters/queries/test.parquet
|
|
- config_name: cqadupstack-webmasters-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-webmasters/qrels/test.parquet
|
|
- config_name: cqadupstack-wordpress-corpus
|
|
data_files:
|
|
- split: train
|
|
path: cqadupstack-wordpress/corpus/*
|
|
- config_name: cqadupstack-wordpress-queries
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-wordpress/queries/test.parquet
|
|
- config_name: cqadupstack-wordpress-qrels
|
|
data_files:
|
|
- split: test
|
|
path: cqadupstack-wordpress/qrels/test.parquet
|
|
- config_name: fever-corpus
|
|
data_files:
|
|
- split: train
|
|
path: fever/corpus/*
|
|
- config_name: fever-queries
|
|
data_files:
|
|
- split: train
|
|
path: fever/queries/train.parquet
|
|
- split: dev
|
|
path: fever/queries/dev.parquet
|
|
- split: test
|
|
path: fever/queries/test.parquet
|
|
- config_name: fever-qrels
|
|
data_files:
|
|
- split: train
|
|
path: fever/qrels/train.parquet
|
|
- split: dev
|
|
path: fever/qrels/dev.parquet
|
|
- split: test
|
|
path: fever/qrels/test.parquet
|
|
- config_name: fiqa-corpus
|
|
data_files:
|
|
- split: train
|
|
path: fiqa/corpus/*
|
|
- config_name: fiqa-queries
|
|
data_files:
|
|
- split: train
|
|
path: fiqa/queries/train.parquet
|
|
- split: dev
|
|
path: fiqa/queries/dev.parquet
|
|
- split: all
|
|
path: fiqa/queries/all.parquet
|
|
- split: test
|
|
path: fiqa/queries/test.parquet
|
|
- config_name: fiqa-qrels
|
|
data_files:
|
|
- split: train
|
|
path: fiqa/qrels/train.parquet
|
|
- split: dev
|
|
path: fiqa/qrels/dev.parquet
|
|
- split: all
|
|
path: fiqa/qrels/all.parquet
|
|
- split: test
|
|
path: fiqa/qrels/test.parquet
|
|
- config_name: hotpotqa-corpus
|
|
data_files:
|
|
- split: train
|
|
path: hotpotqa/corpus/*
|
|
- config_name: hotpotqa-queries
|
|
data_files:
|
|
- split: train
|
|
path: hotpotqa/queries/train.parquet
|
|
- split: dev
|
|
path: hotpotqa/queries/dev.parquet
|
|
- split: test
|
|
path: hotpotqa/queries/test.parquet
|
|
- config_name: hotpotqa-qrels
|
|
data_files:
|
|
- split: train
|
|
path: hotpotqa/qrels/train.parquet
|
|
- split: dev
|
|
path: hotpotqa/qrels/dev.parquet
|
|
- split: test
|
|
path: hotpotqa/qrels/test.parquet
|
|
- config_name: msmarco-corpus
|
|
data_files:
|
|
- split: train
|
|
path: msmarco/corpus/*
|
|
- config_name: msmarco-queries
|
|
data_files:
|
|
- split: train
|
|
path: msmarco/queries/train.parquet
|
|
- split: dev
|
|
path: msmarco/queries/dev.parquet
|
|
- config_name: msmarco-qrels
|
|
data_files:
|
|
- split: train
|
|
path: msmarco/qrels/train.parquet
|
|
- split: dev
|
|
path: msmarco/qrels/dev.parquet
|
|
- config_name: nfcorpus-corpus
|
|
data_files:
|
|
- split: train
|
|
path: nfcorpus/corpus/*
|
|
- config_name: nfcorpus-queries
|
|
data_files:
|
|
- split: train
|
|
path: nfcorpus/queries/train.parquet
|
|
- split: dev
|
|
path: nfcorpus/queries/dev.parquet
|
|
- split: test
|
|
path: nfcorpus/queries/test.parquet
|
|
- config_name: nfcorpus-qrels
|
|
data_files:
|
|
- split: train
|
|
path: nfcorpus/qrels/train.parquet
|
|
- split: dev
|
|
path: nfcorpus/qrels/dev.parquet
|
|
- split: test
|
|
path: nfcorpus/qrels/test.parquet
|
|
- config_name: nq-corpus
|
|
data_files:
|
|
- split: train
|
|
path: nq/corpus/*
|
|
- config_name: nq-queries
|
|
data_files:
|
|
- split: test
|
|
path: nq/queries/test.parquet
|
|
- config_name: nq-qrels
|
|
data_files:
|
|
- split: test
|
|
path: nq/qrels/test.parquet
|
|
- config_name: quora-corpus
|
|
data_files:
|
|
- split: train
|
|
path: quora/corpus/*
|
|
- config_name: quora-queries
|
|
data_files:
|
|
- split: dev
|
|
path: quora/queries/dev.parquet
|
|
- split: test
|
|
path: quora/queries/test.parquet
|
|
- config_name: quora-qrels
|
|
data_files:
|
|
- split: dev
|
|
path: quora/qrels/dev.parquet
|
|
- split: test
|
|
path: quora/qrels/test.parquet
|
|
- config_name: robust04-corpus
|
|
data_files:
|
|
- split: train
|
|
path: robust04/corpus/*
|
|
- config_name: robust04-queries
|
|
data_files:
|
|
- split: test
|
|
path: robust04/queries/test.parquet
|
|
- config_name: robust04-qrels
|
|
data_files:
|
|
- split: test
|
|
path: robust04/qrels/test.parquet
|
|
- config_name: scidocs-corpus
|
|
data_files:
|
|
- split: train
|
|
path: scidocs/corpus/*
|
|
- config_name: scidocs-queries
|
|
data_files:
|
|
- split: test
|
|
path: scidocs/queries/test.parquet
|
|
- config_name: scidocs-qrels
|
|
data_files:
|
|
- split: test
|
|
path: scidocs/qrels/test.parquet
|
|
- config_name: scifact-corpus
|
|
data_files:
|
|
- split: train
|
|
path: scifact/corpus/*
|
|
- config_name: scifact-queries
|
|
data_files:
|
|
- split: train
|
|
path: scifact/queries/train.parquet
|
|
- split: test
|
|
path: scifact/queries/test.parquet
|
|
- config_name: scifact-qrels
|
|
data_files:
|
|
- split: train
|
|
path: scifact/qrels/train.parquet
|
|
- split: test
|
|
path: scifact/qrels/test.parquet
|
|
- config_name: signal1m-corpus
|
|
data_files:
|
|
- split: train
|
|
path: signal1m/corpus/*
|
|
- config_name: signal1m-queries
|
|
data_files:
|
|
- split: test
|
|
path: signal1m/queries/test.parquet
|
|
- config_name: signal1m-qrels
|
|
data_files:
|
|
- split: test
|
|
path: signal1m/qrels/test.parquet
|
|
- config_name: trec-covid-corpus
|
|
data_files:
|
|
- split: train
|
|
path: trec-covid/corpus/*
|
|
- config_name: trec-covid-queries
|
|
data_files:
|
|
- split: test
|
|
path: trec-covid/queries/test.parquet
|
|
- config_name: trec-covid-qrels
|
|
data_files:
|
|
- split: test
|
|
path: trec-covid/qrels/test.parquet
|
|
- config_name: trec-news-corpus
|
|
data_files:
|
|
- split: train
|
|
path: trec-news/corpus/*
|
|
- config_name: trec-news-queries
|
|
data_files:
|
|
- split: test
|
|
path: trec-news/queries/test.parquet
|
|
- config_name: trec-news-qrels
|
|
data_files:
|
|
- split: test
|
|
path: trec-news/qrels/test.parquet
|
|
- config_name: webis-touche2020-corpus
|
|
data_files:
|
|
- split: train
|
|
path: webis-touche2020/corpus/*
|
|
- config_name: webis-touche2020-queries
|
|
data_files:
|
|
- split: test
|
|
path: webis-touche2020/queries/test.parquet
|
|
- config_name: webis-touche2020-qrels
|
|
data_files:
|
|
- split: test
|
|
path: webis-touche2020/qrels/test.parquet
|
|
---
|
|
|
|
# BEIR embeddings with Cohere embed-english-v3.0 model
|
|
|
|
This datasets contains all query & document embeddings for [BEIR](https://github.com/beir-cellar/beir), embedded with the [Cohere embed-english-v3.0](https://huggingface.co/Cohere/Cohere-embed-english-v3.0) embedding model.
|
|
|
|
|
|
## Overview of datasets
|
|
|
|
This repository hosts all 18 datasets from BEIR, including query and document embeddings. The following table gives an overview of the available datasets.
|
|
See the next section how to load the individual datasets.
|
|
|
|
| Dataset | nDCG@10 | #Documents
|
|
| --- | --- | --- |
|
|
| arguana | 53.98 | 8,674 |
|
|
| bioasq | 45.66 | 14,914,603 |
|
|
| climate-fever | 25.90 | 5,416,593 |
|
|
| cqadupstack-android | 50.01 | 22,998 |
|
|
| cqadupstack-english | 49.09 | 40,221 |
|
|
| cqadupstack-gaming | 60.50 | 45,301 |
|
|
| cqadupstack-gis | 39.17 | 37,637 |
|
|
| cqadupstack-mathematica | 30.38 | 16,705 |
|
|
| cqadupstack-physics | 43.82 | 38,316 |
|
|
| cqadupstack-programmers | 43.67 | 32,176 |
|
|
| cqadupstack-stats | 35.23 | 42,269 |
|
|
| cqadupstack-text | 30.84 | 68,184 |
|
|
| cqadupstack-unix | 40.59 | 47,382 |
|
|
| cqadupstack-webmasters | 40.68 | 17,405 |
|
|
| cqadupstack-wordpress | 34.26 | 48,605 |
|
|
| fever | 89.00 | 5,416,568 |
|
|
| fiqa | 42.14 | 57,638 |
|
|
| hotpotqa | 70.72 | 5,233,329 |
|
|
| msmarco | 42.86 | 8,841,823 |
|
|
| nfcorpus | 38.63 | 3,633 |
|
|
| nq | 61.62 | 2,681,468 |
|
|
| quora | 88.72 | 522,931 |
|
|
| robust04 | 54.06 | 528,155 |
|
|
| scidocs | 20.34 | 25,657 |
|
|
| scifact | 71.81 | 5,183 |
|
|
| signal1m | 26.32 | 2,866,316 |
|
|
| trec-covid | 81.78 | 171,332 |
|
|
| trec-news | 50.42 | 594,977 |
|
|
| webis-touche2020 | 32.64 | 382,545 |
|
|
|
|
Notes:
|
|
- arguana: The task of arguana is to find for a given argument (e.g. `Being vegetarian helps the environment ...`), an argument that refutes it (e.g. `Vegetarian doesn't have an impact on the environment`). Naturally, embedding models work by finding the most similar texts, hence for the given argument it would find similar arguments first that support that `vegetarian helps the environment`, which would be treated as non-relevant. By embedding model prompting, the model can be steered to find arguments that refute the query. This will improve the nDCG@10 score from 53.98 to 61.5.
|
|
- climate-fever: The task is to find evidence that support or refute a claim. As with arguana, with the default mode, the model will find the evidence primarily supporting the claim. By embedding model prompting, we can tell the model to find support and contra evidence for a claim. This improves the nDCG@10 score to 38.4.
|
|
- Quora: As the corpus consists of questions, they have been encoded with the `input_type='search_query'` in order to find similar/duplicate questions.
|
|
- cqadupstack: The datasets consists of several sub-datasets, where the nDCG@10 scores will be averaged in BEIR.
|
|
- bioasq/robust04/trec-news/signal1m: For these datasets we just provide the IDs and the embeddings, but not title/text fields. See the [BEIR repository](https://github.com/beir-cellar/beir) how to obtain the respective text corpora. You can still evaluate search quality on these datasets.
|
|
|
|
|
|
## Loading the dataset
|
|
|
|
### Loading the document embeddings
|
|
The `corpus` split contains all document embeddings of the corpus.
|
|
|
|
You can either load the dataset like this:
|
|
```python
|
|
from datasets import load_dataset
|
|
dataset_name = "hotpotqa"
|
|
docs = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-corpus", split="train")
|
|
```
|
|
|
|
Or you can also stream it without downloading it before:
|
|
```python
|
|
from datasets import load_dataset
|
|
dataset_name = "hotpotqa"
|
|
docs = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-corpus", split="train", streaming=True)
|
|
for doc in docs:
|
|
doc_id = doc['_id']
|
|
title = doc['title']
|
|
text = doc['text']
|
|
emb = doc['emb']
|
|
```
|
|
|
|
Note, depending on the dataset size, the corpus split can be quite large.
|
|
|
|
### Loading the query embeddings
|
|
The `queries` split contains all query embeddings. There might be up to three splits: `train`, `dev`, and `test`, depending which splits are available in BEIR. Evaluation is performed on the `test` split.
|
|
|
|
You can load the dataset like this:
|
|
```python
|
|
from datasets import load_dataset
|
|
dataset_name = "hotpotqa"
|
|
queries = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-queries", split="test")
|
|
|
|
for query in queries:
|
|
query_id = query['_id']
|
|
text = query['text']
|
|
emb = query['emb']
|
|
```
|
|
|
|
|
|
### Loading the qrels
|
|
|
|
The `qrels` split contains the query relevance annotation, i.e., it contains the relevance score for (query, document) pairs.
|
|
|
|
|
|
You can load the dataset like this:
|
|
```python
|
|
from datasets import load_dataset
|
|
dataset_name = "hotpotqa"
|
|
qrels = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-qrels", split="test")
|
|
|
|
for qrel in qrels:
|
|
query_id = qrel['query_id']
|
|
corpus_id = qrel['corpus_id']
|
|
score = qrel['score']
|
|
```
|
|
|
|
## Search
|
|
The following shows an example, how the dataset can be used to build a semantic search application.
|
|
|
|
Get your API key from [cohere.com](https://cohere.com) and start using this dataset.
|
|
|
|
```python
|
|
#Run: pip install cohere datasets torch
|
|
from datasets import load_dataset
|
|
import torch
|
|
import cohere
|
|
dataset_name = "hotpotqa"
|
|
co = cohere.Client("<<COHERE_API_KEY>>") # Add your cohere API key from www.cohere.com
|
|
|
|
#Load at max 1000 documents + embeddings
|
|
max_docs = 1000
|
|
docs_stream = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-corpus", split="train", streaming=True)
|
|
docs = []
|
|
doc_embeddings = []
|
|
for doc in docs_stream:
|
|
docs.append(doc)
|
|
doc_embeddings.append(doc['emb'])
|
|
if len(docs) >= max_docs:
|
|
break
|
|
|
|
doc_embeddings = torch.tensor(doc_embeddings)
|
|
|
|
query = 'What is an abstract' #Your query
|
|
response = co.embed(texts=[query], model='embed-english-v3.0', input_type='search_query')
|
|
query_embedding = response.embeddings
|
|
query_embedding = torch.tensor(query_embedding)
|
|
|
|
# Compute dot score between query embedding and document embeddings
|
|
dot_scores = torch.mm(query_embedding, doc_embeddings.transpose(0, 1))
|
|
top_k = torch.topk(dot_scores, k=3)
|
|
|
|
# Print results
|
|
print("Query:", query)
|
|
for doc_id in top_k.indices[0].tolist():
|
|
print(docs[doc_id]['title'])
|
|
print(docs[doc_id]['text'], "\n")
|
|
```
|
|
|
|
|
|
## Running evaluations
|
|
|
|
This dataset allows to reproduce the [BEIR](https://github.com/beir-cellar/beir) performance results and to compute nDCG@10, Recall@10, and Accuracy@3.
|
|
|
|
You must have `beir`, `faiss`, `numpy`, and `datasets` installed. The following scripts loads all files, runs search and computes the search quality metrices.
|
|
|
|
```python
|
|
import numpy as np
|
|
import faiss
|
|
from beir.retrieval.evaluation import EvaluateRetrieval
|
|
import time
|
|
from datasets import load_dataset
|
|
|
|
def faiss_search(index, queries_emb, k=[10, 100]):
|
|
start_time = time.time()
|
|
faiss_scores, faiss_doc_ids = index.search(queries_emb, max(k))
|
|
print(f"Search took {(time.time()-start_time):.2f} sec")
|
|
|
|
query2id = {idx: qid for idx, qid in enumerate(query_ids)}
|
|
doc2id = {idx: cid for idx, cid in enumerate(docs_ids)}
|
|
|
|
faiss_results = {}
|
|
for idx in range(0, len(faiss_scores)):
|
|
qid = query2id[idx]
|
|
doc_scores = {doc2id[doc_id]: score.item() for doc_id, score in zip(faiss_doc_ids[idx], faiss_scores[idx])}
|
|
faiss_results[qid] = doc_scores
|
|
|
|
ndcg, map_score, recall, precision = EvaluateRetrieval.evaluate(qrels, faiss_results, k)
|
|
acc = EvaluateRetrieval.evaluate_custom(qrels, faiss_results, [3, 5, 10], metric="acc")
|
|
print(ndcg)
|
|
print(recall)
|
|
print(acc)
|
|
|
|
dataset_name = "<<DATASET_NAME>>"
|
|
dataset_split = "test"
|
|
num_dim = 1024
|
|
|
|
#Load qrels
|
|
df = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-qrels", split=dataset_split)
|
|
qrels = {}
|
|
for row in df:
|
|
qid = row['query_id']
|
|
cid = row['corpus_id']
|
|
|
|
if row['score'] > 0:
|
|
if qid not in qrels:
|
|
qrels[qid] = {}
|
|
qrels[qid][cid] = row['score']
|
|
|
|
#Load queries
|
|
df = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-queries", split=dataset_split)
|
|
|
|
query_ids = df['_id']
|
|
query_embs = np.asarray(df['emb'])
|
|
print("Query embeddings:", query_embs.shape)
|
|
|
|
#Load corpus
|
|
df = load_dataset("Cohere/beir-embed-english-v3", f"{dataset_name}-corpus", split="train")
|
|
|
|
docs_ids = df['_id']
|
|
|
|
#Build index
|
|
print("Build index. This might take some time")
|
|
index = faiss.IndexFlatIP(num_dim)
|
|
index.add(np.asarray(df.to_pandas()['emb'].tolist()))
|
|
|
|
#Run and evaluate search
|
|
print("Seach on index")
|
|
faiss_search(index, query_embs)
|
|
```
|
|
|
|
## Notes
|
|
- This dataset was created with `datasets==2.15.0`. Make sure to use this or a newer version of the datasets library.
|
|
|
|
|
|
|
|
|