Sentence Similarity
Safetensors
Japanese
RAGatouille
bert
ColBERT

Add Sentence Transformers usage

#1
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
  license: mit
@@ -163,6 +165,36 @@ RAG.search(query="What animation studio did Miyazaki found?")
163
  ```
164
 
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  # Citation
167
 
168
  If you'd like to cite this work, please cite the 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
  license: mit
 
165
  ```
166
 
167
 
168
+ ## Sentence Transformers
169
+
170
+ 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`:
171
+
172
+ ```bash
173
+ pip install "sentence-transformers>=6.0.0" fugashi unidic-lite
174
+ ```
175
+
176
+ ```python
177
+ from sentence_transformers import MultiVectorEncoder
178
+
179
+ model = MultiVectorEncoder("bclavie/JaColBERT")
180
+
181
+ query = "日本で一番高い山は何ですか?"
182
+ documents = [
183
+ "富士山は日本で最も高い山で、標高は3776メートルです。",
184
+ "東京は日本の首都で、世界最大の都市圏の一つです。",
185
+ ]
186
+
187
+ query_embeddings = model.encode_query(query)
188
+ document_embeddings = model.encode_document(documents)
189
+ print(query_embeddings.shape, document_embeddings[0].shape)
190
+ # torch.Size([32, 128]) torch.Size([21, 128])
191
+
192
+ # MaxSim late-interaction scoring (higher is more relevant)
193
+ scores = model.similarity(query_embeddings, document_embeddings)
194
+ print(scores)
195
+ # tensor([[28.1927, 16.7800]], device='cuda:0')
196
+ ```
197
+
198
  # Citation
199
 
200
  If you'd like to cite this work, please cite the technical report: