Sentence Similarity
ONNX
Safetensors
sentence-transformers
PyLate
modernbert
ColBERT
multi-vector
feature-extraction
multilingual
code search
text-embeddings-inference
🇪🇺 Region: EU
Instructions to use lightonai/mLateOn with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lightonai/mLateOn 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="lightonai/mLateOn") queries_emb = model.encode(queries, is_query=True) docs_emb = model.encode(documents, is_query=False) - Inference
- Notebooks
- Google Colab
- Kaggle
Add Sentence Transformers usage
#1
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- ColBERT
|
|
|
|
| 4 |
- PyLate
|
| 5 |
- sentence-transformers
|
| 6 |
- sentence-similarity
|
|
@@ -204,6 +205,40 @@ ColBERT(
|
|
| 204 |
|
| 205 |
## Usage
|
| 206 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 207 |
First install the PyLate library:
|
| 208 |
|
| 209 |
```bash
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- ColBERT
|
| 4 |
+
- multi-vector
|
| 5 |
- PyLate
|
| 6 |
- sentence-transformers
|
| 7 |
- sentence-similarity
|
|
|
|
| 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("lightonai/mLateOn")
|
| 220 |
+
|
| 221 |
+
query = "Which planet is the Red Planet?"
|
| 222 |
+
documents = [
|
| 223 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 224 |
+
"Mars, connu pour son apparence rougeâtre, est souvent appelé la planète rouge.",
|
| 225 |
+
"Mars, bekannt für sein rötliches Erscheinungsbild, wird oft als der Rote Planet bezeichnet.",
|
| 226 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 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 |
+
# (10, 128) (20, 128)
|
| 233 |
+
|
| 234 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 235 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 236 |
+
print(scores)
|
| 237 |
+
# tensor([[9.6029, 9.5838, 9.5877, 9.4578]])
|
| 238 |
+
```
|
| 239 |
+
|
| 240 |
+
### PyLate
|
| 241 |
+
|
| 242 |
First install the PyLate library:
|
| 243 |
|
| 244 |
```bash
|