File size: 13,557 Bytes
77430b2
8fe067f
77430b2
22bf668
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18d3960
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74c6f8f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c125746
 
 
 
 
 
 
 
 
 
 
 
 
 
eab7dda
c125746
eab7dda
 
7ba7203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f155b57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8c438bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
935484e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3cf8ee2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7e942a6
 
 
 
 
 
 
 
 
 
 
 
 
 
191fa9e
7e942a6
191fa9e
 
8c574cf
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
dbb4e97
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8fe067f
 
 
 
 
 
 
 
 
 
f7aa9fe
 
 
 
c125746
77430b2
8fb9653
77430b2
 
 
 
 
 
 
 
 
8fb9653
77430b2
973ef7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f6ba8e1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77430b2
22bf668
 
 
 
18d3960
 
 
 
74c6f8f
 
 
 
c125746
 
 
 
7ba7203
 
 
 
f155b57
 
 
 
8c438bc
 
 
 
935484e
 
 
 
3cf8ee2
 
 
 
7e942a6
 
 
 
8c574cf
 
 
 
dbb4e97
 
 
 
8fe067f
 
 
 
77430b2
 
 
 
973ef7b
 
 
 
f6ba8e1
 
 
 
77430b2
698ada4
3f6df6d
698ada4
 
 
 
 
c0968b6
 
 
698ada4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
---
license: apache-2.0
dataset_info:
- config_name: arabic_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 185002207
  dataset_size: 278081216
- config_name: chinese_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 184701435
  dataset_size: 278081216
- config_name: dutch_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 185849249
  dataset_size: 278081216
- config_name: english_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 535572160
    num_examples: 502912
  download_size: 339859952
  dataset_size: 535572160
- config_name: french_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186154601
  dataset_size: 278081216
- config_name: german_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 184933921
  dataset_size: 278081216
- config_name: hindi_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186289631
  dataset_size: 278081216
- config_name: indonesian_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186918156
  dataset_size: 278081216
- config_name: italian_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186232117
  dataset_size: 278081216
- config_name: japanese_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 535572160
    num_examples: 502912
  download_size: 337734717
  dataset_size: 535572160
- config_name: portuguese_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186472515
  dataset_size: 278081216
- config_name: russian_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 184840600
  dataset_size: 278081216
- config_name: sentence-transformers-msmarco-hard-negatives
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  splits:
  - name: train
    num_bytes: 846201448
    num_examples: 502939
  download_size: 662470387
  dataset_size: 846201448
- config_name: sentence-transformers-msmarco-hard-negatives-bm25
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  splits:
  - name: train
    num_bytes: 213472888
    num_examples: 502912
  download_size: 176954469
  dataset_size: 213472888
- config_name: spanish_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 186573954
  dataset_size: 278081216
- config_name: vietnamese_bge-reranker-v2-m3
  features:
  - name: qid
    dtype: int64
  - name: pos
    sequence: int64
  - name: neg
    sequence: int64
  - name: pos.score
    sequence: float64
  - name: neg.score
    sequence: float64
  splits:
  - name: train
    num_bytes: 278081216
    num_examples: 502912
  download_size: 185789847
  dataset_size: 278081216
configs:
- config_name: arabic_bge-reranker-v2-m3
  data_files:
  - split: train
    path: arabic_bge-reranker-v2-m3/train-*
- config_name: chinese_bge-reranker-v2-m3
  data_files:
  - split: train
    path: chinese_bge-reranker-v2-m3/train-*
- config_name: dutch_bge-reranker-v2-m3
  data_files:
  - split: train
    path: dutch_bge-reranker-v2-m3/train-*
- config_name: english_bge-reranker-v2-m3
  data_files:
  - split: train
    path: english_bge-reranker-v2-m3/train-*
- config_name: french_bge-reranker-v2-m3
  data_files:
  - split: train
    path: french_bge-reranker-v2-m3/train-*
- config_name: german_bge-reranker-v2-m3
  data_files:
  - split: train
    path: german_bge-reranker-v2-m3/train-*
