Sentence Similarity
sentence-transformers
Safetensors
English
modernbert
SMVE
ColBERT
multi-vector
PyLate
feature-extraction
text-embeddings-inference
Instructions to use topk-io/Iso-ModernColBERT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use topk-io/Iso-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="topk-io/Iso-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
#1
by tomaarsen HF Staff - opened
README.md
CHANGED
|
@@ -6,6 +6,7 @@ pipeline_tag: sentence-similarity
|
|
| 6 |
tags:
|
| 7 |
- SMVE
|
| 8 |
- ColBERT
|
|
|
|
| 9 |
- PyLate
|
| 10 |
- sentence-transformers
|
| 11 |
- sentence-similarity
|
|
@@ -97,6 +98,41 @@ up to 3x faster inference in `bf16` with almost no loss in accuracy and enables
|
|
| 97 |
[Sparse Multi-Vector Encoding (SMVE)](https://www.topk.io/blog/20260311-smve-multi-vector-retrieval) inside [TopK](https://topk.io).
|
| 98 |
|
| 99 |
## Usage
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 100 |
Install PyLate for embeddings and TopK SDK for retrieval.
|
| 101 |
```
|
| 102 |
pip install -U pylate topk-sdk
|
|
|
|
| 6 |
tags:
|
| 7 |
- SMVE
|
| 8 |
- ColBERT
|
| 9 |
+
- multi-vector
|
| 10 |
- PyLate
|
| 11 |
- sentence-transformers
|
| 12 |
- sentence-similarity
|
|
|
|
| 98 |
[Sparse Multi-Vector Encoding (SMVE)](https://www.topk.io/blog/20260311-smve-multi-vector-retrieval) inside [TopK](https://topk.io).
|
| 99 |
|
| 100 |
## Usage
|
| 101 |
+
|
| 102 |
+
### Sentence Transformers
|
| 103 |
+
|
| 104 |
+
This model can be used with [Sentence Transformers](https://www.sbert.net/) as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
|
| 105 |
+
|
| 106 |
+
```bash
|
| 107 |
+
pip install "sentence-transformers>=6.0.0"
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
```python
|
| 111 |
+
from sentence_transformers import MultiVectorEncoder
|
| 112 |
+
|
| 113 |
+
model = MultiVectorEncoder("topk-io/Iso-ModernColBERT")
|
| 114 |
+
|
| 115 |
+
query = "Which planet is known as the Red Planet?"
|
| 116 |
+
documents = [
|
| 117 |
+
"Venus is often called Earth's twin because of its similar size and proximity.",
|
| 118 |
+
"Mars, known for its reddish appearance, is often referred to as the Red Planet.",
|
| 119 |
+
"Jupiter, the largest planet in our solar system, has a prominent red spot.",
|
| 120 |
+
"Saturn, famous for its rings, is sometimes mistaken for the Red Planet.",
|
| 121 |
+
]
|
| 122 |
+
|
| 123 |
+
query_embeddings = model.encode_query(query)
|
| 124 |
+
document_embeddings = model.encode_document(documents)
|
| 125 |
+
print(query_embeddings.shape, document_embeddings[0].shape)
|
| 126 |
+
# (12, 128) (18, 128)
|
| 127 |
+
|
| 128 |
+
# MaxSim late-interaction scoring (higher is more relevant)
|
| 129 |
+
scores = model.similarity(query_embeddings, document_embeddings)
|
| 130 |
+
print(scores)
|
| 131 |
+
# tensor([[ 9.4844, 10.4180, 9.8516, 10.1953]])
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
### PyLate
|
| 135 |
+
|
| 136 |
Install PyLate for embeddings and TopK SDK for retrieval.
|
| 137 |
```
|
| 138 |
pip install -U pylate topk-sdk
|