Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
---
|
| 2 |
tags:
|
| 3 |
- sentence-transformers
|
|
@@ -48,42 +49,35 @@ model-index:
|
|
| 48 |
results:
|
| 49 |
- task:
|
| 50 |
type: semantic-similarity
|
| 51 |
-
name: Semantic Similarity
|
| 52 |
-
dataset:
|
| 53 |
-
name: Unknown
|
| 54 |
-
type: unknown
|
| 55 |
metrics:
|
| 56 |
- type: pearson_cosine
|
| 57 |
value: 0.4639747212598005
|
| 58 |
-
name:
|
| 59 |
- type: spearman_cosine
|
| 60 |
value: 0.4595105448711385
|
| 61 |
-
name:
|
| 62 |
---
|
| 63 |
|
| 64 |
# SentenceTransformer
|
| 65 |
|
| 66 |
-
|
| 67 |
|
| 68 |
-
##
|
| 69 |
|
| 70 |
-
###
|
| 71 |
-
- **
|
| 72 |
-
|
| 73 |
-
- **
|
| 74 |
-
- **
|
| 75 |
-
- **Similarity Function:** Cosine Similarity
|
| 76 |
-
<!-- - **Training Dataset:** Unknown -->
|
| 77 |
-
<!-- - **Language:** Unknown -->
|
| 78 |
-
<!-- - **License:** Unknown -->
|
| 79 |
|
| 80 |
-
###
|
| 81 |
|
| 82 |
-
- **
|
| 83 |
-
- **
|
| 84 |
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
| 85 |
|
| 86 |
-
###
|
| 87 |
|
| 88 |
```
|
| 89 |
SentenceTransformer(
|
|
@@ -92,23 +86,23 @@ SentenceTransformer(
|
|
| 92 |
)
|
| 93 |
```
|
| 94 |
|
| 95 |
-
##
|
| 96 |
|
| 97 |
-
###
|
| 98 |
|
| 99 |
-
|
| 100 |
|
| 101 |
```bash
|
| 102 |
pip install -U sentence-transformers
|
| 103 |
```
|
| 104 |
|
| 105 |
-
|
| 106 |
```python
|
| 107 |
from sentence_transformers import SentenceTransformer
|
| 108 |
|
| 109 |
-
#
|
| 110 |
model = SentenceTransformer("sentence_transformers_model_id")
|
| 111 |
-
#
|
| 112 |
sentences = [
|
| 113 |
'Comcast Class A shares were up 8 cents at $30.50 in morning trading on the Nasdaq Stock Market.',
|
| 114 |
'The stock rose 48 cents to $30 yesterday in Nasdaq Stock Market trading.',
|
|
@@ -118,7 +112,7 @@ embeddings = model.encode(sentences)
|
|
| 118 |
print(embeddings.shape)
|
| 119 |
# [3, 256]
|
| 120 |
|
| 121 |
-
#
|
| 122 |
similarities = model.similarity(embeddings, embeddings)
|
| 123 |
print(similarities)
|
| 124 |
# tensor([[1.0000, 0.5752, 0.2980],
|
|
@@ -126,91 +120,55 @@ print(similarities)
|
|
| 126 |
# [0.2980, 0.2161, 1.0000]])
|
| 127 |
```
|
| 128 |
|
| 129 |
-
|
| 130 |
-
### Direct Usage (Transformers)
|
| 131 |
-
|
| 132 |
-
<details><summary>Click to see the direct usage in Transformers</summary>
|
| 133 |
-
|
| 134 |
-
</details>
|
| 135 |
-
-->
|
| 136 |
-
|
| 137 |
-
<!--
|
| 138 |
-
### Downstream Usage (Sentence Transformers)
|
| 139 |
-
|
| 140 |
-
You can finetune this model on your own dataset.
|
| 141 |
-
|
| 142 |
-
<details><summary>Click to expand</summary>
|
| 143 |
-
|
| 144 |
-
</details>
|
| 145 |
-
-->
|
| 146 |
-
|
| 147 |
-
<!--
|
| 148 |
-
### Out-of-Scope Use
|
| 149 |
-
|
| 150 |
-
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 151 |
-
-->
|
| 152 |
-
|
| 153 |
-
## Evaluation
|
| 154 |
|
| 155 |
-
###
|
| 156 |
|
| 157 |
-
####
|
| 158 |
|
| 159 |
-
*
|
| 160 |
|
| 161 |
-
|
|
| 162 |
|:--------------------|:-----------|
|
| 163 |
| pearson_cosine | 0.464 |
|
| 164 |
| **spearman_cosine** | **0.4595** |
|
| 165 |
|
| 166 |
-
|
| 167 |
-
## Bias, Risks and Limitations
|
| 168 |
|
| 169 |
-
|
| 170 |
-
-->
|
| 171 |
|
| 172 |
-
|
| 173 |
-
### Recommendations
|
| 174 |
|
| 175 |
-
*
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
## Training Details
|
| 179 |
-
|
| 180 |
-
### Training Dataset
|
| 181 |
-
|
| 182 |
-
#### Unnamed Dataset
|
| 183 |
-
|
| 184 |
-
* Size: 5,749 training samples
|
| 185 |
-
* Columns: <code>sentence_0</code>, <code>sentence_1</code>, and <code>label</code>
|
| 186 |
-
* Approximate statistics based on the first 1000 samples:
|
| 187 |
| | sentence_0 | sentence_1 | label |
|
| 188 |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 189 |
-
|
|
| 190 |
-
|
|
| 191 |
-
*
|
| 192 |
| sentence_0 | sentence_1 | label |
|
| 193 |
|:----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:--------------------------------|
|
| 194 |
-
|
|
| 195 |
-
|
|
| 196 |
-
|
|
| 197 |
-
*
|
| 198 |
```json
|
| 199 |
{
|
| 200 |
"loss_fct": "torch.nn.modules.loss.MSELoss"
|
| 201 |
}
|
| 202 |
```
|
| 203 |
|
| 204 |
-
###
|
| 205 |
-
####
|
| 206 |
|
| 207 |
- `eval_strategy`: steps
|
| 208 |
- `per_device_train_batch_size`: 16
|
| 209 |
- `per_device_eval_batch_size`: 16
|
| 210 |
- `multi_dataset_batch_sampler`: round_robin
|
| 211 |
|
| 212 |
-
####
|
| 213 |
-
<details><summary>
|
| 214 |
|
| 215 |
- `overwrite_output_dir`: False
|
| 216 |
- `do_predict`: False
|
|
@@ -333,8 +291,8 @@ You can finetune this model on your own dataset.
|
|
| 333 |
|
| 334 |
</details>
|
| 335 |
|
| 336 |
-
###
|
| 337 |
-
|
|
| 338 |
|:------:|:----:|:-------------:|:---------------:|
|
| 339 |
| 1.0 | 360 | - | 0.2967 |
|
| 340 |
| 1.3889 | 500 | 0.11 | 0.3338 |
|
|
@@ -343,7 +301,7 @@ You can finetune this model on your own dataset.
|
|
| 343 |
| 3.0 | 1080 | - | 0.4595 |
|
| 344 |
|
| 345 |
|
| 346 |
-
###
|
| 347 |
- Python: 3.12.11
|
| 348 |
- Sentence Transformers: 5.1.0
|
| 349 |
- Transformers: 4.56.1
|
|
@@ -352,7 +310,7 @@ You can finetune this model on your own dataset.
|
|
| 352 |
- Datasets: 4.0.0
|
| 353 |
- Tokenizers: 0.22.0
|
| 354 |
|
| 355 |
-
##
|
| 356 |
|
| 357 |
### BibTeX
|
| 358 |
|
|
@@ -367,22 +325,4 @@ You can finetune this model on your own dataset.
|
|
| 367 |
publisher = "Association for Computational Linguistics",
|
| 368 |
url = "https://arxiv.org/abs/1908.10084",
|
| 369 |
}
|
| 370 |
-
```
|
| 371 |
-
|
| 372 |
-
<!--
|
| 373 |
-
## Glossary
|
| 374 |
-
|
| 375 |
-
*Clearly define terms in order to be accessible across audiences.*
|
| 376 |
-
-->
|
| 377 |
-
|
| 378 |
-
<!--
|
| 379 |
-
## Model Card Authors
|
| 380 |
-
|
| 381 |
-
*Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction.*
|
| 382 |
-
-->
|
| 383 |
-
|
| 384 |
-
<!--
|
| 385 |
-
## Model Card Contact
|
| 386 |
-
|
| 387 |
-
*Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors.*
|
| 388 |
-
-->
|
|
|
|
| 1 |
+
|
| 2 |
---
|
| 3 |
tags:
|
| 4 |
- sentence-transformers
|
|
|
|
| 49 |
results:
|
| 50 |
- task:
|
| 51 |
type: semantic-similarity
|
| 52 |
+
name: 意味的類似性 (Semantic Similarity)
|
|
|
|
|
|
|
|
|
|
| 53 |
metrics:
|
| 54 |
- type: pearson_cosine
|
| 55 |
value: 0.4639747212598005
|
| 56 |
+
name: ピアソン相関係数 (コサイン類似度)
|
| 57 |
- type: spearman_cosine
|
| 58 |
value: 0.4595105448711385
|
| 59 |
+
name: スピアマン相関係数 (コサイン類似度)
|
| 60 |
---
|
| 61 |
|
| 62 |
# SentenceTransformer
|
| 63 |
|
| 64 |
+
これは、訓練済みの[sentence-transformers](https://www.SBERT.net)モデルです。このモデルは、文と段落を256次元の密なベクトル空間にマッピングし、意味的テキスト類似性、意味検索、言い換えマイニング、テキスト分類、クラスタリングなどに使用できます。
|
| 65 |
|
| 66 |
+
## モデル詳細
|
| 67 |
|
| 68 |
+
### モデルの説明
|
| 69 |
+
- **モデルタイプ:** Sentence Transformer
|
| 70 |
+
- **最大シーケンス長:** 2048トークン
|
| 71 |
+
- **出力次元数:** 256次元
|
| 72 |
+
- **類似度関数:** コサイン類似度
|
|
|
|
|
|
|
|
|
|
|
|
|
| 73 |
|
| 74 |
+
### モデルのソース
|
| 75 |
|
| 76 |
+
- **ドキュメント:** [Sentence Transformers Documentation](https://sbert.net)
|
| 77 |
+
- **リポジトリ:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers)
|
| 78 |
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers)
|
| 79 |
|
| 80 |
+
### 完全なモデルアーキテクチャ
|
| 81 |
|
| 82 |
```
|
| 83 |
SentenceTransformer(
|
|
|
|
| 86 |
)
|
| 87 |
```
|
| 88 |
|
| 89 |
+
## 使用方法
|
| 90 |
|
| 91 |
+
### 直接使用 (Sentence Transformers)
|
| 92 |
|
| 93 |
+
まず、Sentence Transformersライブラリをインストールします:
|
| 94 |
|
| 95 |
```bash
|
| 96 |
pip install -U sentence-transformers
|
| 97 |
```
|
| 98 |
|
| 99 |
+
次に、このモデルをロードして推論を実行できます。
|
| 100 |
```python
|
| 101 |
from sentence_transformers import SentenceTransformer
|
| 102 |
|
| 103 |
+
# 🤗 Hubからダウンロード
|
| 104 |
model = SentenceTransformer("sentence_transformers_model_id")
|
| 105 |
+
# 推論を実行
|
| 106 |
sentences = [
|
| 107 |
'Comcast Class A shares were up 8 cents at $30.50 in morning trading on the Nasdaq Stock Market.',
|
| 108 |
'The stock rose 48 cents to $30 yesterday in Nasdaq Stock Market trading.',
|
|
|
|
| 112 |
print(embeddings.shape)
|
| 113 |
# [3, 256]
|
| 114 |
|
| 115 |
+
# 埋め込みベクトルの類似度スコアを取得
|
| 116 |
similarities = model.similarity(embeddings, embeddings)
|
| 117 |
print(similarities)
|
| 118 |
# tensor([[1.0000, 0.5752, 0.2980],
|
|
|
|
| 120 |
# [0.2980, 0.2161, 1.0000]])
|
| 121 |
```
|
| 122 |
|
| 123 |
+
## 評価
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
|
| 125 |
+
### メトリクス
|
| 126 |
|
| 127 |
+
#### 意味的類似性
|
| 128 |
|
| 129 |
+
* [<code>EmbeddingSimilarityEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.EmbeddingSimilarityEvaluator)で評価
|
| 130 |
|
| 131 |
+
| メトリクス | 値 |
|
| 132 |
|:--------------------|:-----------|
|
| 133 |
| pearson_cosine | 0.464 |
|
| 134 |
| **spearman_cosine** | **0.4595** |
|
| 135 |
|
| 136 |
+
## 訓練詳細
|
|
|
|
| 137 |
|
| 138 |
+
### 訓練データセット
|
|
|
|
| 139 |
|
| 140 |
+
#### 名称未設定のデータセット
|
|
|
|
| 141 |
|
| 142 |
+
* サイズ: 5,749 訓練サンプル
|
| 143 |
+
* カラム: `sentence_0`, `sentence_1`, `label`
|
| 144 |
+
* 最初の1000サンプルに基づくおおよその統計:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
| | sentence_0 | sentence_1 | label |
|
| 146 |
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------|
|
| 147 |
+
| 型 | string | string | float |
|
| 148 |
+
| 詳細 | <ul><li>最小: 6 トークン</li><li>平均: 14.76 トークン</li><li>最大: 55 トークン</li></ul> | <ul><li>最小: 6 トークン</li><li>平均: 14.73 トークン</li><li>最大: 57 トークン</li></ul> | <ul><li>最小: 0.0</li><li>平均: 0.55</li><li>最大: 1.0</li></ul> |
|
| 149 |
+
* サンプル:
|
| 150 |
| sentence_0 | sentence_1 | label |
|
| 151 |
|:----------------------------------------------------------------------------|:-------------------------------------------------------------------------------------|:--------------------------------|
|
| 152 |
+
| `Forecasters said warnings might go up for Cuba later Thursday.` | `Watches or warnings could be issued for eastern Cuba later on Thursday.` | `0.8` |
|
| 153 |
+
| `Death toll in Lebanon bombings rises to 47` | `1 suspect arrested after Lebanon car bombings kill 45` | `0.5599999904632569` |
|
| 154 |
+
| `Three dogs running on a racetrack.` | `Three dogs round a bend at a racetrack.` | `0.9600000381469727` |
|
| 155 |
+
* 損失関数: [<code>CosineSimilarityLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#cosinesimilarityloss) 以下のパラメータを使用:
|
| 156 |
```json
|
| 157 |
{
|
| 158 |
"loss_fct": "torch.nn.modules.loss.MSELoss"
|
| 159 |
}
|
| 160 |
```
|
| 161 |
|
| 162 |
+
### 訓練ハイパーパラメータ
|
| 163 |
+
#### デフォルト以外のハイパーパラメータ
|
| 164 |
|
| 165 |
- `eval_strategy`: steps
|
| 166 |
- `per_device_train_batch_size`: 16
|
| 167 |
- `per_device_eval_batch_size`: 16
|
| 168 |
- `multi_dataset_batch_sampler`: round_robin
|
| 169 |
|
| 170 |
+
#### すべてのハイパーパラメータ
|
| 171 |
+
<details><summary>クリックして展開</summary>
|
| 172 |
|
| 173 |
- `overwrite_output_dir`: False
|
| 174 |
- `do_predict`: False
|
|
|
|
| 291 |
|
| 292 |
</details>
|
| 293 |
|
| 294 |
+
### 訓練ログ
|
| 295 |
+
| エポック | ステップ | 訓練損失 | spearman_cosine |
|
| 296 |
|:------:|:----:|:-------------:|:---------------:|
|
| 297 |
| 1.0 | 360 | - | 0.2967 |
|
| 298 |
| 1.3889 | 500 | 0.11 | 0.3338 |
|
|
|
|
| 301 |
| 3.0 | 1080 | - | 0.4595 |
|
| 302 |
|
| 303 |
|
| 304 |
+
### フレームワークのバージョン
|
| 305 |
- Python: 3.12.11
|
| 306 |
- Sentence Transformers: 5.1.0
|
| 307 |
- Transformers: 4.56.1
|
|
|
|
| 310 |
- Datasets: 4.0.0
|
| 311 |
- Tokenizers: 0.22.0
|
| 312 |
|
| 313 |
+
## 引用
|
| 314 |
|
| 315 |
### BibTeX
|
| 316 |
|
|
|
|
| 325 |
publisher = "Association for Computational Linguistics",
|
| 326 |
url = "https://arxiv.org/abs/1908.10084",
|
| 327 |
}
|
| 328 |
+
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|