Sentence Similarity
sentence-transformers
Safetensors
bert
feature-extraction
dense
Generated from Trainer
dataset_size:90000
loss:MultipleNegativesRankingLoss
Eval Results (legacy)
text-embeddings-inference
Instructions to use redis/model-a-baseline with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use redis/model-a-baseline with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("redis/model-a-baseline") sentences = [ "who is the publisher of the norton anthology american literature", "W. W. Norton & Company W. W. Norton & Company is an American publishing company based in New York City. It has been owned wholly by its employees since the early 1960s. The company is known for its \"Norton Anthologies\" (particularly The Norton Anthology of English Literature) and its texts in the Norton Critical Editions series, the latter of which are frequently assigned in university literature courses.", "New Orleans La Nouvelle-Orléans (New Orleans) was founded in Spring of 1718 (7 May has become the traditional date to mark the anniversary, but the actual day is unknown[25]) by the French Mississippi Company, under the direction of Jean-Baptiste Le Moyne de Bienville, on land inhabited by the Chitimacha. It was named for Philippe II, Duke of Orléans, who was Regent of the Kingdom of France at the time. His title came from the French city of Orléans.", "I Really Like You The music video was directed by Peter Glanz. Jepsen filmed part of the song's music video on 16 February 2015, in front of the Mondrian Hotel in Manhattan alongside Tom Hanks, Justin Bieber and a troupe of dancers. Also making cameo appearances in the video are Rudy Mancuso and Andrew B. Bachelor (A.K.A. King Bach), well-known users of the short-form video sharing application Vine. The video was released on 6 March 2015.[15] CBC Music's Nicolle Weeks described it as \"a more affable version\" of the music video for The Verve's \"Bitter Sweet Symphony\" (1997).[16] The music video has been rated as one of 10 Best Music Videos of 2015 (So Far) by the readers of Billboard.[17]" ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [4, 4] - Notebooks
- Google Colab
- Kaggle
Add new SentenceTransformer model
Browse files- 1_Pooling/config.json +3 -3
- README.md +233 -82
- config_sentence_transformers.json +1 -1
- modules.json +6 -0
1_Pooling/config.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
{
|
| 2 |
-
"word_embedding_dimension":
|
| 3 |
-
"pooling_mode_cls_token":
|
| 4 |
-
"pooling_mode_mean_tokens":
|
| 5 |
"pooling_mode_max_tokens": false,
|
| 6 |
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
"pooling_mode_weightedmean_tokens": false,
|
|
|
|
| 1 |
{
|
| 2 |
+
"word_embedding_dimension": 768,
|
| 3 |
+
"pooling_mode_cls_token": false,
|
| 4 |
+
"pooling_mode_mean_tokens": true,
|
| 5 |
"pooling_mode_max_tokens": false,
|
| 6 |
"pooling_mode_mean_sqrt_len_tokens": false,
|
| 7 |
"pooling_mode_weightedmean_tokens": false,
|
README.md
CHANGED
|
@@ -5,51 +5,124 @@ tags:
|
|
| 5 |
- feature-extraction
|
| 6 |
- dense
|
| 7 |
- generated_from_trainer
|
| 8 |
-
- dataset_size:
|
| 9 |
- loss:MultipleNegativesRankingLoss
|
| 10 |
-
base_model:
|
| 11 |
widget:
|
| 12 |
-
- source_sentence:
|
|
|
|
| 13 |
sentences:
|
| 14 |
-
-
|
| 15 |
-
|
| 16 |
-
-
|
| 17 |
-
-
|
|
|
|
|
|
|
| 18 |
sentences:
|
| 19 |
-
-
|
| 20 |
-
-
|
| 21 |
-
|
| 22 |
-
-
|
| 23 |
-
- source_sentence:
|
| 24 |
sentences:
|
| 25 |
-
-
|
| 26 |
-
|
| 27 |
-
-
|
| 28 |
-
-
|
|
|
|
|
|
|
| 29 |
sentences:
|
| 30 |
-
-
|
| 31 |
-
- How
|
| 32 |
-
-
|
| 33 |
-
|
|
|
|
| 34 |
sentences:
|
| 35 |
-
-
|
| 36 |
-
-
|
| 37 |
-
-
|
| 38 |
pipeline_tag: sentence-similarity
|
| 39 |
library_name: sentence-transformers
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
---
|
| 41 |
|
| 42 |
-
# SentenceTransformer based on
|
| 43 |
|
| 44 |
-
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [
|
| 45 |
|
| 46 |
## Model Details
|
| 47 |
|
| 48 |
### Model Description
|
| 49 |
- **Model Type:** Sentence Transformer
|
| 50 |
-
- **Base model:** [
|
| 51 |
- **Maximum Sequence Length:** 128 tokens
|
| 52 |
-
- **Output Dimensionality:**
|
| 53 |
- **Similarity Function:** Cosine Similarity
|
| 54 |
<!-- - **Training Dataset:** Unknown -->
|
| 55 |
<!-- - **Language:** Unknown -->
|
|
@@ -65,8 +138,9 @@ This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [p
|
|
| 65 |
|
| 66 |
```
|
| 67 |
SentenceTransformer(
|
| 68 |
-
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': '
|
| 69 |
-
(1): Pooling({'word_embedding_dimension':
|
|
|
|
| 70 |
)
|
| 71 |
```
|
| 72 |
|
|
@@ -85,23 +159,23 @@ Then you can load this model and run inference.
|
|
| 85 |
from sentence_transformers import SentenceTransformer
|
| 86 |
|
| 87 |
# Download from the 🤗 Hub
|
| 88 |
-
model = SentenceTransformer("
|
| 89 |
# Run inference
|
| 90 |
sentences = [
|
| 91 |
-
'
|
| 92 |
-
'
|
| 93 |
-
'
|
| 94 |
]
|
| 95 |
embeddings = model.encode(sentences)
|
| 96 |
print(embeddings.shape)
|
| 97 |
-
# [3,
|
| 98 |
|
| 99 |
# Get the similarity scores for the embeddings
|
| 100 |
similarities = model.similarity(embeddings, embeddings)
|
| 101 |
print(similarities)
|
| 102 |
-
# tensor([[
|
| 103 |
-
# [
|
| 104 |
-
# [
|
| 105 |
```
|
| 106 |
|
| 107 |
<!--
|
|
@@ -128,6 +202,32 @@ You can finetune this model on your own dataset.
|
|
| 128 |
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 129 |
-->
|
| 130 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 131 |
<!--
|
| 132 |
## Bias, Risks and Limitations
|
| 133 |
|
|
@@ -146,23 +246,49 @@ You can finetune this model on your own dataset.
|
|
| 146 |
|
| 147 |
#### Unnamed Dataset
|
| 148 |
|
| 149 |
-
* Size:
|
| 150 |
-
* Columns: <code>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 151 |
* Approximate statistics based on the first 1000 samples:
|
| 152 |
-
| |
|
| 153 |
-
|:--------|:----------------------------------------------------------------------------------|:---------------------------------------------------------------------------------|:----------------------------------------------------------------------------------
|
| 154 |
-
| type | string | string
|
| 155 |
-
| details | <ul><li>min:
|
| 156 |
* Samples:
|
| 157 |
-
|
|
| 158 |
-
|:----------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------|:-----------------------------------------------------------------------|
|
| 159 |
-
| <code>
|
| 160 |
-
| <code>
|
| 161 |
-
| <code>
|
| 162 |
* Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
|
| 163 |
```json
|
| 164 |
{
|
| 165 |
-
"scale":
|
| 166 |
"similarity_fct": "cos_sim",
|
| 167 |
"gather_across_devices": false
|
| 168 |
}
|
|
@@ -171,36 +297,49 @@ You can finetune this model on your own dataset.
|
|
| 171 |
### Training Hyperparameters
|
| 172 |
#### Non-Default Hyperparameters
|
| 173 |
|
| 174 |
-
- `
|
| 175 |
-
- `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
- `fp16`: True
|
| 177 |
-
- `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 178 |
|
| 179 |
#### All Hyperparameters
|
| 180 |
<details><summary>Click to expand</summary>
|
| 181 |
|
| 182 |
- `overwrite_output_dir`: False
|
| 183 |
- `do_predict`: False
|
| 184 |
-
- `eval_strategy`:
|
| 185 |
- `prediction_loss_only`: True
|
| 186 |
-
- `per_device_train_batch_size`:
|
| 187 |
-
- `per_device_eval_batch_size`:
|
| 188 |
- `per_gpu_train_batch_size`: None
|
| 189 |
- `per_gpu_eval_batch_size`: None
|
| 190 |
- `gradient_accumulation_steps`: 1
|
| 191 |
- `eval_accumulation_steps`: None
|
| 192 |
- `torch_empty_cache_steps`: None
|
| 193 |
-
- `learning_rate`:
|
| 194 |
-
- `weight_decay`: 0.
|
| 195 |
- `adam_beta1`: 0.9
|
| 196 |
- `adam_beta2`: 0.999
|
| 197 |
- `adam_epsilon`: 1e-08
|
| 198 |
-
- `max_grad_norm`: 1
|
| 199 |
-
- `num_train_epochs`: 3
|
| 200 |
-
- `max_steps`:
|
| 201 |
- `lr_scheduler_type`: linear
|
| 202 |
- `lr_scheduler_kwargs`: {}
|
| 203 |
-
- `warmup_ratio`: 0.
|
| 204 |
- `warmup_steps`: 0
|
| 205 |
- `log_level`: passive
|
| 206 |
- `log_level_replica`: warning
|
|
@@ -228,14 +367,14 @@ You can finetune this model on your own dataset.
|
|
| 228 |
- `tpu_num_cores`: None
|
| 229 |
- `tpu_metrics_debug`: False
|
| 230 |
- `debug`: []
|
| 231 |
-
- `dataloader_drop_last`:
|
| 232 |
-
- `dataloader_num_workers`:
|
| 233 |
-
- `dataloader_prefetch_factor`:
|
| 234 |
- `past_index`: -1
|
| 235 |
- `disable_tqdm`: False
|
| 236 |
- `remove_unused_columns`: True
|
| 237 |
- `label_names`: None
|
| 238 |
-
- `load_best_model_at_end`:
|
| 239 |
- `ignore_data_skip`: False
|
| 240 |
- `fsdp`: []
|
| 241 |
- `fsdp_min_num_params`: 0
|
|
@@ -245,23 +384,23 @@ You can finetune this model on your own dataset.
|
|
| 245 |
- `parallelism_config`: None
|
| 246 |
- `deepspeed`: None
|
| 247 |
- `label_smoothing_factor`: 0.0
|
| 248 |
-
- `optim`:
|
| 249 |
- `optim_args`: None
|
| 250 |
- `adafactor`: False
|
| 251 |
- `group_by_length`: False
|
| 252 |
- `length_column_name`: length
|
| 253 |
- `project`: huggingface
|
| 254 |
- `trackio_space_id`: trackio
|
| 255 |
-
- `ddp_find_unused_parameters`:
|
| 256 |
- `ddp_bucket_cap_mb`: None
|
| 257 |
- `ddp_broadcast_buffers`: False
|
| 258 |
- `dataloader_pin_memory`: True
|
| 259 |
- `dataloader_persistent_workers`: False
|
| 260 |
- `skip_memory_metrics`: True
|
| 261 |
- `use_legacy_prediction_loop`: False
|
| 262 |
-
- `push_to_hub`:
|
| 263 |
- `resume_from_checkpoint`: None
|
| 264 |
-
- `hub_model_id`:
|
| 265 |
- `hub_strategy`: every_save
|
| 266 |
- `hub_private_repo`: None
|
| 267 |
- `hub_always_push`: False
|
|
@@ -288,31 +427,43 @@ You can finetune this model on your own dataset.
|
|
| 288 |
- `neftune_noise_alpha`: None
|
| 289 |
- `optim_target_modules`: None
|
| 290 |
- `batch_eval_metrics`: False
|
| 291 |
-
- `eval_on_start`:
|
| 292 |
- `use_liger_kernel`: False
|
| 293 |
- `liger_kernel_config`: None
|
| 294 |
- `eval_use_gather_object`: False
|
| 295 |
- `average_tokens_across_devices`: True
|
| 296 |
- `prompts`: None
|
| 297 |
- `batch_sampler`: batch_sampler
|
| 298 |
-
- `multi_dataset_batch_sampler`:
|
| 299 |
- `router_mapping`: {}
|
| 300 |
- `learning_rate_mapping`: {}
|
| 301 |
|
| 302 |
</details>
|
| 303 |
|
| 304 |
### Training Logs
|
| 305 |
-
| Epoch | Step | Training Loss |
|
| 306 |
-
|:------:|:----:|:-------------:|
|
| 307 |
-
| 0
|
| 308 |
-
| 0.
|
| 309 |
-
| 0.
|
| 310 |
-
|
|
| 311 |
-
|
|
| 312 |
-
|
|
| 313 |
-
|
|
| 314 |
-
|
|
| 315 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 316 |
|
| 317 |
|
| 318 |
### Framework Versions
|
|
|
|
| 5 |
- feature-extraction
|
| 6 |
- dense
|
| 7 |
- generated_from_trainer
|
| 8 |
+
- dataset_size:359997
|
| 9 |
- loss:MultipleNegativesRankingLoss
|
| 10 |
+
base_model: sentence-transformers/all-mpnet-base-v2
|
| 11 |
widget:
|
| 12 |
+
- source_sentence: When do you use Ms. or Mrs.? Is one for a married woman and one
|
| 13 |
+
for one that's not married? Which one is for what?
|
| 14 |
sentences:
|
| 15 |
+
- When do you use Ms. or Mrs.? Is one for a married woman and one for one that's
|
| 16 |
+
not married? Which one is for what?
|
| 17 |
+
- Nations that do/does otherwise? Which one do I use?
|
| 18 |
+
- Why don't bikes have a gear indicator?
|
| 19 |
+
- source_sentence: Which ointment is applied to the face of UFC fighters at the commencement
|
| 20 |
+
of a bout? What does it do?
|
| 21 |
sentences:
|
| 22 |
+
- How can I save a Snapchat video that others posted?
|
| 23 |
+
- Which ointment is applied to the face of UFC fighters at the commencement of a
|
| 24 |
+
bout? What does it do?
|
| 25 |
+
- How do I get the body of a UFC Fighter?
|
| 26 |
+
- source_sentence: Do you love the life you live?
|
| 27 |
sentences:
|
| 28 |
+
- Can I do shoulder and triceps workout on same day? What other combinations like
|
| 29 |
+
this can I do?
|
| 30 |
+
- Do you love the life you're living?
|
| 31 |
+
- Where can you find an online TI-84 calculator?
|
| 32 |
+
- source_sentence: Ordered food on Swiggy 3 days ago.After accepting my money, said
|
| 33 |
+
no more on Menu! When if ever will I atleast get refund in cr card a/c?
|
| 34 |
sentences:
|
| 35 |
+
- Is getting to the Tel Aviv airport to catch a 5:30 AM flight very expensive?
|
| 36 |
+
- How do I die and make it look like an accident?
|
| 37 |
+
- Ordered food on Swiggy 3 days ago.After accepting my money, said no more on Menu!
|
| 38 |
+
When if ever will I atleast get refund in cr card a/c?
|
| 39 |
+
- source_sentence: How do you earn money on Quora?
|
| 40 |
sentences:
|
| 41 |
+
- What is a cheap healthy diet I can keep the same and eat every day?
|
| 42 |
+
- What are some things new employees should know going into their first day at Maximus?
|
| 43 |
+
- What is the best way to make money on Quora?
|
| 44 |
pipeline_tag: sentence-similarity
|
| 45 |
library_name: sentence-transformers
|
| 46 |
+
metrics:
|
| 47 |
+
- cosine_accuracy@1
|
| 48 |
+
- cosine_accuracy@3
|
| 49 |
+
- cosine_accuracy@5
|
| 50 |
+
- cosine_precision@1
|
| 51 |
+
- cosine_precision@3
|
| 52 |
+
- cosine_precision@5
|
| 53 |
+
- cosine_recall@1
|
| 54 |
+
- cosine_recall@3
|
| 55 |
+
- cosine_recall@5
|
| 56 |
+
- cosine_ndcg@10
|
| 57 |
+
- cosine_mrr@1
|
| 58 |
+
- cosine_mrr@5
|
| 59 |
+
- cosine_mrr@10
|
| 60 |
+
- cosine_map@100
|
| 61 |
+
model-index:
|
| 62 |
+
- name: SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
|
| 63 |
+
results:
|
| 64 |
+
- task:
|
| 65 |
+
type: information-retrieval
|
| 66 |
+
name: Information Retrieval
|
| 67 |
+
dataset:
|
| 68 |
+
name: val
|
| 69 |
+
type: val
|
| 70 |
+
metrics:
|
| 71 |
+
- type: cosine_accuracy@1
|
| 72 |
+
value: 0.831025
|
| 73 |
+
name: Cosine Accuracy@1
|
| 74 |
+
- type: cosine_accuracy@3
|
| 75 |
+
value: 0.903825
|
| 76 |
+
name: Cosine Accuracy@3
|
| 77 |
+
- type: cosine_accuracy@5
|
| 78 |
+
value: 0.9306
|
| 79 |
+
name: Cosine Accuracy@5
|
| 80 |
+
- type: cosine_precision@1
|
| 81 |
+
value: 0.831025
|
| 82 |
+
name: Cosine Precision@1
|
| 83 |
+
- type: cosine_precision@3
|
| 84 |
+
value: 0.301275
|
| 85 |
+
name: Cosine Precision@3
|
| 86 |
+
- type: cosine_precision@5
|
| 87 |
+
value: 0.18612000000000004
|
| 88 |
+
name: Cosine Precision@5
|
| 89 |
+
- type: cosine_recall@1
|
| 90 |
+
value: 0.831025
|
| 91 |
+
name: Cosine Recall@1
|
| 92 |
+
- type: cosine_recall@3
|
| 93 |
+
value: 0.903825
|
| 94 |
+
name: Cosine Recall@3
|
| 95 |
+
- type: cosine_recall@5
|
| 96 |
+
value: 0.9306
|
| 97 |
+
name: Cosine Recall@5
|
| 98 |
+
- type: cosine_ndcg@10
|
| 99 |
+
value: 0.8949476210025439
|
| 100 |
+
name: Cosine Ndcg@10
|
| 101 |
+
- type: cosine_mrr@1
|
| 102 |
+
value: 0.831025
|
| 103 |
+
name: Cosine Mrr@1
|
| 104 |
+
- type: cosine_mrr@5
|
| 105 |
+
value: 0.8695604166666618
|
| 106 |
+
name: Cosine Mrr@5
|
| 107 |
+
- type: cosine_mrr@10
|
| 108 |
+
value: 0.873754801587296
|
| 109 |
+
name: Cosine Mrr@10
|
| 110 |
+
- type: cosine_map@100
|
| 111 |
+
value: 0.8759213487912666
|
| 112 |
+
name: Cosine Map@100
|
| 113 |
---
|
| 114 |
|
| 115 |
+
# SentenceTransformer based on sentence-transformers/all-mpnet-base-v2
|
| 116 |
|
| 117 |
+
This is a [sentence-transformers](https://www.SBERT.net) model finetuned from [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2). It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
|
| 118 |
|
| 119 |
## Model Details
|
| 120 |
|
| 121 |
### Model Description
|
| 122 |
- **Model Type:** Sentence Transformer
|
| 123 |
+
- **Base model:** [sentence-transformers/all-mpnet-base-v2](https://huggingface.co/sentence-transformers/all-mpnet-base-v2) <!-- at revision e8c3b32edf5434bc2275fc9bab85f82640a19130 -->
|
| 124 |
- **Maximum Sequence Length:** 128 tokens
|
| 125 |
+
- **Output Dimensionality:** 768 dimensions
|
| 126 |
- **Similarity Function:** Cosine Similarity
|
| 127 |
<!-- - **Training Dataset:** Unknown -->
|
| 128 |
<!-- - **Language:** Unknown -->
|
|
|
|
| 138 |
|
| 139 |
```
|
| 140 |
SentenceTransformer(
|
| 141 |
+
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': 'MPNetModel'})
|
| 142 |
+
(1): Pooling({'word_embedding_dimension': 768, 'pooling_mode_cls_token': False, 'pooling_mode_mean_tokens': True, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
|
| 143 |
+
(2): Normalize()
|
| 144 |
)
|
| 145 |
```
|
| 146 |
|
|
|
|
| 159 |
from sentence_transformers import SentenceTransformer
|
| 160 |
|
| 161 |
# Download from the 🤗 Hub
|
| 162 |
+
model = SentenceTransformer("redis/model-a-baseline")
|
| 163 |
# Run inference
|
| 164 |
sentences = [
|
| 165 |
+
'How do you earn money on Quora?',
|
| 166 |
+
'What is the best way to make money on Quora?',
|
| 167 |
+
'What are some things new employees should know going into their first day at Maximus?',
|
| 168 |
]
|
| 169 |
embeddings = model.encode(sentences)
|
| 170 |
print(embeddings.shape)
|
| 171 |
+
# [3, 768]
|
| 172 |
|
| 173 |
# Get the similarity scores for the embeddings
|
| 174 |
similarities = model.similarity(embeddings, embeddings)
|
| 175 |
print(similarities)
|
| 176 |
+
# tensor([[1.0000, 0.9977, 0.0043],
|
| 177 |
+
# [0.9977, 1.0000, 0.0051],
|
| 178 |
+
# [0.0043, 0.0051, 1.0000]])
|
| 179 |
```
|
| 180 |
|
| 181 |
<!--
|
|
|
|
| 202 |
*List how the model may foreseeably be misused and address what users ought not to do with the model.*
|
| 203 |
-->
|
| 204 |
|
| 205 |
+
## Evaluation
|
| 206 |
+
|
| 207 |
+
### Metrics
|
| 208 |
+
|
| 209 |
+
#### Information Retrieval
|
| 210 |
+
|
| 211 |
+
* Dataset: `val`
|
| 212 |
+
* Evaluated with [<code>InformationRetrievalEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.InformationRetrievalEvaluator)
|
| 213 |
+
|
| 214 |
+
| Metric | Value |
|
| 215 |
+
|:-------------------|:-----------|
|
| 216 |
+
| cosine_accuracy@1 | 0.831 |
|
| 217 |
+
| cosine_accuracy@3 | 0.9038 |
|
| 218 |
+
| cosine_accuracy@5 | 0.9306 |
|
| 219 |
+
| cosine_precision@1 | 0.831 |
|
| 220 |
+
| cosine_precision@3 | 0.3013 |
|
| 221 |
+
| cosine_precision@5 | 0.1861 |
|
| 222 |
+
| cosine_recall@1 | 0.831 |
|
| 223 |
+
| cosine_recall@3 | 0.9038 |
|
| 224 |
+
| cosine_recall@5 | 0.9306 |
|
| 225 |
+
| **cosine_ndcg@10** | **0.8949** |
|
| 226 |
+
| cosine_mrr@1 | 0.831 |
|
| 227 |
+
| cosine_mrr@5 | 0.8696 |
|
| 228 |
+
| cosine_mrr@10 | 0.8738 |
|
| 229 |
+
| cosine_map@100 | 0.8759 |
|
| 230 |
+
|
| 231 |
<!--
|
| 232 |
## Bias, Risks and Limitations
|
| 233 |
|
|
|
|
| 246 |
|
| 247 |
#### Unnamed Dataset
|
| 248 |
|
| 249 |
+
* Size: 359,997 training samples
|
| 250 |
+
* Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
|
| 251 |
+
* Approximate statistics based on the first 1000 samples:
|
| 252 |
+
| | anchor | positive | negative |
|
| 253 |
+
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|
|
| 254 |
+
| type | string | string | string |
|
| 255 |
+
| details | <ul><li>min: 4 tokens</li><li>mean: 15.46 tokens</li><li>max: 49 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 15.52 tokens</li><li>max: 49 tokens</li></ul> | <ul><li>min: 5 tokens</li><li>mean: 16.99 tokens</li><li>max: 128 tokens</li></ul> |
|
| 256 |
+
* Samples:
|
| 257 |
+
| anchor | positive | negative |
|
| 258 |
+
|:--------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------------------------------------------------------------|
|
| 259 |
+
| <code>Shall I upgrade my iPhone 5s to iOS 10 final version?</code> | <code>Should I upgrade an iPhone 5s to iOS 10?</code> | <code>Whether extension of CA-articleship is to be served at same firm/company?</code> |
|
| 260 |
+
| <code>Is Donald Trump really going to be the president of United States?</code> | <code>Do you think Donald Trump could conceivably be the next President of the United States?</code> | <code>Since solid carbon dioxide is dry ice and incredibly cold, why doesn't it have an effect on global warming?</code> |
|
| 261 |
+
| <code>What are real tips to improve work life balance?</code> | <code>What are the best ways to create a work life balance?</code> | <code>How do you open a briefcase combination lock without the combination?</code> |
|
| 262 |
+
* Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
|
| 263 |
+
```json
|
| 264 |
+
{
|
| 265 |
+
"scale": 7.0,
|
| 266 |
+
"similarity_fct": "cos_sim",
|
| 267 |
+
"gather_across_devices": false
|
| 268 |
+
}
|
| 269 |
+
```
|
| 270 |
+
|
| 271 |
+
### Evaluation Dataset
|
| 272 |
+
|
| 273 |
+
#### Unnamed Dataset
|
| 274 |
+
|
| 275 |
+
* Size: 40,000 evaluation samples
|
| 276 |
+
* Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
|
| 277 |
* Approximate statistics based on the first 1000 samples:
|
| 278 |
+
| | anchor | positive | negative |
|
| 279 |
+
|:--------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|:----------------------------------------------------------------------------------|
|
| 280 |
+
| type | string | string | string |
|
| 281 |
+
| details | <ul><li>min: 6 tokens</li><li>mean: 15.71 tokens</li><li>max: 65 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 15.79 tokens</li><li>max: 65 tokens</li></ul> | <ul><li>min: 6 tokens</li><li>mean: 16.97 tokens</li><li>max: 78 tokens</li></ul> |
|
| 282 |
* Samples:
|
| 283 |
+
| anchor | positive | negative |
|
| 284 |
+
|:------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------|
|
| 285 |
+
| <code>Why were feathered dinosaur fossils only found in the last 20 years?</code> | <code>Why were feathered dinosaur fossils only found in the last 20 years?</code> | <code>Why are only few people aware that many dinosaurs had feathers?</code> |
|
| 286 |
+
| <code>If FOX News is the conservative news station, which cable news network is for liberals/progressives?</code> | <code>If FOX News is the conservative news station, which cable news network is for liberals/progressives?</code> | <code>How much did Fox News and conservative leaning media networks stoke the anger that contributed to Donald Trump's popularity?</code> |
|
| 287 |
+
| <code>How can guys last longer during sex?</code> | <code>How do I last longer in sex?</code> | <code>What is a permanent solution for rough and puffy hair?</code> |
|
| 288 |
* Loss: [<code>MultipleNegativesRankingLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#multiplenegativesrankingloss) with these parameters:
|
| 289 |
```json
|
| 290 |
{
|
| 291 |
+
"scale": 7.0,
|
| 292 |
"similarity_fct": "cos_sim",
|
| 293 |
"gather_across_devices": false
|
| 294 |
}
|
|
|
|
| 297 |
### Training Hyperparameters
|
| 298 |
#### Non-Default Hyperparameters
|
| 299 |
|
| 300 |
+
- `eval_strategy`: steps
|
| 301 |
+
- `per_device_train_batch_size`: 128
|
| 302 |
+
- `per_device_eval_batch_size`: 128
|
| 303 |
+
- `learning_rate`: 2e-05
|
| 304 |
+
- `weight_decay`: 0.0001
|
| 305 |
+
- `max_steps`: 5000
|
| 306 |
+
- `warmup_ratio`: 0.1
|
| 307 |
- `fp16`: True
|
| 308 |
+
- `dataloader_drop_last`: True
|
| 309 |
+
- `dataloader_num_workers`: 1
|
| 310 |
+
- `dataloader_prefetch_factor`: 1
|
| 311 |
+
- `load_best_model_at_end`: True
|
| 312 |
+
- `optim`: adamw_torch
|
| 313 |
+
- `ddp_find_unused_parameters`: False
|
| 314 |
+
- `push_to_hub`: True
|
| 315 |
+
- `hub_model_id`: redis/model-a-baseline
|
| 316 |
+
- `eval_on_start`: True
|
| 317 |
|
| 318 |
#### All Hyperparameters
|
| 319 |
<details><summary>Click to expand</summary>
|
| 320 |
|
| 321 |
- `overwrite_output_dir`: False
|
| 322 |
- `do_predict`: False
|
| 323 |
+
- `eval_strategy`: steps
|
| 324 |
- `prediction_loss_only`: True
|
| 325 |
+
- `per_device_train_batch_size`: 128
|
| 326 |
+
- `per_device_eval_batch_size`: 128
|
| 327 |
- `per_gpu_train_batch_size`: None
|
| 328 |
- `per_gpu_eval_batch_size`: None
|
| 329 |
- `gradient_accumulation_steps`: 1
|
| 330 |
- `eval_accumulation_steps`: None
|
| 331 |
- `torch_empty_cache_steps`: None
|
| 332 |
+
- `learning_rate`: 2e-05
|
| 333 |
+
- `weight_decay`: 0.0001
|
| 334 |
- `adam_beta1`: 0.9
|
| 335 |
- `adam_beta2`: 0.999
|
| 336 |
- `adam_epsilon`: 1e-08
|
| 337 |
+
- `max_grad_norm`: 1.0
|
| 338 |
+
- `num_train_epochs`: 3.0
|
| 339 |
+
- `max_steps`: 5000
|
| 340 |
- `lr_scheduler_type`: linear
|
| 341 |
- `lr_scheduler_kwargs`: {}
|
| 342 |
+
- `warmup_ratio`: 0.1
|
| 343 |
- `warmup_steps`: 0
|
| 344 |
- `log_level`: passive
|
| 345 |
- `log_level_replica`: warning
|
|
|
|
| 367 |
- `tpu_num_cores`: None
|
| 368 |
- `tpu_metrics_debug`: False
|
| 369 |
- `debug`: []
|
| 370 |
+
- `dataloader_drop_last`: True
|
| 371 |
+
- `dataloader_num_workers`: 1
|
| 372 |
+
- `dataloader_prefetch_factor`: 1
|
| 373 |
- `past_index`: -1
|
| 374 |
- `disable_tqdm`: False
|
| 375 |
- `remove_unused_columns`: True
|
| 376 |
- `label_names`: None
|
| 377 |
+
- `load_best_model_at_end`: True
|
| 378 |
- `ignore_data_skip`: False
|
| 379 |
- `fsdp`: []
|
| 380 |
- `fsdp_min_num_params`: 0
|
|
|
|
| 384 |
- `parallelism_config`: None
|
| 385 |
- `deepspeed`: None
|
| 386 |
- `label_smoothing_factor`: 0.0
|
| 387 |
+
- `optim`: adamw_torch
|
| 388 |
- `optim_args`: None
|
| 389 |
- `adafactor`: False
|
| 390 |
- `group_by_length`: False
|
| 391 |
- `length_column_name`: length
|
| 392 |
- `project`: huggingface
|
| 393 |
- `trackio_space_id`: trackio
|
| 394 |
+
- `ddp_find_unused_parameters`: False
|
| 395 |
- `ddp_bucket_cap_mb`: None
|
| 396 |
- `ddp_broadcast_buffers`: False
|
| 397 |
- `dataloader_pin_memory`: True
|
| 398 |
- `dataloader_persistent_workers`: False
|
| 399 |
- `skip_memory_metrics`: True
|
| 400 |
- `use_legacy_prediction_loop`: False
|
| 401 |
+
- `push_to_hub`: True
|
| 402 |
- `resume_from_checkpoint`: None
|
| 403 |
+
- `hub_model_id`: redis/model-a-baseline
|
| 404 |
- `hub_strategy`: every_save
|
| 405 |
- `hub_private_repo`: None
|
| 406 |
- `hub_always_push`: False
|
|
|
|
| 427 |
- `neftune_noise_alpha`: None
|
| 428 |
- `optim_target_modules`: None
|
| 429 |
- `batch_eval_metrics`: False
|
| 430 |
+
- `eval_on_start`: True
|
| 431 |
- `use_liger_kernel`: False
|
| 432 |
- `liger_kernel_config`: None
|
| 433 |
- `eval_use_gather_object`: False
|
| 434 |
- `average_tokens_across_devices`: True
|
| 435 |
- `prompts`: None
|
| 436 |
- `batch_sampler`: batch_sampler
|
| 437 |
+
- `multi_dataset_batch_sampler`: proportional
|
| 438 |
- `router_mapping`: {}
|
| 439 |
- `learning_rate_mapping`: {}
|
| 440 |
|
| 441 |
</details>
|
| 442 |
|
| 443 |
### Training Logs
|
| 444 |
+
| Epoch | Step | Training Loss | Validation Loss | val_cosine_ndcg@10 |
|
| 445 |
+
|:------:|:----:|:-------------:|:---------------:|:------------------:|
|
| 446 |
+
| 0 | 0 | - | 0.5241 | 0.8962 |
|
| 447 |
+
| 0.0889 | 250 | 0.5415 | 0.3965 | 0.8954 |
|
| 448 |
+
| 0.1778 | 500 | 0.4818 | 0.3813 | 0.8947 |
|
| 449 |
+
| 0.2667 | 750 | 0.4608 | 0.3722 | 0.8942 |
|
| 450 |
+
| 0.3556 | 1000 | 0.4481 | 0.3679 | 0.8947 |
|
| 451 |
+
| 0.4445 | 1250 | 0.4382 | 0.3637 | 0.8943 |
|
| 452 |
+
| 0.5334 | 1500 | 0.4357 | 0.3607 | 0.8943 |
|
| 453 |
+
| 0.6223 | 1750 | 0.4304 | 0.3590 | 0.8945 |
|
| 454 |
+
| 0.7112 | 2000 | 0.4258 | 0.3566 | 0.8949 |
|
| 455 |
+
| 0.8001 | 2250 | 0.4223 | 0.3542 | 0.8948 |
|
| 456 |
+
| 0.8890 | 2500 | 0.421 | 0.3527 | 0.8952 |
|
| 457 |
+
| 0.9780 | 2750 | 0.4182 | 0.3511 | 0.8952 |
|
| 458 |
+
| 1.0669 | 3000 | 0.4079 | 0.3493 | 0.8948 |
|
| 459 |
+
| 1.1558 | 3250 | 0.405 | 0.3488 | 0.8948 |
|
| 460 |
+
| 1.2447 | 3500 | 0.4032 | 0.3480 | 0.8946 |
|
| 461 |
+
| 1.3336 | 3750 | 0.4022 | 0.3480 | 0.8948 |
|
| 462 |
+
| 1.4225 | 4000 | 0.3999 | 0.3468 | 0.8948 |
|
| 463 |
+
| 1.5114 | 4250 | 0.4009 | 0.3465 | 0.8949 |
|
| 464 |
+
| 1.6003 | 4500 | 0.4005 | 0.3463 | 0.8949 |
|
| 465 |
+
| 1.6892 | 4750 | 0.3991 | 0.3459 | 0.8949 |
|
| 466 |
+
| 1.7781 | 5000 | 0.4008 | 0.3457 | 0.8949 |
|
| 467 |
|
| 468 |
|
| 469 |
### Framework Versions
|
config_sentence_transformers.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
{
|
| 2 |
-
"model_type": "SentenceTransformer",
|
| 3 |
"__version__": {
|
| 4 |
"sentence_transformers": "5.2.0",
|
| 5 |
"transformers": "4.57.3",
|
| 6 |
"pytorch": "2.9.1+cu128"
|
| 7 |
},
|
|
|
|
| 8 |
"prompts": {
|
| 9 |
"query": "",
|
| 10 |
"document": ""
|
|
|
|
| 1 |
{
|
|
|
|
| 2 |
"__version__": {
|
| 3 |
"sentence_transformers": "5.2.0",
|
| 4 |
"transformers": "4.57.3",
|
| 5 |
"pytorch": "2.9.1+cu128"
|
| 6 |
},
|
| 7 |
+
"model_type": "SentenceTransformer",
|
| 8 |
"prompts": {
|
| 9 |
"query": "",
|
| 10 |
"document": ""
|
modules.json
CHANGED
|
@@ -10,5 +10,11 @@
|
|
| 10 |
"name": "1",
|
| 11 |
"path": "1_Pooling",
|
| 12 |
"type": "sentence_transformers.models.Pooling"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
}
|
| 14 |
]
|
|
|
|
| 10 |
"name": "1",
|
| 11 |
"path": "1_Pooling",
|
| 12 |
"type": "sentence_transformers.models.Pooling"
|
| 13 |
+
},
|
| 14 |
+
{
|
| 15 |
+
"idx": 2,
|
| 16 |
+
"name": "2",
|
| 17 |
+
"path": "2_Normalize",
|
| 18 |
+
"type": "sentence_transformers.models.Normalize"
|
| 19 |
}
|
| 20 |
]
|