File size: 21,374 Bytes
b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f b68c261 6597b2f |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
---
language:
- ja
- en
license: mit
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:16897699
- loss:MatryoshkaLoss
- loss:MultipleNegativesRankingLoss
datasets:
- sentence-transformers/msmarco-co-condenser-margin-mse-sym-mnrl-mean-v1
- sentence-transformers/squad
- sentence-transformers/all-nli
- sentence-transformers/trivia-qa
- nthakur/swim-ir-monolingual
- sentence-transformers/miracl
- sentence-transformers/mr-tydi
- hotchpotch/sentence_transformer_japanese
library_name: sentence-transformers
---
以äžã®æç« ã¯ãããã°èšäºâïžããã®è»¢èŒã§ãã
# 100åéã§å®çšçãªæç« ãã¯ãã«ãäœãããæ¥æ¬èª StaticEmbedding ãå
Ž
æç« ã®å¯ãã¯ãã«ã¯ãæ
å ±æ€çŽ¢ã»æç« å€å¥ã»é¡äŒŒæç« æœåºãªã©ãããŸããŸãªçšéã«äœ¿ãããšãã§ããŸããããããªããæå
端ã®Transformerã¢ãã«ã¯å°ããã¢ãã«ã§ãããšãããCPUã§ã¯é
ããå€æé床ãå®çšã§ãªãããšããã°ãã°ã§ãã
ããããªãããå
æ¥å
¬éãããTransformerã¢ãã«ãã§ã¯ãªãã [StaticEmbedding](https://huggingface.co./blog/static-embeddings)ã¯ãäŸãã° [intfloat/multilingual-e5-small](https://huggingface.co./intfloat/multilingual-e5-small) (以äžmE5-small)ãšã®ãã³ãããŒã¯æ¯èŒã§ã¯85%ã®ã¹ã³ã¢ãšããå®çšã§ããæ§èœã§ããã€CPUã§åäœæã«126åé«éã«æãã¯ãã«ãäœæããããšãã§ããããšããé©ãã®é床ã§ãã
ãšããããã§ãæ©éæ¥æ¬èª(ãšè±èª)ã§åŠç¿ãããã¢ãã« sentence-embedding-japanese ãäœæããå
¬éããŸããã
- https://huggingface.co./hotchpotch/static-embedding-japanese
æ¥æ¬èªã®æç« ãã¯ãã«ã®æ§èœãè©äŸ¡ãã JMTEB ã®çµæã¯ä»¥äžã§ãã確ãã« mE5-small ã«ã¯è¥å¹²åã°ãªããŸã§ããã¿ã¹ã¯ã«ãã£ãŠã¯åã£ãŠãããããŸããã[ä»ã®æ¥æ¬èªbaseãµã€ãºbertã¢ãã«ãããã¹ã³ã¢ãé«ãããšããã](https://github.com/sbintuitions/JMTEB/blob/main/leaderboard.md)ããããæäœéå®çšã«éããŠããæ§èœãåºãŠããŸãããæ¬åœã«ãããªã«æ§èœåºãã®ãå®éã«åŠç¿ãããŠã¿ããŸã§åä¿¡åçã§ãããããããã§ããã
| Model | Avg(micro) | Retrieval | STS | Classification | Reranking | Clustering | PairClassification |
| ---------------------------------------- | ---------- | --------- | ----- | -------------- | --------- | ---------- | ------------------ |
| text-embedding-3-small | 69.18 | 66.39 | 79.46 | 73.06 | 92.92 | 51.06 | 62.27 |
| multilingual-e5-small | 67.71 | 67.27 | 80.07 | 67.62 | 93.03 | 46.91 | 62.19 |
| **static-embedding-japanese** | 66.66 | **67.92** | **80.16** | **67.96** | 91.87 | 35.83 | **62.37** |
ãªããStaticEmbedding æ¥æ¬èªã¢ãã«åŠç¿ãªã©ã®æè¡çãªããšã¯èšäºã®åŸåã«æžããŠããã®ã§ãèå³ãããæ¹ã¯ã©ããã
## å©çšæ¹æ³
å©çšã¯ç°¡åãSentenceTransformer ã䜿ã£ãŠãã€ãã®æ¹æ³ã§æãã¯ãã«ãäœããŸããä»åã¯GPUã䜿ãããCPUã§å®è¡ããŠã¿ãŸãããããªã SentenceTransformer 㯠3.3.1 ã§è©ŠããŠããŸãã
```
pip install "sentence-transformers>=3.3.1"
```
```python
from sentence_transformers import SentenceTransformer
model_name = "hotchpotch/static-embedding-japanese"
model = SentenceTransformer(model_name, device="cpu")
query = "çŸå³ããã©ãŒã¡ã³å±ã«è¡ããã"
docs = [
"çŽ æµãªã«ãã§ãè¿æã«ããããèœã¡çããé°å²æ°ã§ãã£ããã§ããããçªéã®åžããã¯å
¬åã®æ¯è²ãèŠãããã ã",
"æ°é®®ãªéä»ãæäŸããåºã§ããå°å
ã®æŒåž«ããçŽæ¥ä»å
¥ããŠããã®ã§é®®åºŠã¯æ矀ã§ãããæç人ã®è
ã確ãã§ãã",
"ãããã¯è¡ãã«ãããã©ãé ããè±éªšã®ååºã ããã¹ãŒããæé«ã ãã麺ã®ç¡¬ãã奜ã¿ã",
"ããããã®äžè¯ãã°ã®åºãæããŠãããããšããããã£ãŒã·ã¥ãŒãæäœãã§æããããŠãžã¥ãŒã·ãŒãªãã ã",
]
embeddings = model.encode([query] + docs)
print(embeddings.shape)
similarities = model.similarity(embeddings[0], embeddings[1:])
for i, similarity in enumerate(similarities[0].tolist()):
print(f"{similarity:.04f}: {docs[i]}")
```
```
(5, 1024)
0.1040: çŽ æµãªã«ãã§ãè¿æã«ããããèœã¡çããé°å²æ°ã§ãã£ããã§ããããçªéã®åžããã¯å
¬åã®æ¯è²ãèŠãããã ã
0.2521: æ°é®®ãªéä»ãæäŸããåºã§ããå°å
ã®æŒåž«ããçŽæ¥ä»å
¥ããŠããã®ã§é®®åºŠã¯æ矀ã§ãããæç人ã®è
ã確ãã§ãã
0.4835: ãããã¯è¡ãã«ãããã©ãé ããè±éªšã®ååºã ããã¹ãŒããæé«ã ãã麺ã®ç¡¬ãã奜ã¿ã
0.3199: ããããã®äžè¯ãã°ã®åºãæããŠãããããšããããã£ãŒã·ã¥ãŒãæäœãã§æããããŠãžã¥ãŒã·ãŒãªãã ã
```
ãã®ããã«ãqueryã«ãããããæç« ã®ã¹ã³ã¢ãé«ããªãããã«èšç®ã§ããŠãŸããããã®äŸæã§ã¯ãäŸãã°BM25ã§ã¯queryã«å«ãŸãããã©ãŒã¡ã³ãã®ãããªçŽæ¥çãªåèªãæç« ã«åºãŠããªããããããŸãããããããããšãé£ããã§ãããã
ãŸãé床ããCPUã§æãã¯ãã«ãäœã£ãæ¹ã¯å°ãªãæç« éã§ãã ãã¶æéãããããªããšããçµéšããããæ¹ãå€ããšæããŸãããStaticEmbedding ã¢ãã«ã§ã¯CPUãããããéããã°äžç¬ã§çµãããšæããŸããããã100åéã
## ãªãCPUã§æšè«ãé«éãªã®ïŒ
StaticEmbedding ã¯Transformerã¢ãã«ã§ã¯ãããŸãããã€ãŸãTrasformerã®ç¹åŸŽã§ããã¢ãã³ã·ã§ã³ã®èšç®ãäžåãªãã§ããæç« ã«åºãŠããåèªããŒã¯ã³ã1024次å
ã®ããŒãã«ã«ä¿åããŠãæãã¯ãã«ã§ã¯ããã®å¹³åããšã£ãŠããã ãã§ãããªããã¢ãã³ã·ã§ã³ããªãã®ã§ãæèã®ç解ãªã©ã¯ããŠããŸããã
ãŸã PyTorch ã® nn.EmbeddingBag ã䜿ã£ãŠãå
šãŠãé£çµããããŒã¯ã³ãšãªãã»ãããæž¡ããŠåŠçããããšã§ãPyTorch ã®æé©åã§é«éãªCPU䞊ååŠçãšã¡ã¢ãªã¢ã¯ã»ã¹ããããŠããããã§ãã
![](https://huggingface.co./datasets/huggingface/documentation-images/resolve/main/blog/static-embeddings/similarity_speed.png)
[å
èšäºã®é床è©äŸ¡çµæã«ãããš](https://huggingface.co./blog/static-embeddings#multilingual-similarity-4)CPUã§ã¯mE5-smallãšæ¯ã¹ãŠ126åéãããã§ããã
## è©äŸ¡çµæ
JMTEBã§ã®å
šãŠã®è©äŸ¡çµæã¯[ãã¡ãJSONãã¡ã€ã«ã«èšèŒ](https://huggingface.co./hotchpotch/static-embedding-japanese/blob/main/JMTEB/summary.json)ããŠããŸãã[JMTEB Leaderboard](https://github.com/sbintuitions/JMTEB/blob/main/leaderboard.md)ã§èŠæ¯ã¹ããšãå·®ããããã§ããããJMTEBã®å
šäœã®è©äŸ¡çµæã¯ã¢ãã«ãµã€ãºãèãããšãããã¶ãè¯å¥œã§ãããªããJMTEB ã§è©äŸ¡ãããæ¹ã¯ãmr-tidy ã¿ã¹ã¯ã®700äžæç« ã®ãã¯ãã«åã«æéãããªãããã(ã¢ãã«ã«ããããŸããRTX4090ã§1~4æéã»ã©)ãšæããŸãããããStaticEmbeddingsã§ã¯éåžžã«éããRTX4090ã§ã¯çŽ4åã§åŠççµããããšãã§ããŸããã
### æ
å ±æ€çŽ¢ã§BM25ã®çœ®ãæããã§ãããã?
JMTEBã®äžã®æ
å ±æ€çŽ¢ã¿ã¹ã¯ã®[Retrievalã®çµæ](https://huggingface.co./hotchpotch/static-embedding-japanese/blob/main/JMTEB/summary.json)ãèŠãŠã¿ãŸããããStaticEmbedding ã§ã¯ mr-tidy ã®é
ç®ãèããæªãã§ãããmr-tidyã¯ä»ã®ã¿ã¹ã¯ã«æ¯ã¹ãŠæç« éãå§åçã«å€ã(700äžæç« )ãã€ãŸãæ倧éã®æç« ãæ€çŽ¢ãããããªã¿ã¹ã¯ã§ã¯çµæãæªãå¯èœæ§ãããããã§ããæèãç¡èŠãããåçŽãªããŒã¯ã³ã®å¹³åãªã®ã§ãå¢ããã°å¢ããã»ã©äŒŒãå¹³åã®æç« ãåºãŠãããšãããšãããããçµæã«ããªãåŸããã§ããã
ã®ã§ã倧éã®æç« ã®å ŽåãBM25ãããã ãã¶æ§èœãæªãå¯èœæ§ãããããã§ãããã ãå°ãªãæç« ã§ããã°ãã®åèªããããå°ãªãå Žåã¯ãBM25ãããè¯å¥œãªçµæã«ãªãããšãå€ããã§ããã
ãªãæ
å ±æ€çŽ¢ã¿ã¹ã¯ã® jaqket ã®çµæãä»ã®ã¢ãã«ã«å¯ŸããŠãããè¯ãã®ã¯ãJQaRa (dev, unused)ãåŠç¿ããŠãããããšãã£ãŠãé«ãããæãã§è¬ã§ããtest ã®æ
å ±ãªãŒã¯ã¯ããŠããªããšã¯æãã®ã§ããâŠã
### ã¯ã©ã¹ã¿ãªã³ã°çµæãæªã
ãã¡ãã詳现ã¯è¿œã£ãããŠããŸããããã¹ã³ã¢çã«ã¯ä»ã®ã¢ãã«ãããã ãã¶æªãçµæã§ãããã¯ã©ã¹åé¡ã¿ã¹ã¯ã¯æªããªãã®ã§äžæè°ã§ããåã蟌ã¿ç©ºéããããªã§ãŒã·ã«è¡šçŸåŠç¿ã§äœããã圱é¿ãããã®ã§ããããã
## JQaRA, JaCWIR ã§ã®ãªã©ã³ãã³ã°ã¿ã¹ã¯
[JQaRA](https://huggingface.co./datasets/hotchpotch/JQaRA) ã®çµæã¯ãã¡ãã
| model_names | ndcg@10 | mrr@10 |
|:-----------------------------------------------------------------------------------------|----------:|---------:|
| [static-embedding-japanese](https://huggingface.co./hotchpotch/static-embedding-japanese) | 0.4704 | 0.6814 |
| bm25 | 0.458 | 0.702 |
| [multilingual-e5-small](https://huggingface.co./intfloat/multilingual-e5-small) | 0.4917 | 0.7291 |
[JaCWIR](https://huggingface.co./datasets/hotchpotch/JaCWIR) ã®çµæã¯ãã¡ãã
| model_names | map@10 | hits@10 |
|:-----------------------------------------------------------------------------------------|---------:|----------:|
| [static-embedding-japanese](https://huggingface.co./hotchpotch/static-embedding-japanese) | 0.7642 | 0.9266 |
| bm25 | 0.8408 | 0.9528 |
| [multilingual-e5-small](https://huggingface.co./intfloat/multilingual-e5-small) | 0.869 | 0.97 |
JQaRa è©äŸ¡ã¯ BM25 ããã¯è¥å¹²è¯ããmE5-small ããã¯è¥å¹²äœããJaCWIR 㯠BM25, mE5ããã ãã¶äœãæãã®çµæã«ãªããŸããã
JaCWIR ã¯Webæç« ã®ã¿ã€ãã«ãšæŠèŠæãªã®ã§ãããããã綺éºãªãæç« ã§ã¯ãªãã±ãŒã¹ãå€ããtransformerã¢ãã«ã¯ãã€ãºã«åŒ·ãã®ã§ãåçŽãªããŒã¯ã³å¹³åã®StaticEmbeddingã§ã¯æªãçµæã«ãªãããã§ããBM25ã¯ç¹åŸŽçãªåèªã«ãããããããã®ã§ãJaCWIR ã§ããã€ãºãšãªããããªåèªã¯ã¯ãšãªã«ãããããªããããTransformer ã¢ãã«ãšç«¶äºåã®ããçµæ§è¯ãçµæãæ®ããŸãã
ãã®çµæãããStaticEmbedding 㯠Transformer / BM25 ã«æ¯ã¹ããã€ãºãå€ãå«ãæç« ã®å Žåã¯ã¹ã³ã¢ãæªãå¯èœæ§ããããŸãã
## åºå次å
ã®åæž
StaticEmbedding ã§åºåããã次å
ã¯ãåŠç¿æ¬¡ç¬¬ã§ããä»åäœæãããã®ã¯1024次å
ãšããããã®ãµã€ãºã§ãã次å
æ°ã倧ãããšãæšè«åŸã®ã¿ã¹ã¯(ã¯ã©ã¹ã¿ãªã³ã°ãæ
å ±æ€çŽ¢ãªã©)ã«èšç®ã³ã¹ããããã£ãŠããŸããŸããããããªãããåŠç¿æã«ãããªã§ãŒã·ã«è¡šçŸåŠç¿([Matryoshka Representation Learning(MRL)](https://arxiv.org/abs/2205.13147))ãããŠããããã1024次å
ãããã«å°ããªæ¬¡å
ãžãšç°¡åã«æ¬¡å
åæžãã§ããŸãã
MRLã¯ãåŠç¿æã«å
é ã®ãã¯ãã«ã»ã©éèŠãªæ¬¡å
ãæã£ãŠããããšã§ãäŸãã°1024次å
ã§ãå
é ã®32,64,128,256...次å
ã ãã䜿ã£ãŠåŸããåãæšãŠãã ãã§ãããçšåºŠè¯å¥œãªçµæã瀺ããŠããŸãã
![](https://huggingface.co./datasets/huggingface/documentation-images/resolve/main/blog/static-embeddings/nano_beir_matryoshka.png)
ãã®ã°ã©ãåç
§å
ã®[StaticEmbedding ã®èšäº](https://huggingface.co./blog/static-embeddings#matryoshka-evaluation)ã«ãããšã128次å
ã§91.87%, 256次å
ã§95.79%, 512次å
ã§98.53%ã®æ§èœãç¶æããŠããããã§ãã粟床ã«ãããŸã§ã·ãã¢ã§ã¯ãªããããã®åŸã®èšç®ã³ã¹ããäžãããå Žåãã¬ããšæ¬¡å
åæžããŠäœ¿ãããšããçšéã«ã䜿ãããã§ããã
## StaticEmbedding ã¢ãã«ãäœã£ãŠã¿ãŠ
æ£çŽãåçŽãªããŒã¯ã³ã®embeddingsã®å¹³åã§ãããªã«æ§èœåºãã®ãåä¿¡åçã ã£ãã®ã§ãããå®éã«åŠç¿ãããŠã¿ãŠã·ã³ãã«ãªã¢ãŒããã¯ãã£ãªã®ã«æ§èœã®é«ãã«ã³ã£ããããŸãããTransformer å
šçã®ãã®æ代ã«ãå€ãè¯ãåèªåã蟌ã¿ã®æŽ»çšã¢ãã«ã§ãå®äžçã§å©æŽ»çšã§ããããªã¢ãã«ã®åºçŸã«é©ããé ããŸããã
CPUã§ã®æšè«é床ãéãæãã¯ãã«äœæã¢ãã«ã¯ãããŒã«ã«CPUç°å¢ã§å€§éã®æç« ã®å€æãªã©ã¯ããšããããšããžããã€ã¹ã ã£ãããããã¯ãŒã¯ãé
ã(ãªã¢ãŒãã®æšè«ãµãŒããå©ããªã)ç°å¢ã ã£ãããè²ã
ãšæŽ»çšããããããããã§ããã
---
# StaticEmbedding æ¥æ¬èªã¢ãã«åŠç¿ã®ãã¯ãã«ã«ããŒã
## ãªãããŸãåŠç¿ã§ããã®ã
StaticEmbedding ã¯éåžžã«ã·ã³ãã«ã§ãæç« ãããŒã¯ãã€ãºããIDã§åèªã®åã蟌ã¿ãã¯ãã«ãæ ŒçŽãããŠããEmbeddingBagããŒãã«ããN次å
(ä»åã¯1024次å
)ã®ãã¯ãã«ãååŸãããã®å¹³åãåãã ãã§ãã
ãããŸã§ãåèªåã蟌ã¿ãã¯ãã«ãšããã°ãword2vec ã GloVe ã®ããã« Skip-gram ã CBOW ãçšããŠåèªã®åšèŸºãåŠç¿ããŠããŸãããããããStaticEmbedding ã§ã¯æç« å
šäœãçšããŠåŠç¿ããŠããŸãããŸãã察ç
§åŠç¿ã䜿ã£ãŠå€§éã®æç« ã巚倧ãããã§åŠç¿ããŠãããè¯ãåèªã®åã蟌ã¿è¡šçŸã®åŠç¿ã«æåããŠããããã§ãã
## åŠç¿ããŒã¿ã»ãã
æ¥æ¬èªã¢ãã«åŠç¿ã«ãããã察ç
§åŠç¿ã§å©çšã§ããããŒã¿ã»ãããšããŠã以äžãäœæã䜿çšããŸããã
- [hotchpotch/sentence_transformer_japanese](https://huggingface.co./datasets/hotchpotch/sentence_transformer_japanese)
- [SentenceTransformer ã§åŠç¿ããããã«ã©ã åãšæ§é ](https://sbert.net/docs/sentence_transformer/loss_overview.html)ã«æŽãããã®ã§ãã
- `(anchor, positive)`, `(anchor, positive, negative)`, `(anchor, positive, negative_1, ..., negative_n)` ãšãã£ãæ§é ã«ãªã£ãŠããŸãã
- 以äžã®ããŒã¿ã»ãããåºã« hotchpotch/sentence_transformer_japanese ãäœæããŸãããæ¯åºŠãªããããŒã¿ã»ããã®äœè
ã®æ¹ã
ã»ãšããã hpprc æ°ã«æè¬ã§ãã
- https://huggingface.co./datasets/hpprc/emb
- https://huggingface.co./datasets/hotchpotch/hpprc_emb-scores ã®ãªã©ã³ã«ãŒã¹ã³ã¢ã䜿çšããpositive(>=0.7) / negative(<=0.3) ã®ãã£ã«ã¿ãªã³ã°ãè¡ããŸããã
- https://huggingface.co./datasets/hpprc/llmjp-kaken
- https://huggingface.co./datasets/hpprc/msmarco-ja
- [https://huggingface.co./datasets/hotchpotch/msmarco-ja-hard-negatives](https://huggingface.co./datasets/hotchpotch/msmarco-ja-hard-negatives) ã®ãªã©ã³ã«ãŒã¹ã³ã¢ãçšããŠãpositive(>=0.7) / negative(<=0.3) ã®ãã£ã«ã¿ãªã³ã°ãè¡ããŸããã
- https://huggingface.co./datasets/hpprc/mqa-ja
- https://huggingface.co./datasets/hpprc/llmjp-warp-html
- äžèšã®äœæããããŒã¿ã»ããã®äžã§ã以äžã䜿çšããŸããããªããæ
å ±æ€çŽ¢ã匷åãããã£ããããæ
å ±æ€çŽ¢ã«é©ããããŒã¿ã»ããã®ããŒã¿ã¯ãªãŒã®ã¥ã¡ã³ããŒã·ã§ã³ã§ä»¶æ°ãå€ãã«åŠç¿ãããŠããŸãã
- httprc_auto-wiki-nli-triplet
- httprc_auto-wiki-qa
- httprc_auto-wiki-qa-nemotron
- httprc_auto-wiki-qa-pair
- httprc_baobab-wiki-retrieval
- httprc_janli-triplet
- httprc_jaquad
- httprc_jqara
- httprc_jsnli-triplet
- httprc_jsquad
- httprc_miracl
- httprc_mkqa
- httprc_mkqa-triplet
- httprc_mr-tydi
- httprc_nu-mnli-triplet
- httprc_nu-snli-triplet
- httprc_quiz-no-mori
- httprc_quiz-works
- httprc_snow-triplet
- httprc_llmjp-kaken
- httprc_llmjp_warp_html
- httprc_mqa_ja
- httprc_msmarco_ja
- è±èªããŒã¿ã»ããã«ã¯ã以äžã®ããŒã¿ã»ãããå©çšããŠããŸãã
- [sentence-transformers/msmarco-co-condenser-margin-mse-sym-mnrl-mean-v1](https://huggingface.co./datasets/sentence-transformers/msmarco-co-condenser-margin-mse-sym-mnrl-mean-v1)
- [sentence-transformers/squad](https://huggingface.co./datasets/sentence-transformers/squad)
- [sentence-transformers/all-nli](https://huggingface.co./datasets/sentence-transformers/all-nli)
- [sentence-transformers/trivia-qa](https://huggingface.co./datasets/sentence-transformers/trivia-qa)
- [nthakur/swim-ir-monolingual](https://huggingface.co./datasets/nthakur/swim-ir-monolingual)
- [sentence-transformers/miracl](https://huggingface.co./datasets/sentence-transformers/miracl)
- [sentence-transformers/mr-tydi](https://huggingface.co./datasets/sentence-transformers/mr-tydi)
## æ¥æ¬èªããŒã¯ãã€ã¶
StaticEmbedding ãåŠç¿ããããã«ã¯ãHuggingFace ã®ããŒã¯ãã€ã¶ã©ã€ãã©ãªã® tokenizer.json 圢åŒã§åŠçå¯èœãªããŒã¯ãã€ã¶ã䜿ããšç°¡åããã ã£ãã®ã§ã [hotchpotch/xlm-roberta-japanese-tokenizer](https://huggingface.co./hotchpotch/xlm-roberta-japanese-tokenizer) ãšããããŒã¯ãã€ã¶ãäœæããŸãããèªåœæ°ã¯ 32,768 ã§ãã
ãã®ããŒã¯ãã€ã¶ã¯ãwikipedia æ¥æ¬èªãwikipedia è±èª(ãµã³ããªã³ã°)ãcc-100(æ¥æ¬èª, ãµã³ããªã³ã°)ã®ããŒã¿ã unidic ã§åå²ããsentencepiece unigram ã§åŠç¿ãããã®ã§ããXLM-Roberta 圢åŒã®æ¥æ¬èªããŒã¯ãã€ã¶ãšããŠãæ©èœããŸããä»åã¯ãã®ããŒã¯ãã€ã¶ãå©çšããŸããã
## ãã€ããŒãã©ã¡ãŒã¿
[倧å
ã®åŠç¿ã³ãŒã](https://huggingface.co./blog/static-embeddings#english-retrieval-2)ãšã®å€æŽç¹ãã¡ã¢ã¯ä»¥äžã®éãã§ãã
- batch_size ã倧å
ã® 2048 ãã 6072 ã«èšå®ããŸããã
- 察ç
§åŠç¿ã§å·šå€§ãªããããåŠçãããšããåäžãããå
ã«ããžãã£ããšãã¬ãã£ããå«ãŸãããšåŠç¿ã«æªåœ±é¿ãäžããå¯èœæ§ããããŸãããããé²ãããã« [BatchSamplers.NO_DUPLICATES](https://sbert.net/docs/package_reference/sentence_transformer/sampler.html) ãªãã·ã§ã³ããããŸããããããããããµã€ãºã巚倧ã ãšåäžãããã«å«ããªãããã®ãµã³ããªã³ã°åŠçã«æéããããããšããããŸãã
- ä»å㯠`BatchSamplers.NO_DUPLICATES` ãæå®ããRTX4090 ã® 24GB ã«åãŸã 6072 ã«èšå®ããŸãããããããµã€ãºã¯ããã«å€§ããæ¹ãçµæãè¯ãå¯èœæ§ããããŸãã
- epochæ°ã1ãã2ã«å€æŽããŸãã
- 1ããã2ã®æ¹ãè¯ãçµæã«ãªããŸããããã ããããŒã¿ãµã€ãºããã£ãšå€§ãããã°ã1ã®æ¹ãè¯ãå¯èœæ§ããããŸãã
- ã¹ã±ãžã¥ãŒã©
- æšæºã®linearãããçµéšåã§ããè¯ããšæããcosineã«å€æŽããŸããã
- ãªããã£ãã€ã¶
- æšæºã®AdamW ã®ãŸãŸã§ããadafactorã«å€æŽããå ŽåãåæãæªããªããŸããã
- learning_rate
- 2e-1 ã®ãŸãŸã§ããå€ã巚倧ãããã®ã§ã¯ãªãããšçåã«æããŸããããäœããããšçµæãæªåããŸããã
- dataloader_prefetch_factor=4
- dataloader_num_workers=15
- ããŒã¯ãã€ãºãšããããµã³ãã©ã®ãµã³ããªã³ã°ã«æéããããããã倧ããã«èšå®ããŸããã
## åŠç¿ãªãœãŒã¹
- CPU
- Ryzen9 7950X
- GPU
- RTX4090
- memory
- 64GB
ãã®ãã·ã³ãªãœãŒã¹ã§ã®åŠç¿ã«ããã£ãæéã¯çŽ4æéã§ãããGPUã®ã³ã¢è² è·ã¯éåžžã«å°ãããä»ã®transformerã¢ãã«ã§ã¯åŠç¿æã«90%ååŸã§åŒµãä»ãã®ã«å¯ŸããŠãStaticEmbeddingã§ã¯ã»ãšãã©0%ã§ãããããã¯ã巚倧ãªããããGPUã¡ã¢ãªã«è»¢éããæéã倧åãå ããŠããããããšæãããŸãããã®ãããGPUã¡ã¢ãªã®åž¯åå¹
ãéããªãã°ãåŠç¿é床ãããã«åäžããå¯èœæ§ããããŸãã
## ãããªãæ§èœåäžãž
ä»åå©çšããããŒã¯ãã€ã¶ã¯StaticEmbeddingåãã«ç¹åãããã®ã§ã¯ãªããããããé©ããããŒã¯ãã€ã¶ã䜿çšããã°æ§èœãåäžããå¯èœæ§ããããŸããããããµã€ãºãããã«å·šå€§åããããšã§ãåŠç¿ã®å®å®æ§ãåäžããæ§èœåäžãèŠèŸŒãããããããŸããã
ãŸããããŸããŸãªãã¡ã€ã³ãåæããŒã¿ã»ãããå©çšãããªã©ãããå¹
åºãæç« ãªãœãŒã¹ãåŠç¿ã«çµã¿èŸŒãããšã§ããããªãæ§èœåäžãæåŸ
ã§ããŸãã
## 倧å
ã®åŠç¿ã³ãŒã
åŠç¿ã«äœ¿çšããã³ãŒãã¯ã以äžã§ MIT ã©ã€ã»ã³ã¹ã§å
¬éããŠããŸããã¹ã¯ãªãããå®è¡ããã°åçŸã§ãããã¯ã...!
- https://huggingface.co./hotchpotch/static-embedding-japanese/blob/main/trainer.py
## ã©ã€ã»ã³ã¹
static-embedding-japanese 㯠MIT ã©ã€ã»ã³ã¹ã§å
¬éããŠããŸãã
|