Loading…
Loading…
sentence-transformers/all-MiniLM-L6-v2The 6M-MNRL bag-of-documents retriever:
all-MiniLM-L6-v2fine-tuned with MultipleNegativesRankingLoss on ~1.9M bag-derived (query, document) pairs from the Amazon ESCI catalog. Part of the bag-of-documents retrieval research; see the live demo.
This is a sentence-transformers model finetuned from sentence-transformers/all-MiniLM-L6-v2. It maps sentences & paragraphs to a 384-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, text classification, clustering, and more.
SentenceTransformer(
(0): Transformer({'max_seq_length': 256, 'do_lower_case': False, 'architecture': 'BertModel'})
(1): Pooling({'word_embedding_dimension': 384, '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})
(2): Normalize()
)
First install the Sentence Transformers library:
pip install -U sentence-transformers
Then you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
sentences = [
'pet products for dogs',
'PetzPaw Pet Products All Natural Dog Treats Healthy Treats for Your Pet Made in the USA. No Grain, Wheat, Soy, Gluten. Great Tasting Beef Snacks for Any Breed - Perfect for Dog Training',
'Acacia Salad Tongs - 12" Wooden Salad Servers Wood Salad Serving Utensils - Wood Salad Spoon & Fork Set.',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, 0.6096, -0.0091],
# [ 0.6096, 1.0000, 0.0292],
# [-0.0091, 0.0292, 1.0000]])
sentence_0 and sentence_1| sentence_0 | sentence_1 | |
|---|---|---|
| type | string | string |
| details |
|
|
| sentence_0 | sentence_1 |
|---|---|
fall decor |
Thanksgiving Fall Decor for Home Pumpkin Fall Wreath Welcome Sign Front Door Decor Farmhouse Fall Door Hanger Wooden Sign with Berries for Home Autumn, Halloween, Thanksgiving Day Indoor Outdoor Wall |
bedding queen |
Cove Canopy Bed, QUEEN, BLACK |
marbles |
Verichy Flat Glass Marbles, 0.9LB 114PCS Mixed Color Flat Gems Table Scatter Decor Vase Filler Beads Aquarium Pebbles |
MultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}
per_device_train_batch_size: 64per_device_eval_batch_size: 64multi_dataset_batch_sampler: round_robinper_device_train_batch_size: 64num_train_epochs: 3max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0optim: adamw_torch_fusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1label_smoothing_factor: 0.0bf16: Falsefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: trackioeval_strategy: noper_device_eval_batch_size: 64prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}parallelism_config: Nonedataloader_drop_last: Falsedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: round_robinrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.0165 | 500 | 0.1228 |
| 0.0331 | 1000 | 0.0907 |
| 0.0496 | 1500 | 0.0782 |
| 0.0661 | 2000 | 0.0756 |
| 0.0827 | 2500 | 0.0704 |
| 0.0992 | 3000 | 0.0631 |
| 0.1157 | 3500 | 0.0643 |
| 0.1322 | 4000 | 0.0651 |
| 0.1488 | 4500 | 0.0611 |
| 0.1653 | 5000 | 0.0594 |
| 0.1818 | 5500 | 0.0593 |
| 0.1984 | 6000 | 0.0584 |
| 0.2149 | 6500 | 0.0558 |
| 0.2314 | 7000 | 0.0568 |
| 0.2480 | 7500 | 0.0548 |
| 0.2645 | 8000 | 0.0556 |
| 0.2810 | 8500 | 0.0533 |
| 0.2975 | 9000 | 0.0523 |
| 0.3141 | 9500 | 0.0551 |
| 0.3306 | 10000 | 0.0500 |
| 0.3471 | 10500 | 0.0514 |
| 0.3637 | 11000 | 0.0507 |
| 0.3802 | 11500 | 0.0484 |
| 0.3967 | 12000 | 0.0482 |
| 0.4133 | 12500 | 0.0519 |
| 0.4298 | 13000 | 0.0485 |
| 0.4463 | 13500 | 0.0464 |
| 0.4628 | 14000 | 0.0486 |
| 0.4794 | 14500 | 0.0477 |
| 0.4959 | 15000 | 0.0469 |
| 0.5124 | 15500 | 0.0463 |
| 0.5290 | 16000 | 0.0460 |
| 0.5455 | 16500 | 0.0461 |
| 0.5620 | 17000 | 0.0463 |
| 0.5786 | 17500 | 0.0449 |
| 0.5951 | 18000 | 0.0454 |
| 0.6116 | 18500 | 0.0456 |
| 0.6281 | 19000 | 0.0441 |
| 0.6447 | 19500 | 0.0444 |
| 0.6612 | 20000 | 0.0428 |
| 0.6777 | 20500 | 0.0452 |
| 0.6943 | 21000 | 0.0421 |
| 0.7108 | 21500 | 0.0442 |
| 0.7273 | 22000 | 0.0429 |
| 0.7439 | 22500 | 0.0429 |
| 0.7604 | 23000 | 0.0406 |
| 0.7769 | 23500 | 0.0411 |
| 0.7934 | 24000 | 0.0418 |
| 0.8100 | 24500 | 0.0412 |
| 0.8265 | 25000 | 0.0417 |
| 0.8430 | 25500 | 0.0425 |
| 0.8596 | 26000 | 0.0420 |
| 0.8761 | 26500 | 0.0407 |
| 0.8926 | 27000 | 0.0419 |
| 0.9092 | 27500 | 0.0374 |
| 0.9257 | 28000 | 0.0391 |
| 0.9422 | 28500 | 0.0393 |
| 0.9587 | 29000 | 0.0419 |
| 0.9753 | 29500 | 0.0408 |
| 0.9918 | 30000 | 0.0388 |
| 1.0083 | 30500 | 0.0357 |
| 1.0249 | 31000 | 0.0355 |
| 1.0414 | 31500 | 0.0363 |
| 1.0579 | 32000 | 0.0346 |
| 1.0745 | 32500 | 0.0351 |
| 1.0910 | 33000 | 0.0355 |
| 1.1075 | 33500 | 0.0349 |
| 1.1240 | 34000 | 0.0356 |
| 1.1406 | 34500 | 0.0353 |
| 1.1571 | 35000 | 0.0353 |
| 1.1736 | 35500 | 0.0368 |
| 1.1902 | 36000 | 0.0363 |
| 1.2067 | 36500 | 0.0351 |
| 1.2232 | 37000 | 0.0339 |
| 1.2398 | 37500 | 0.0341 |
| 1.2563 | 38000 | 0.0342 |
| 1.2728 | 38500 | 0.0342 |
| 1.2893 | 39000 | 0.0340 |
| 1.3059 | 39500 | 0.0350 |
| 1.3224 | 40000 | 0.0328 |
| 1.3389 | 40500 | 0.0354 |
| 1.3555 | 41000 | 0.0321 |
| 1.3720 | 41500 | 0.0326 |
| 1.3885 | 42000 | 0.0351 |
| 1.4051 | 42500 | 0.0339 |
| 1.4216 | 43000 | 0.0336 |
| 1.4381 | 43500 | 0.0328 |
| 1.4546 | 44000 | 0.0306 |
| 1.4712 | 44500 | 0.0338 |
| 1.4877 | 45000 | 0.0340 |
| 1.5042 | 45500 | 0.0327 |
| 1.5208 | 46000 | 0.0335 |
| 1.5373 | 46500 | 0.0335 |
| 1.5538 | 47000 | 0.0328 |
| 1.5704 | 47500 | 0.0327 |
| 1.5869 | 48000 | 0.0328 |
| 1.6034 | 48500 | 0.0305 |
| 1.6199 | 49000 | 0.0329 |
| 1.6365 | 49500 | 0.0314 |
| 1.6530 | 50000 | 0.0318 |
| 1.6695 | 50500 | 0.0333 |
| 1.6861 | 51000 | 0.0316 |
| 1.7026 | 51500 | 0.0322 |
| 1.7191 | 52000 | 0.0320 |
| 1.7357 | 52500 | 0.0342 |
| 1.7522 | 53000 | 0.0323 |
| 1.7687 | 53500 | 0.0329 |
| 1.7852 | 54000 | 0.0315 |
| 1.8018 | 54500 | 0.0324 |
| 1.8183 | 55000 | 0.0343 |
| 1.8348 | 55500 | 0.0340 |
| 1.8514 | 56000 | 0.0307 |
| 1.8679 | 56500 | 0.0311 |
| 1.8844 | 57000 | 0.0321 |
| 1.9010 | 57500 | 0.0317 |
| 1.9175 | 58000 | 0.0300 |
| 1.9340 | 58500 | 0.0313 |
| 1.9505 | 59000 | 0.0314 |
| 1.9671 | 59500 | 0.0311 |
| 1.9836 | 60000 | 0.0307 |
| 2.0001 | 60500 | 0.0325 |
| 2.0167 | 61000 | 0.0287 |
| 2.0332 | 61500 | 0.0290 |
| 2.0497 | 62000 | 0.0291 |
| 2.0663 | 62500 | 0.0308 |
| 2.0828 | 63000 | 0.0279 |
| 2.0993 | 63500 | 0.0278 |
| 2.1158 | 64000 | 0.0287 |
| 2.1324 | 64500 | 0.0292 |
| 2.1489 | 65000 | 0.0287 |
| 2.1654 | 65500 | 0.0293 |
| 2.1820 | 66000 | 0.0290 |
| 2.1985 | 66500 | 0.0305 |
| 2.2150 | 67000 | 0.0284 |
| 2.2316 | 67500 | 0.0296 |
| 2.2481 | 68000 | 0.0285 |
| 2.2646 | 68500 | 0.0279 |
| 2.2811 | 69000 | 0.0293 |
| 2.2977 | 69500 | 0.0281 |
| 2.3142 | 70000 | 0.0303 |
| 2.3307 | 70500 | 0.0281 |
| 2.3473 | 71000 | 0.0299 |
| 2.3638 | 71500 | 0.0294 |
| 2.3803 | 72000 | 0.0295 |
| 2.3969 | 72500 | 0.0271 |
| 2.4134 | 73000 | 0.0264 |
| 2.4299 | 73500 | 0.0281 |
| 2.4464 | 74000 | 0.0279 |
| 2.4630 | 74500 | 0.0288 |
| 2.4795 | 75000 | 0.0263 |
| 2.4960 | 75500 | 0.0291 |
| 2.5126 | 76000 | 0.0288 |
| 2.5291 | 76500 | 0.0277 |
| 2.5456 | 77000 | 0.0278 |
| 2.5622 | 77500 | 0.0278 |
| 2.5787 | 78000 | 0.0277 |
| 2.5952 | 78500 | 0.0285 |
| 2.6117 | 79000 | 0.0269 |
| 2.6283 | 79500 | 0.0279 |
| 2.6448 | 80000 | 0.0285 |
| 2.6613 | 80500 | 0.0283 |
| 2.6779 | 81000 | 0.0270 |
| 2.6944 | 81500 | 0.0275 |
| 2.7109 | 82000 | 0.0277 |
| 2.7275 | 82500 | 0.0275 |
| 2.7440 | 83000 | 0.0273 |
| 2.7605 | 83500 | 0.0278 |
| 2.7770 | 84000 | 0.0288 |
| 2.7936 | 84500 | 0.0286 |
| 2.8101 | 85000 | 0.0287 |
| 2.8266 | 85500 | 0.0267 |
| 2.8432 | 86000 | 0.0267 |
| 2.8597 | 86500 | 0.0272 |
| 2.8762 | 87000 | 0.0279 |
| 2.8928 | 87500 | 0.0276 |
| 2.9093 | 88000 | 0.0289 |
| 2.9258 | 88500 | 0.0297 |
| 2.9423 | 89000 | 0.0273 |
| 2.9589 | 89500 | 0.0285 |
| 2.9754 | 90000 | 0.0269 |
| 2.9919 | 90500 | 0.0285 |
@inproceedings{reimers-2019-sentence-bert,
title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
author = "Reimers, Nils and Gurevych, Iryna",
booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
month = "11",
year = "2019",
publisher = "Association for Computational Linguistics",
url = "https://arxiv.org/abs/1908.10084",
}
@misc{oord2019representationlearningcontrastivepredictive,
title={Representation Learning with Contrastive Predictive Coding},
author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
year={2019},
eprint={1807.03748},
archivePrefix={arXiv},
primaryClass={cs.LG},
url={https://arxiv.org/abs/1807.03748},
}