Update README.md
Browse files
README.md
CHANGED
|
@@ -27,3 +27,78 @@ configs:
|
|
| 27 |
- split: train
|
| 28 |
path: data/train-*
|
| 29 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
- split: train
|
| 28 |
path: data/train-*
|
| 29 |
---
|
| 30 |
+
|
| 31 |
+
This is reranking dataset built from 179 queris from [MSMARCO-V2 passages set](https://ir-datasets.com/msmarco-passage-v2.html).
|
| 32 |
+
|
| 33 |
+
Below are the data creation process:
|
| 34 |
+
|
| 35 |
+
```
|
| 36 |
+
import sys
|
| 37 |
+
from pyserini.search import get_topics, get_qrels
|
| 38 |
+
from run_evaluation import THE_TOPICS, THE_INDEX
|
| 39 |
+
from trec_eval import EvalFunction
|
| 40 |
+
import json
|
| 41 |
+
qrels = {}
|
| 42 |
+
for data in ['dl21', 'dl22', 'dl23']:
|
| 43 |
+
qrels_file = get_qrels_file(THE_TOPICS[data])
|
| 44 |
+
with open(qrels_file, 'r') as f:
|
| 45 |
+
for line in f:
|
| 46 |
+
qid, _, docid, rel = line.strip().split()
|
| 47 |
+
if qid not in qrels:
|
| 48 |
+
qrels[qid] = {}
|
| 49 |
+
qrels[qid][docid] = int(rel)
|
| 50 |
+
|
| 51 |
+
# Save the combined qrels to a file
|
| 52 |
+
output_file = './combined_qrels.txt'
|
| 53 |
+
with open(output_file, 'w') as f:
|
| 54 |
+
for qid in sorted(qrels.keys()):
|
| 55 |
+
for docid, rel in qrels[qid].items():
|
| 56 |
+
f.write(f"{qid} 0 {docid} {rel}\n")
|
| 57 |
+
|
| 58 |
+
for data in ['dl21', 'dl22', 'dl23']:
|
| 59 |
+
topics = get_topics(THE_TOPICS[data] if data not in dl else data)
|
| 60 |
+
print(f"\nEvaluating {data}:, len(topics): {len(topics)}")
|
| 61 |
+
EvalFunction.main(THE_TOPICS[data], f'./20{data[2:]}_passage_top100.txt')
|
| 62 |
+
|
| 63 |
+
# Concate the files
|
| 64 |
+
combined_rank_results = []
|
| 65 |
+
for data in ['dl21', 'dl22', 'dl23']:
|
| 66 |
+
with open(f'{data}_bm25_rank_results.json', 'r') as f:
|
| 67 |
+
rank_results = json.load(f)
|
| 68 |
+
print(f"len(rank_results): {len(rank_results)}")
|
| 69 |
+
combined_rank_results.extend(rank_results)
|
| 70 |
+
|
| 71 |
+
# Multiple Random Sampling
|
| 72 |
+
|
| 73 |
+
import copy
|
| 74 |
+
import random
|
| 75 |
+
replicate_rank_results = []
|
| 76 |
+
replicate_times = 100
|
| 77 |
+
for item in combined_rank_results:
|
| 78 |
+
for _ in range(replicate_times):
|
| 79 |
+
new_item = copy.deepcopy(item)
|
| 80 |
+
# Randomly select 20 hits from original hits list
|
| 81 |
+
random_select_index = random.sample(range(len(item['hits'])), min(20, len(item['hits'])))
|
| 82 |
+
random_select_index.sort()
|
| 83 |
+
new_item['hits'] = [new_item['hits'][i] for i in random_select_index]
|
| 84 |
+
replicate_rank_results.append(new_item)
|
| 85 |
+
print(len(replicate_rank_results))
|
| 86 |
+
|
| 87 |
+
# Push to huggingface
|
| 88 |
+
|
| 89 |
+
from datasets import Dataset
|
| 90 |
+
import pandas as pd
|
| 91 |
+
from huggingface_hub import login
|
| 92 |
+
df = pd.DataFrame(replicate_rank_results)
|
| 93 |
+
dataset = Dataset.from_pandas(df)
|
| 94 |
+
|
| 95 |
+
# Print dataset info
|
| 96 |
+
print(f"Dataset size: {len(dataset)}")
|
| 97 |
+
print(dataset)
|
| 98 |
+
|
| 99 |
+
# Upload the dataset to Huggingface Hub
|
| 100 |
+
dataset.push_to_hub(
|
| 101 |
+
"le723z/DeepRerank", # Replace with your desired repository name
|
| 102 |
+
private=False, # Set to True if you want a private dataset
|
| 103 |
+
)
|
| 104 |
+
```
|