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-2.0
|
4 |
+
datasets:
|
5 |
+
- ms_marco
|
6 |
+
- sentence-transformers/msmarco-hard-negatives
|
7 |
+
metrics:
|
8 |
+
- recall
|
9 |
+
tags:
|
10 |
+
- feature-extraction
|
11 |
+
- sentence-similarity
|
12 |
+
library_name: colbert-ai
|
13 |
+
inference: false
|
14 |
+
language:
|
15 |
+
- multilingual
|
16 |
+
- af
|
17 |
+
- am
|
18 |
+
- ar
|
19 |
+
- az
|
20 |
+
- be
|
21 |
+
- bg
|
22 |
+
- bn
|
23 |
+
- ca
|
24 |
+
- cs
|
25 |
+
- cy
|
26 |
+
- da
|
27 |
+
- de
|
28 |
+
- el
|
29 |
+
- en
|
30 |
+
- eo
|
31 |
+
- es
|
32 |
+
- et
|
33 |
+
- eu
|
34 |
+
- fa
|
35 |
+
- fi
|
36 |
+
- fr
|
37 |
+
- ga
|
38 |
+
- gl
|
39 |
+
- gu
|
40 |
+
- ha
|
41 |
+
- he
|
42 |
+
- hi
|
43 |
+
- hr
|
44 |
+
- hu
|
45 |
+
- hy
|
46 |
+
- id
|
47 |
+
- is
|
48 |
+
- it
|
49 |
+
- ja
|
50 |
+
- ka
|
51 |
+
- kk
|
52 |
+
- km
|
53 |
+
- kn
|
54 |
+
- ko
|
55 |
+
- ku
|
56 |
+
- ky
|
57 |
+
- la
|
58 |
+
- lo
|
59 |
+
- lt
|
60 |
+
- lv
|
61 |
+
- mk
|
62 |
+
- ml
|
63 |
+
- mn
|
64 |
+
- mr
|
65 |
+
- ms
|
66 |
+
- my
|
67 |
+
- ne
|
68 |
+
- nl
|
69 |
+
- no
|
70 |
+
- or
|
71 |
+
- pa
|
72 |
+
- pl
|
73 |
+
- ps
|
74 |
+
- pt
|
75 |
+
- ro
|
76 |
+
- ru
|
77 |
+
- sa
|
78 |
+
- si
|
79 |
+
- sk
|
80 |
+
- sl
|
81 |
+
- so
|
82 |
+
- sq
|
83 |
+
- sr
|
84 |
+
- sv
|
85 |
+
- sw
|
86 |
+
- ta
|
87 |
+
- te
|
88 |
+
- th
|
89 |
+
- tl
|
90 |
+
- tr
|
91 |
+
- uk
|
92 |
+
- ur
|
93 |
+
- uz
|
94 |
+
- vi
|
95 |
+
- zh
|
96 |
+
---
|
97 |
+
|
98 |
+
<h1 align="center">ColBERT-XM</h1>
|
99 |
+
|
100 |
+
|
101 |
+
<h4 align="center">
|
102 |
+
<p>
|
103 |
+
<a href=#usage>π οΈ Usage</a> |
|
104 |
+
<a href="#evaluation">π Evaluation</a> |
|
105 |
+
<a href="#train">π€ Training</a> |
|
106 |
+
<a href="#citation">π Citation</a> |
|
107 |
+
<a href="#license">π License</a>
|
108 |
+
<p>
|
109 |
+
<p>
|
110 |
+
<a href="https://github.com/ant-louis/xm-retrievers">π» Code</a> |
|
111 |
+
<a href="https://arxiv.org/abs/">π Paper</a>
|
112 |
+
<p>
|
113 |
+
</h4>
|
114 |
+
|
115 |
+
This is a [colbert-ai](https://github.com/stanford-futuredata/ColBERT) model: it encodes queries & passages into matrices of token-level embeddings and efficiently finds passages that contextually match the query using scalable vector-similarity (MaxSim) operators. It can be used for tasks like clustering or semantic search. The model uses an [XMOD](https://huggingface.co/facebook/xmod-base) backbone, which allows it to learn from monolingual fine-tuning in a high-resource language, like English, and perform zero-shot retrieval across multiple languages.
|
116 |
+
|
117 |
+
## Usage
|
118 |
+
|
119 |
+
Here are some examples for using ColBERT-XM with [colbert-ai](#using-colbert-ai) or [RAGatouille](#using-ragatouille).
|
120 |
+
|
121 |
+
### Using ColBERT-AI
|
122 |
+
|
123 |
+
Start by installing the [library](https://github.com/stanford-futuredata/ColBERT) and some extra rquirements:
|
124 |
+
|
125 |
+
```
|
126 |
+
pip install git+https://github.com/stanford-futuredata/ColBERT.git@main#egg=colbert-ai torchtorch==2.1.2 faiss-gpu==1.7.2
|
127 |
+
```
|
128 |
+
|
129 |
+
Using the modeel on a collection of passages typically involves the following steps:
|
130 |
+
|
131 |
+
- **Step 1: Indexing.** This step encodes all passages into matrices, stores them on disk, and builds data structures for efficient search. (β οΈ indexing requires a GPU!)
|
132 |
+
```
|
133 |
+
from colbert import Indexer
|
134 |
+
from colbert.infra import Run, RunConfig
|
135 |
+
|
136 |
+
n_gpu: int = 1 # Set your number of available GPUs
|
137 |
+
experiment: str = "" # Name of the folder where the logs and created indices will be stored
|
138 |
+
index_name: str = "" # The name of your index, i.e. the name of your vector database
|
139 |
+
|
140 |
+
with Run().context(RunConfig(nranks=n_gpu,experiment=experiment)):
|
141 |
+
indexer = Indexer(checkpoint="antoinelouis/colbertv1-camembert-base-mmarcoFR")
|
142 |
+
documents = [
|
143 |
+
"Ceci est un premier document.",
|
144 |
+
"Voici un second document.",
|
145 |
+
...
|
146 |
+
]
|
147 |
+
indexer.index(name=index_name, collection=documents)
|
148 |
+
|
149 |
+
```
|
150 |
+
|
151 |
+
- **Step 2: Searching.** Given the model and index, you can issue queries over the collection to retrieve the top-k passages for each query.
|
152 |
+
```
|
153 |
+
from colbert import Searcher
|
154 |
+
from colbert.infra import Run, RunConfig
|
155 |
+
|
156 |
+
n_gpu: int = 0
|
157 |
+
experiment: str = "" # Name of the folder where the logs and created indices will be stored
|
158 |
+
index_name: str = "" # Name of your previously created index where the documents you want to search are stored.
|
159 |
+
k: int = 10 # how many results you want to retrieve
|
160 |
+
|
161 |
+
with Run().context(RunConfig(nranks=n_gpu,experiment=experiment)):
|
162 |
+
searcher = Searcher(index=index_name) # You don't need to specify checkpoint again, the model name is stored in the index.
|
163 |
+
query = "Comment effectuer une recherche avec ColBERT ?"
|
164 |
+
results = searcher.search(query, k=k)
|
165 |
+
# results: tuple of tuples of length k containing ((passage_id, passage_rank, passage_score), ...)
|
166 |
+
|
167 |
+
```
|
168 |
+
|
169 |
+
### Using RAGatouille
|
170 |
+
|
171 |
+
[To come...]
|
172 |
+
|
173 |
+
***
|
174 |
+
|
175 |
+
## Evaluation
|
176 |
+
|
177 |
+
- **MS MARCO**:
|
178 |
+
We evaluate our model on the small development set of [MS MARCO](https://ir-datasets.com/msmarco-passage.html#msmarco-passage/dev/small), which consists of 6,980 queries for a corpus of 8.8M candidate passages. Below, we compared its performance with other retrieval models on the official metrics for the dataset, i.e., mean reciprocal rank at cut-off 10 (MRR@10).
|
179 |
+
|
180 |
+
| | model | Type | #Samples | #Params | en | es | fr | it | pt | id | de | ru | zh | ja | nl | vi | hi | ar | Avg. |
|
181 |
+
|---:|:----------------------------------------------------------------------------------------------------------------------------------------|:--------------|:--------:|:-------:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|-----:|
|
182 |
+
| 1 | BM25 ([Pyserini](https://github.com/castorini/pyserini)) | lexical | - | - | 18.4 | 15.8 | 15.5 | 15.3 | 15.2 | 14.9 | 13.6 | 12.4 | 11.6 | 14.1 | 14.0 | 13.6 | 13.4 | 11.1 | 14.2 |
|
183 |
+
| 2 | mono-mT5 ([Bonfacio et al., 2021](https://doi.org/10.48550/arXiv.2108.13897)) | cross-encoder | 12.8M | 390M | 36.6 | 31.4 | 30.2 | 30.3 | 30.2 | 29.8 | 28.9 | 26.3 | 24.9 | 26.7 | 29.2 | 25.6 | 26.6 | 23.5 | 28.6 |
|
184 |
+
| 3 | mono-mMiniLM ([Bonfacio et al., 2021](https://doi.org/10.48550/arXiv.2108.13897)) | cross-encoder | 80.0M | 107M | 36.6 | 30.9 | 29.6 | 29.1 | 28.9 | 29.3 | 27.8 | 25.1 | 24.9 | 26.3 | 27.6 | 24.7 | 26.2 | 21.9 | 27.8 |
|
185 |
+
| 4 | [DPR-X](https://huggingface.co/eugene-yang/dpr-xlmr-large-mtt-neuclir) ([Yang et al., 2022](https://doi.org/10.48550/arXiv.2204.11989)) | single-vector | 25.6M | 550M | 24.5 | 19.6 | 18.9 | 18.3 | 19.0 | 16.9 | 18.2 | 17.7 | 14.8 | 15.4 | 18.5 | 15.1 | 15.4 | 12.9 | 17.5 |
|
186 |
+
| 5 | [mE5-base](https://huggingface.co/intfloat/multilingual-e5-base) ([Wang et al., 2024](https://doi.org/10.48550/arXiv.2402.05672)) | single-vector | 5.1B | 278M | 35.0 | 28.9 | 30.3 | 28.0 | 27.5 | 26.1 | 27.1 | 24.5 | 22.9 | 25.0 | 27.3 | 23.9 | 24.2 | 20.5 | 26.5 |
|
187 |
+
| 6 | mColBERT ([Bonfacio et al., 2021](https://doi.org/10.48550/arXiv.2108.13897)) | multi-vector | 25.6M | 180M | 35.2 | 30.1 | 28.9 | 29.2 | 29.2 | 27.5 | 28.1 | 25.0 | 24.6 | 23.6 | 27.3 | 18.0 | 23.2 | 20.9 | 26.5 |
|
188 |
+
| | | | | | | | | | | | | | | | | | | | |
|
189 |
+
| 7 | [DPR-XM](https://huggingface.co/antoinelouis/dpr-xm) (ours) | single-vector | 25.6M | 277M | 32.7 | 23.6 | 23.5 | 22.3 | 22.7 | 22.0 | 22.1 | 19.9 | 18.1 | 18.7 | 22.9 | 18.0 | 16.0 | 15.1 | 21.3 |
|
190 |
+
| 8 | **ColBERT-XM** (ours) | multi-vector | 6.4M | 277M | 37.2 | 28.5 | 26.9 | 26.5 | 27.6 | 26.3 | 27.0 | 25.1 | 24.6 | 24.1 | 27.5 | 22.6 | 23.8 | 19.5 | 26.2 |
|
191 |
+
|
192 |
+
***
|
193 |
+
|
194 |
+
## Training
|
195 |
+
|
196 |
+
#### Data
|
197 |
+
|
198 |
+
We use the training samples from the [MS MARCO passage ranking](https://ir-datasets.com/msmarco-passage.html#msmarco-passage/train) dataset, which contains 8.8M passages and 539K training queries. We do not employ the BM25 netaives provided by the official dataset but instead sample harder negatives mined from 12 distinct dense retrievers, using the [msmarco-hard-negatives](https://huggingface.co/datasets/sentence-transformers/msmarco-hard-negatives) distillation dataset. Our final training set consists of 6.4M (q, p+, p-) triples.
|
199 |
+
|
200 |
+
#### Implementation
|
201 |
+
|
202 |
+
The model is initialized from the [xmod-base](https://huggingface.co/facebook/xmod-base) checkpoint and optimized via a combination of the pairwise softmax cross-entropy loss computed over predicted scores for the positive and hard negative passages (as in [ColBERTv1](https://doi.org/10.48550/arXiv.2004.12832)) and the in-batch sampled softmax cross-entropy loss (as in [ColBERTv2](https://doi.org/10.48550/arXiv.2112.01488)). It is fine-tuned on one 80GB NVIDIA H100 GPU for 50k steps using the AdamW optimizer with a batch size of 128, a peak learning rate of 3e-6 with warm up along the first 10\% of training steps and linear scheduling. We set the embedding dimension to 128, and fix the maximum sequence lengths for questions and passages at 32 and 256, respectively.
|
203 |
+
|
204 |
+
***
|
205 |
+
|
206 |
+
## Citation
|
207 |
+
|
208 |
+
```bibtex
|
209 |
+
@article{louis2024modular,
|
210 |
+
author = {Louis, Antoine and Saxena, Vageesh and van Dijck, Gijs and Spanakis, Gerasimos},
|
211 |
+
title = {ColBERT-XM: A Modular Multi-Vector Representation Model for Zero-Shot Multilingual Information Retrieval},
|
212 |
+
journal = {CoRR},
|
213 |
+
volume = {abs/2402.xxxxx},
|
214 |
+
year = {2024},
|
215 |
+
url = {https://doi.org/},
|
216 |
+
doi = {},
|
217 |
+
eprinttype = {arXiv},
|
218 |
+
eprint = {2402.xxxxx},
|
219 |
+
}
|
220 |
+
```
|
221 |
+
|
222 |
+
## License
|
223 |
+
|
224 |
+
DPR-XM is licensed under the [Apache 2.0](https://opensource.org/license/apache-2-0/) license.
|