Sentence Similarity
Safetensors
sentence-transformers
PyLate
modernbert
multi-vector
ColBERT
feature-extraction
multilingual
late-interaction
retrieval
bright
loss:Distillation
text-embeddings-inference
Instructions to use VAGOsolutions/SauerkrautLM-Multi-Reason-ModernColBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use VAGOsolutions/SauerkrautLM-Multi-Reason-ModernColBERT with sentence-transformers:
from pylate import models queries = [ "Which planet is known as the Red Planet?", "What is the largest planet in our solar system?", ] documents = [ ["Mars is the Red Planet.", "Venus is Earth's twin."], ["Jupiter is the largest planet.", "Saturn has rings."], ] model = models.ColBERT(model_name_or_path="VAGOsolutions/SauerkrautLM-Multi-Reason-ModernColBERT") queries_emb = model.encode(queries, is_query=True) docs_emb = model.encode(documents, is_query=False) - Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage (#2)
Browse files- Add Sentence Transformers usage (43d400b4b46863730c45bebfd95ca42fff0670ec)
Co-authored-by: Tom Aarsen <tomaarsen@users.noreply.huggingface.co>
README.md
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
|
|
|
| 3 |
- ColBERT
|
| 4 |
- PyLate
|
| 5 |
- sentence-transformers
|
|
@@ -53,7 +54,7 @@ This exceptional efficiency makes it the ideal choice for production environment
|
|
| 53 |
**Efficiency Ratio:** Up to **54× smaller** than comparable performing models
|
| 54 |
|
| 55 |
### Model Description
|
| 56 |
-
- **Model Type:**
|
| 57 |
- **Document Length:** 8192 tokens (32× longer than traditional BERT models)
|
| 58 |
- **Query Length:** 256 tokens (optimized for complex, multi-part queries)
|
| 59 |
- **Output Dimensionality:** 128 tokens (efficient vector representation)
|
|
@@ -197,12 +198,47 @@ This breakthrough demonstrates that with the right techniques, compact models ca
|
|
| 197 |
|
| 198 |
---
|
| 199 |
|
| 200 |
-
#
|
| 201 |
|
| 202 |
-
This is a
|
| 203 |
|
| 204 |
|
| 205 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
First install the PyLate library:
|
| 207 |
|
| 208 |
```bash
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
+
- multi-vector
|
| 4 |
- ColBERT
|
| 5 |
- PyLate
|
| 6 |
- sentence-transformers
|
|
|
|
| 54 |
**Efficiency Ratio:** Up to **54× smaller** than comparable performing models
|
| 55 |
|
| 56 |
### Model Description
|
| 57 |
+
- **Model Type:** Multi-vector embedding model with innovative Late Interaction architecture
|
| 58 |
- **Document Length:** 8192 tokens (32× longer than traditional BERT models)
|
| 59 |
- **Query Length:** 256 tokens (optimized for complex, multi-part queries)
|
| 60 |
- **Output Dimensionality:** 128 tokens (efficient vector representation)
|
|
|
|
| 198 |
|
| 199 |
---
|
| 200 |
|
| 201 |
+
# Model
|
| 202 |
|
| 203 |
+
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.
|
| 204 |
|
| 205 |
|
| 206 |
## Usage
|
| 207 |
+
|
| 208 |
+
### Sentence Transformers
|
| 209 |
+
|
| 210 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 211 |
+
|
| 212 |
+
```bash
|
| 213 |
+
pip install "sentence-transformers>=6.0.0"
|
| 214 |
+
```
|
| 215 |
+
|
| 216 |
+
```python
|
| 217 |
+
from sentence_transformers import MultiVectorEncoder
|
| 218 |
+
|
| 219 |
+
model = MultiVectorEncoder("VAGOsolutions/SauerkrautLM-Multi-Reason-ModernColBERT")
|
| 220 |
+
|
| 221 |
+
query = "Welcher Planet ist als der Rote Planet bekannt?"
|
| 222 |
+
documents = [
|
| 223 |
+
"Venus wird wegen ihrer ähnlichen Größe und Nähe oft als Erdzwilling bezeichnet.",
|
| 224 |
+
"Mars, bekannt für sein rötliches Aussehen, wird oft als der Rote Planet bezeichnet.",
|
| 225 |
+
"Jupiter, der größte Planet in unserem Sonnensystem, hat einen markanten roten Fleck.",
|
| 226 |
+
"Saturn, berühmt für seine Ringe, wird manchmal für den Roten Planeten gehalten.",
|
| 227 |
+
]
|
| 228 |
+
|
| 229 |
+
query_embeddings = model.encode_query(query)
|
| 230 |
+
document_embeddings = model.encode_document(documents)
|
| 231 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 232 |
+
# (256, 128) (29, 128)
|
| 233 |
+
|
| 234 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 235 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 236 |
+
print(scores)
|
| 237 |
+
# tensor([[211.5445, 217.9270, 215.3372, 216.1647]])
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
### PyLate
|
| 241 |
+
|
| 242 |
First install the PyLate library:
|
| 243 |
|
| 244 |
```bash
|