@@ -79,19 +79,47 @@ Architecture Comparison
7979 - ❌
8080 - ✅
8181 - Sees all candidates at once; highest re-rank quality
82+ * - **MVR **
83+ - :py:class: `~lightning_ir.models.bi_encoders.mvr.MvrConfig `
84+ - Separate
85+ - Multi dense (viewer tokens)
86+ - ✅
87+ - ✅
88+ - Fixed-count multi-vector; balances index size and quality
89+ * - **COIL **
90+ - :py:class: `~lightning_ir.models.bi_encoders.coil.CoilConfig `
91+ - Separate
92+ - Multi (token + CLS)
93+ - ✅
94+ - ✅
95+ - Exact lexical match with context; sparse + dense hybrid
96+ * - **UniCOIL **
97+ - :py:class: `~lightning_ir.models.bi_encoders.coil.UniCoilConfig `
98+ - Separate
99+ - Single sparse (token weights)
100+ - ✅
101+ - ✅
102+ - Lightweight token-weight sparse retrieval; simpler than SPLADE
82103
83104.. note ::
84105
85- Lightning IR also supports several other bi-encoder variants ( :py:class: ` ~lightning_ir.models.bi_encoders.coil.CoilConfig `,
86- :py:class: `~lightning_ir.models.bi_encoders.mvr.MvrConfig `) and external models such as XTR for advanced use cases. See
87- the :ref: `concepts-model ` page and the :py:mod: `~lightning_ir.models ` API
88- reference for a full list.
106+ External checkpoints are also supported out of the box. For example, XTR
107+ (`` google/xtr-base-en ``) uses the ColBERT architecture ( :py:class: `~lightning_ir.models.bi_encoders.col.ColConfig `)
108+ with a T5 backbone. See the :ref: `concepts-model ` page and the :py:mod: `~lightning_ir.models ` API
109+ reference for a full list of registered checkpoints .
89110
90111Quick Examples
91112--------------
92113
93114**DPR bi-encoder ** — simplest dense retrieval:
94115
116+ DPR encodes each query and document into a single dense vector using a
117+ pooling step (typically the CLS token). Similarity is computed with a single
118+ dot product or cosine comparison, which makes retrieval fast and straightforward
119+ to index. The optional ``projection `` head lets you reduce the embedding
120+ dimension and add a non-linear bottleneck; set ``embedding_dim `` to control the
121+ output size.
122+
95123.. code-block :: yaml
96124
97125 # model-dpr.yaml
@@ -101,6 +129,13 @@ Quick Examples
101129 model_name_or_path : bert-base-uncased
102130 config :
103131 class_path : lightning_ir.models.DprConfig
132+ init_args :
133+ similarity_function : dot # or "cosine"
134+ query_length : 32 # max query tokens
135+ doc_length : 512 # max document tokens
136+ pooling_strategy : first # CLS token; also "mean", "max", "sum"
137+ embedding_dim : null # null → use backbone hidden size
138+ projection : linear # linear projection head; null to disable
104139
105140 .. code-block :: python
106141
@@ -109,11 +144,23 @@ Quick Examples
109144
110145 module = BiEncoderModule(
111146 model_name_or_path = " bert-base-uncased" ,
112- config = DprConfig(),
147+ config = DprConfig(
148+ similarity_function = " dot" ,
149+ query_length = 32 ,
150+ doc_length = 512 ,
151+ pooling_strategy = " first" ,
152+ embedding_dim = None , # None → use backbone hidden size
153+ projection = " linear" ,
154+ ),
113155 )
114156
115157 **ColBERT ** — multi-vector late interaction:
116158
159+ ColBERT produces one embedding **per token **, so controlling sequence lengths and
160+ the per-token embedding dimension directly affects index size and quality.
161+ It also supports special ColBERT-specific options (query expansion, marker
162+ tokens, per-token ``normalization_strategy ``) that DPR and SPLADE do not have.
163+
117164.. code-block :: yaml
118165
119166 # model-colbert.yaml
@@ -126,13 +173,13 @@ Quick Examples
126173 init_args :
127174 similarity_function : dot
128175 query_aggregation_function : sum
129- query_expansion : true
176+ query_expansion : true # ColBERT-specific: pad queries to query_length
130177 query_length : 32
131- doc_length : 256
132- normalization_strategy : l2
133- embedding_dim : 128
134- projection : linear_no_bias
135- add_marker_tokens : true
178+ doc_length : 256 # kept smaller than DPR to limit index size
179+ normalization_strategy : l2 # ColBERT-specific: per-token l2 normalisation
180+ embedding_dim : 128 # project every token to 128-d (reduces index size)
181+ projection : linear_no_bias # ColBERT convention: no bias in projection
182+ add_marker_tokens : true # ColBERT-specific: [Q]/[D] special tokens
136183
137184 .. code-block :: python
138185
@@ -144,18 +191,26 @@ Quick Examples
144191 config = ColConfig(
145192 similarity_function = " dot" ,
146193 query_aggregation_function = " sum" ,
147- query_expansion = True ,
194+ query_expansion = True , # ColBERT-specific
148195 query_length = 32 ,
149196 doc_length = 256 ,
150- normalization_strategy = " l2" ,
197+ normalization_strategy = " l2" , # ColBERT-specific
151198 embedding_dim = 128 ,
152199 projection = " linear_no_bias" ,
153- add_marker_tokens = True ,
200+ add_marker_tokens = True , # ColBERT-specific
154201 ),
155202 )
156203
157204 **SPLADE ** — learned sparse retrieval:
158205
206+ SPLADE maps each query and document to a sparse vector over the full vocabulary.
207+ Each vocabulary dimension is activated by taking the max-pool of the token
208+ logits, so the representation is directly interpretable as a bag of weighted
209+ terms. Because the embedding space is the tokenizer vocabulary, ``embedding_dim ``
210+ cannot be set freely — it is always equal to the vocabulary size. The key
211+ knob is ``pooling_strategy ``: ``max `` (the default) gives standard SPLADE
212+ behaviour; ``sum `` gives SPLADE-doc behaviour.
213+
159214.. code-block :: yaml
160215
161216 # model-splade.yaml
@@ -165,6 +220,17 @@ Quick Examples
165220 model_name_or_path : bert-base-uncased
166221 config :
167222 class_path : lightning_ir.models.SpladeConfig
223+ init_args :
224+ similarity_function : dot # sparse dot product
225+ query_length : 32 # max query tokens
226+ doc_length : 512 # max document tokens
227+ pooling_strategy : max # max over token activations (SPLADE default)
228+
229+ .. note ::
230+
231+ SPLADE uses the full vocabulary as its embedding space, so
232+ ``embedding_dim `` is tied to the vocabulary size and cannot be configured
233+ via the constructor (it is derived from the backbone tokenizer).
168234
169235.. code-block :: python
170236
@@ -173,11 +239,23 @@ Quick Examples
173239
174240 module = BiEncoderModule(
175241 model_name_or_path = " bert-base-uncased" ,
176- config = SpladeConfig(),
242+ config = SpladeConfig(
243+ similarity_function = " dot" ,
244+ query_length = 32 ,
245+ doc_length = 512 ,
246+ pooling_strategy = " max" , # max over token activations (SPLADE default)
247+ ),
177248 )
178249
179250 **Cross-encoder (MonoEncoder) ** — highest quality re-ranking:
180251
252+ A cross-encoder concatenates query and document into a single input and runs
253+ them jointly through the backbone, so every layer can attend across both texts.
254+ This yields the highest scoring quality but means no pre-indexing is possible
255+ — documents must be re-encoded for every new query. Use this architecture when
256+ you already have a candidate list (e.g. from a bi-encoder first stage) and
257+ need the best possible re-ranking without latency constraints.
258+
181259.. code-block :: yaml
182260
183261 # model-cross-encoder.yaml
0 commit comments