Sentence Similarity
Safetensors
Japanese
RAGatouille
bert
ColBERT

Add Sentence Transformers usage

#3
by tomaarsen HF Staff - opened
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -8,6 +8,8 @@ language:
8
  pipeline_tag: sentence-similarity
9
  tags:
10
  - ColBERT
 
 
11
  base_model:
12
  - cl-tohoku/bert-base-japanese-v3
13
  - bclavie/JaColBERT
@@ -161,6 +163,36 @@ RAG.search(query="QUERY")
161
  ```
162
 
163
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  # Citation
165
 
166
  If you'd like to cite this work, please cite the JaColBERT technical report:
 
8
  pipeline_tag: sentence-similarity
9
  tags:
10
  - ColBERT
11
+ - multi-vector
12
+ - sentence-transformers
13
  base_model:
14
  - cl-tohoku/bert-base-japanese-v3
15
  - bclavie/JaColBERT
 
163
  ```
164
 
165
 
166
+ ## Sentence Transformers
167
+
168
+ As of [Sentence Transformers](https://www.sbert.net/) v6.0.0, this model can also be loaded directly as a multi-vector (ColBERT-style late interaction) retriever via the `MultiVectorEncoder`:
169
+
170
+ ```bash
171
+ pip install "sentence-transformers>=6.0.0" fugashi unidic-lite
172
+ ```
173
+
174
+ ```python
175
+ from sentence_transformers import MultiVectorEncoder
176
+
177
+ model = MultiVectorEncoder("bclavie/JaColBERTv2")
178
+
179
+ query = "日本で一番高い山は何ですか?"
180
+ documents = [
181
+ "富士山は日本で最も高い山で、標高は3776メートルです。",
182
+ "東京は日本の首都で、世界最大の都市圏の一つです。",
183
+ ]
184
+
185
+ query_embeddings = model.encode_query(query)
186
+ document_embeddings = model.encode_document(documents)
187
+ print(query_embeddings.shape, document_embeddings[0].shape)
188
+ # torch.Size([32, 128]) torch.Size([21, 128])
189
+
190
+ # MaxSim late-interaction scoring (higher is more relevant)
191
+ scores = model.similarity(query_embeddings, document_embeddings)
192
+ print(scores)
193
+ # tensor([[29.9530, 16.4604]], device='cuda:0')
194
+ ```
195
+
196
  # Citation
197
 
198
  If you'd like to cite this work, please cite the JaColBERT technical report: