hugo commited on
Commit
7df9487
1 Parent(s): f798f06

First commit

Browse files
.gitattributes CHANGED
@@ -51,3 +51,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
51
  *.jpg filter=lfs diff=lfs merge=lfs -text
52
  *.jpeg filter=lfs diff=lfs merge=lfs -text
53
  *.webp filter=lfs diff=lfs merge=lfs -text
54
+ *.json filter=lfs diff=lfs merge=lfs -text
create_examples_dataset.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import ftfy
2
+ import json
3
+ import random
4
+ random.seed(1)
5
+ import argparse
6
+ import ir_datasets
7
+ from tqdm.auto import tqdm
8
+
9
+ def load_examples(base_dataset):
10
+ dataset = ir_datasets.load(base_dataset)
11
+
12
+ documents = {}
13
+ for doc in tqdm(
14
+ dataset.docs_iter(), total=dataset.docs_count(), desc="Loading documents"
15
+ ):
16
+ text = (
17
+ f"{doc.title} {doc.text}"
18
+ if "title" in dataset.docs_cls()._fields
19
+ else doc.text
20
+ )
21
+ documents[doc.doc_id] = ftfy.fix_text(text)
22
+
23
+ queries = {}
24
+ for query in dataset.queries_iter():
25
+ queries[query.query_id] = ftfy.fix_text(query.text)
26
+
27
+ return [
28
+ (queries[qrel.query_id], documents[qrel.doc_id])
29
+ for qrel in dataset.qrels_iter()
30
+ ]
31
+
32
+ if __name__ == "__main__":
33
+ parser = argparse.ArgumentParser()
34
+ parser.add_argument('--num_examples', default=500_000)
35
+ parser.add_argument('--dataset', default='beir/msmarco/train')
36
+ parser.add_argument('--output', required=True)
37
+ args = parser.parse_args()
38
+
39
+ examples = load_examples(args.dataset)
40
+ random.shuffle(examples)
41
+
42
+ with open(args.output, 'w') as f:
43
+ for (query, document) in tqdm(examples[:args.num_examples], total=args.num_examples, desc='Writing'):
44
+ f.write(json.dumps({'query': query, 'document': document}) + '\n')
data/msmarco.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1562c5128f6cf73a089023a57a323b2ca58585a25e2d4b9621701091a3be1895
3
+ size 207348070