Add Sentence Transformers usage

#1
by tomaarsen HF Staff - opened
Files changed (1) hide show
  1. README.md +39 -3
README.md CHANGED
@@ -1,5 +1,6 @@
1
  ---
2
  tags:
 
3
  - ColBERT
4
  - PyLate
5
  - sentence-transformers
@@ -55,7 +56,7 @@ This creates a truly multilingual retriever that maintains exceptional English p
55
  **Additional Training:** 4.6B multilingual tokens via knowledge distillation
56
 
57
  ### Model Description
58
- - **Model Type:** PyLate model with innovative Late Interaction architecture
59
  - **Document Length:** 8192 tokens (32× longer than traditional BERT models)
60
  - **Query Length:** 256 tokens (optimized for complex, multi-part queries)
61
  - **Output Dimensionality:** 128 tokens (efficient vector representation)
@@ -160,12 +161,47 @@ We've created a model that excels in English (67.70 nDCG@10) while delivering st
160
 
161
  ---
162
 
163
- # PyLate
164
 
165
- This is a [PyLate](https://github.com/lightonai/pylate) model trained. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
166
 
167
 
168
  ## Usage
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
169
  First install the PyLate library:
170
 
171
  ```bash
 
1
  ---
2
  tags:
3
+ - multi-vector
4
  - ColBERT
5
  - PyLate
6
  - sentence-transformers
 
56
  **Additional Training:** 4.6B multilingual tokens via knowledge distillation
57
 
58
  ### Model Description
59
+ - **Model Type:** Multi-vector embedding model with innovative Late Interaction architecture
60
  - **Document Length:** 8192 tokens (32× longer than traditional BERT models)
61
  - **Query Length:** 256 tokens (optimized for complex, multi-part queries)
62
  - **Output Dimensionality:** 128 tokens (efficient vector representation)
 
161
 
162
  ---
163
 
164
+ # Model
165
 
166
+ This is a multi-vector (ColBERT-style late interaction) embedding model. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
167
 
168
 
169
  ## Usage
170
+
171
+ ### Sentence Transformers
172
+
173
+ This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
174
+
175
+ ```bash
176
+ pip install "sentence-transformers>=6.0.0"
177
+ ```
178
+
179
+ ```python
180
+ from sentence_transformers import MultiVectorEncoder
181
+
182
+ model = MultiVectorEncoder("VAGOsolutions/SauerkrautLM-Multi-ModernColBERT")
183
+
184
+ query = "Welcher Planet ist als der Rote Planet bekannt?"
185
+ documents = [
186
+ "Venus wird wegen ihrer ähnlichen Größe und Nähe oft als Erdzwilling bezeichnet.",
187
+ "Mars, bekannt für sein rötliches Aussehen, wird oft als der Rote Planet bezeichnet.",
188
+ "Jupiter, der größte Planet in unserem Sonnensystem, hat einen markanten roten Fleck.",
189
+ "Saturn, berühmt für seine Ringe, wird manchmal für den Roten Planeten gehalten.",
190
+ ]
191
+
192
+ query_embeddings = model.encode_query(query)
193
+ document_embeddings = model.encode_document(documents)
194
+ print(query_embeddings.shape, document_embeddings[0].shape)
195
+ # (32, 128) (29, 128)
196
+
197
+ # MaxSim late-interaction scoring (higher is more relevant)
198
+ scores = model.similarity(query_embeddings, document_embeddings)
199
+ print(scores)
200
+ # tensor([[28.7305, 29.5820, 29.0117, 29.1172]])
201
+ ```
202
+
203
+ ### PyLate
204
+
205
  First install the PyLate library:
206
 
207
  ```bash