Add Sentence Transformers usage

#1
by tomaarsen HF Staff - opened
Files changed (1) hide show
  1. README.md +36 -0
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