Sentence Similarity
Safetensors
sentence-transformers
English
PyLate
modernbert
ColBERT
multi-vector
feature-extraction
Generated from Trainer
dataset_size:5238
loss:CachedContrastive
text-embeddings-inference
🇪🇺 Region: EU
Instructions to use lightonai/Agent-ModernColBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use lightonai/Agent-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="lightonai/Agent-ModernColBERT") 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
#3
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -3,6 +3,7 @@ language:
|
|
| 3 |
- en
|
| 4 |
tags:
|
| 5 |
- ColBERT
|
|
|
|
| 6 |
- PyLate
|
| 7 |
- sentence-transformers
|
| 8 |
- sentence-similarity
|
|
@@ -153,14 +154,14 @@ If you rather want to use a simpler version without the prefix (just reasoning +
|
|
| 153 |
|
| 154 |
`get_document` is a net improvement in most cases, but the gains depend on **both** the retrieval model and the agent. The very strong numbers above are not a given for every combination. We tried adding more `get_document` data points, but were not able to reproduce the original AgentIR results exactly (small deltas remain after fixing environments). We therefore omit those points from the comparison: although they look favorable to Agent-ModernColBERT, we can't yet rule out GPT-OSS-side errors.
|
| 155 |
|
| 156 |
-
#
|
| 157 |
|
| 158 |
-
This is a
|
| 159 |
|
| 160 |
## Model Details
|
| 161 |
|
| 162 |
### Model Description
|
| 163 |
-
- **Model Type:**
|
| 164 |
- **Base model:** [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1)
|
| 165 |
- **Document Length:** 4096 tokens
|
| 166 |
- **Query Length:** 8192 tokens
|
|
@@ -187,6 +188,41 @@ ColBERT(
|
|
| 187 |
```
|
| 188 |
|
| 189 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
First install the PyLate library:
|
| 191 |
|
| 192 |
```bash
|
|
|
|
| 3 |
- en
|
| 4 |
tags:
|
| 5 |
- ColBERT
|
| 6 |
+
- multi-vector
|
| 7 |
- PyLate
|
| 8 |
- sentence-transformers
|
| 9 |
- sentence-similarity
|
|
|
|
| 154 |
|
| 155 |
`get_document` is a net improvement in most cases, but the gains depend on **both** the retrieval model and the agent. The very strong numbers above are not a given for every combination. We tried adding more `get_document` data points, but were not able to reproduce the original AgentIR results exactly (small deltas remain after fixing environments). We therefore omit those points from the comparison: although they look favorable to Agent-ModernColBERT, we can't yet rule out GPT-OSS-side errors.
|
| 156 |
|
| 157 |
+
# Multi-vector embedding model based on lightonai/GTE-ModernColBERT-v1
|
| 158 |
|
| 159 |
+
This is a multi-vector (ColBERT-style late interaction) embedding model finetuned from [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1) on the [agent_ir-data](https://huggingface.co/datasets/Tevatron/AgentIR-data) dataset. It maps sentences & paragraphs to sequences of 128-dimensional dense vectors and can be used for semantic textual similarity using the MaxSim operator.
|
| 160 |
|
| 161 |
## Model Details
|
| 162 |
|
| 163 |
### Model Description
|
| 164 |
+
- **Model Type:** Multi-vector embedding model
|
| 165 |
- **Base model:** [lightonai/GTE-ModernColBERT-v1](https://huggingface.co/lightonai/GTE-ModernColBERT-v1)
|
| 166 |
- **Document Length:** 4096 tokens
|
| 167 |
- **Query Length:** 8192 tokens
|
|
|
|
| 188 |
```
|
| 189 |
|
| 190 |
## Usage
|
| 191 |
+
|
| 192 |
+
### Sentence Transformers
|
| 193 |
+
|
| 194 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 195 |
+
|
| 196 |
+
```bash
|
| 197 |
+
pip install "sentence-transformers>=6.0.0"
|
| 198 |
+
```
|
| 199 |
+
|
| 200 |
+
```python
|
| 201 |
+
from sentence_transformers import MultiVectorEncoder
|
| 202 |
+
|
| 203 |
+
model = MultiVectorEncoder("lightonai/Agent-ModernColBERT")
|
| 204 |
+
|
| 205 |
+
query = "Which planet is known as the Red Planet?"
|
| 206 |
+
documents = [
|
| 207 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 208 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 209 |
+
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
|
| 210 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 211 |
+
]
|
| 212 |
+
|
| 213 |
+
query_embeddings = model.encode_query(query)
|
| 214 |
+
document_embeddings = model.encode_document(documents)
|
| 215 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 216 |
+
# (12, 128) (18, 128)
|
| 217 |
+
|
| 218 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 219 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 220 |
+
print(scores)
|
| 221 |
+
# tensor([[10.4239, 11.1039, 10.6760, 10.9058]])
|
| 222 |
+
```
|
| 223 |
+
|
| 224 |
+
### PyLate
|
| 225 |
+
|
| 226 |
First install the PyLate library:
|
| 227 |
|
| 228 |
```bash
|