tomaarsen HF Staff commited on
Commit
5b4fe76
·
verified ·
1 Parent(s): 9a6a17e

Fix architectures field, add Sentence Transformers usage

Browse files
Files changed (2) hide show
  1. README.md +35 -0
  2. config.json +1 -1
README.md CHANGED
@@ -11,6 +11,8 @@ language:
11
  pipeline_tag: sentence-similarity
12
  tags:
13
  - ColBERT
 
 
14
  base_model:
15
  - cl-tohoku/bert-base-japanese-v3
16
  - bclavie/JaColBERT
@@ -25,6 +27,39 @@ This model largely outperforms all previous approaches, including JaColBERTV2 mu
25
  This page will be updated with the full details and the model report in the next few days.
26
 
27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ```
29
  @misc{clavié2024jacolbertv25optimisingmultivectorretrievers,
30
  title={JaColBERTv2.5: Optimising Multi-Vector Retrievers to Create State-of-the-Art Japanese Retrievers with Constrained Resources},
 
11
  pipeline_tag: sentence-similarity
12
  tags:
13
  - ColBERT
14
+ - multi-vector
15
+ - sentence-transformers
16
  base_model:
17
  - cl-tohoku/bert-base-japanese-v3
18
  - bclavie/JaColBERT
 
27
  This page will be updated with the full details and the model report in the next few days.
28
 
29
 
30
+ ## Sentence Transformers
31
+
32
+ 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`:
33
+
34
+ ```bash
35
+ pip install "sentence-transformers>=6.0.0" fugashi unidic-lite
36
+ ```
37
+
38
+ ```python
39
+ from sentence_transformers import MultiVectorEncoder
40
+
41
+ model = MultiVectorEncoder("answerdotai/JaColBERTv2.5")
42
+
43
+ query = "日本で一番高い山は何ですか?"
44
+ documents = [
45
+ "富士山は日本で最も高い山で、標高は3776メートルです。",
46
+ "東京は日本の首都で、世界最大の都市圏の一つです。",
47
+ "北岳は南アルプスにある山で、日本で二番目に高い山です。",
48
+ "富士山は静岡県と山梨県にまたがる活火山です。",
49
+ ]
50
+
51
+ query_embeddings = model.encode_query(query)
52
+ document_embeddings = model.encode_document(documents)
53
+ print(query_embeddings.shape, document_embeddings[0].shape)
54
+ # torch.Size([32, 128]) torch.Size([21, 128])
55
+
56
+ # MaxSim late-interaction scoring (higher is more relevant)
57
+ scores = model.similarity(query_embeddings, document_embeddings)
58
+ print(scores)
59
+ # tensor([[30.6709, 28.9073, 29.6979, 29.0785]], device='cuda:0')
60
+ ```
61
+
62
+
63
  ```
64
  @misc{clavié2024jacolbertv25optimisingmultivectorretrievers,
65
  title={JaColBERTv2.5: Optimising Multi-Vector Retrievers to Create State-of-the-Art Japanese Retrievers with Constrained Resources},
config.json CHANGED
@@ -1,7 +1,7 @@
1
  {
2
  "_name_or_path": "./step_48003",
3
  "architectures": [
4
- "BertModel"
5
  ],
6
  "attention_probs_dropout_prob": 0.1,
7
  "classifier_dropout": null,
 
1
  {
2
  "_name_or_path": "./step_48003",
3
  "architectures": [
4
+ "HF_ColBERT"
5
  ],
6
  "attention_probs_dropout_prob": 0.1,
7
  "classifier_dropout": null,