- config_name: hindi_bge-reranker-v2-m3
  data_files:
  - split: train
    path: hindi_bge-reranker-v2-m3/train-*
- config_name: indonesian_bge-reranker-v2-m3
  data_files:
  - split: train
    path: indonesian_bge-reranker-v2-m3/train-*
- config_name: italian_bge-reranker-v2-m3
  data_files:
  - split: train
    path: italian_bge-reranker-v2-m3/train-*
- config_name: japanese_bge-reranker-v2-m3
  data_files:
  - split: train
    path: japanese_bge-reranker-v2-m3/train-*
- config_name: portuguese_bge-reranker-v2-m3
  data_files:
  - split: train
    path: portuguese_bge-reranker-v2-m3/train-*
- config_name: russian_bge-reranker-v2-m3
  data_files:
  - split: train
    path: russian_bge-reranker-v2-m3/train-*
- config_name: sentence-transformers-msmarco-hard-negatives
  data_files:
  - split: train
    path: sentence-transformers-msmarco-hard-negatives/train-*
- config_name: sentence-transformers-msmarco-hard-negatives-bm25
  data_files:
  - split: train
    path: sentence-transformers-msmarco-hard-negatives-bm25/train-*
- config_name: spanish_bge-reranker-v2-m3
  data_files:
  - split: train
    path: spanish_bge-reranker-v2-m3/train-*
- config_name: vietnamese_bge-reranker-v2-m3
  data_files:
  - split: train
    path: vietnamese_bge-reranker-v2-m3/train-*
---

- `hotchpotch/mmarco-hard-negatives-reranker-score`

This repository contains data from [mMARCO](https://huggingface.co/datasets/unicamp-dl/mmarco) scored using the reranker [BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3).

## Languages Covered

```
target_languages = ["english", "chinese", "french", "german", "indonesian", "italian", "portuguese", "russian", "spanish", "arabic", "dutch", "hindi", "japanese", "vietnamese"]
```

## Hard Negative Data

The hard negative data is derived from [sentence-transformers-msmarco-hard-negatives-bm25](https://huggingface.co/datasets/sentence-transformers/msmarco-hard-negatives), randomly sampling 32 instances for use.

## License

This project adheres to the same license as mMARCO: **Apache License 2.0**.

# Example


```python
# target languages => ["english", "chinese", "french", "german", "indonesian", "italian", "portuguese", "russian", "spanish", "arabic", "dutch", "hindi", "japanese", "vietnamese"]

lang = "spanish"
repo_id = "hotchpotch/mmarco-hard-negatives-reranker-score"
reranker = "bge-reranker-v2-m3"
subset = f"{lang}_{reranker}"
mapping = f"mappings/{lang}_joblib.pkl.gz"

from datasets import load_dataset
import joblib
from huggingface_hub import hf_hub_download

queries_ds = load_dataset(
    "unicamp-dl/mmarco", "queries-" + lang, split="train", trust_remote_code=True
)
collection_ds = load_dataset(
    "unicamp-dl/mmarco",
    "collection-" + lang,
    split="collection",
    trust_remote_code=True,
)
score_ds = load_dataset(repo_id, subset, split="train")


mapping_file = hf_hub_download(repo_type="dataset", repo_id=repo_id, filename=mapping)

index_mapping_dict = joblib.load(mapping_file)
query_id_dict = index_mapping_dict["query_id_dict"]
collection_id_dict = index_mapping_dict["collection_id_dict"]


def get_query_text(query_id) -> str:
    idx = query_id_dict[query_id]
    return queries_ds[idx]["text"]  # type: ignore


def get_collection_text(doc_id) -> str:
    idx = collection_id_dict[doc_id]
    return collection_ds[idx]["text"]  # type: ignore

for i in range(5):
    qid: int = score_ds[i]["qid"]
    pos: list[int] = score_ds[i]["pos"]
    pos_score: list[float] = score_ds[i]["pos.score"]
    neg: list[int] = score_ds[i]["neg"]
    neg_score: list[float] = score_ds[i]["neg.score"]
    query = get_query_text(qid)
    pos_docs = [get_collection_text(doc_id)[0:64] for doc_id in pos]
    neg_docs = [get_collection_text(doc_id)[0:64] for doc_id in neg]
    print(f"# Query: {query}")
    print("## Positive docs:")
    for doc, score in zip(pos_docs, pos_score):
        print(f"  {doc} ({score})")
    print("## Negative docs:")
    for doc, score in list(zip(neg_docs, neg_score))[0:5]:
        print(f"  {doc} ({score})")
    print("-------")
```

output

```
# Query: ¿Qué son las artes liberales?
## Positive docs:
  Artes liberales. 1. el curso académico de instrucción en una uni (0.99770385)
## Negative docs:
  Grandes Ligas. Puede elegir entre una variedad de especializacio (0.69760895)
  BA = Licenciatura en Artes BS = Licenciatura en Ciencias Creo qu (0.24364243)
  ¿Qué es una Licenciatura en Artes (B.A.)? Un programa de licenci (0.20641373)
  ¿Qué significa LCSW? / Human and Social ... / Liberal Arts y ... (0.0140636265)
  definición de artes liberales Las áreas de aprendizaje que culti (0.9963924)
-------
# Query: ¿Cuál es el mecanismo de acción de los fármacos fibrinolíticos o trombolíticos?
## Positive docs:
  Hematología clínica de BailliÃÆ'¨re. 6 Mecanismo de acción d (0.966347)
## Negative docs:
  Definición y ejemplos de mecanismos de acción. Más en Trastorno  (0.3598139)
  ¿Qué es losartán y cómo funciona (mecanismo de acción)? ¿Qué mar (0.0031480708)
  ActivaseÃ⠀ šÃ,® Una propietaria trombolítico, que puede à ¢  (0.83237296)
  La terapia fibrinolítica, también llamada a veces "terapia tromb (0.92590266)
  Diazepam Valium Mecanismo de acción Valium Mecanismo de acción E (0.040162582)
-------
# Query: ¿Qué es el recuento normal de plataformas?
## Positive docs:
  78 seguidores. R. Las plaquetas son glóbulos diminutos que ayuda (0.10105592)
## Negative docs:
  ¿Qué es la trombocitopenia (recuento bajo de plaquetas)? Las pla (0.047337715)
  Calificación Más reciente Más antiguo. Mejor respuesta: Nancy: e (0.03179867)
  1 Tarifas de solicitud ࢠ€Â⠀ œ $ 80 por una plataform (0.001044386)
  Conteo sanguíneo de MCV. Mi recuento sanguíneo de MCV está en 98 (0.011115014)
  ¿Cuáles son los niveles normales de hemograma para una mujer adu (0.015247591)
-------
# Query: promedio de costo en dólares explicado
## Positive docs:
  El promedio del costo en dólares es simplemente un método para c (0.96771675)
## Negative docs:
  El promedio del costo en dólares es una técnica simple que le pe (0.9859364)
  Anteriormente en Free from Broke, Glen ha abordado el tema del c (0.89274967)
  (TMFMathGuy). 19 de noviembre de 2014 a las 2:15 p.m. El promedi (0.98421544)
  Comprar acciones por valor de $ 2,000 en el primer mes, a $ 14.2 (0.36624968)
  DEFINICIÓN de 'Valor Promedio'. Una estrategia de inversión que  (0.3941427)
-------
# Query: alimentos que ayudan a combatir la gota
## Positive docs:
  Además de seguir una dieta bien balanceada para promover la salu (0.9874721)
## Negative docs:
  Alimentos para la gota: anacardos y gota. Los anacardos y la got (0.84606963)
  Alimentos que debe evitar si tiene gota La gota es un tipo de ar (0.016979992)
  El puerto causa gota. Estos son solo algunos tratamientos natura (0.30850264)
  20 alimentos ricos en purina que debe evitar: alterar su dieta p (0.4324828)
  Alimentos que combaten el cáncer por BÃÆ' © liveau & Gingras (0.010408314)
-------

```