加载中…
加载中…
Bag-of-documents fine-tune of
all-MiniLM-L6-v2on the BestBuy 2012 ACM Hackathon clickthrough dataset (query -> clicked-SKU bags, MultipleNegativesRankingLoss). 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 = [
'microsoft office student',
'Microsoft Office Home and Student 2010 (Product Key Card) - Windows',
'Twenty - CD',
]
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.7084, -0.0283],
# [ 0.7084, 1.0000, -0.0393],
# [-0.0283, -0.0393, 1.0000]])
sentence_0, sentence_1, and sentence_2| sentence_0 | sentence_1 | sentence_2 | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| sentence_0 | sentence_1 | sentence_2 |
|---|---|---|
sonyporable dvd |
Sony - 9" Widescreen Portable DVD Player with Swivel Screen - Black |
Sony Ericsson - Cyber-Shot Mobile Phone (Unlocked) - Black |
blue ray drives |
LG - 14x Internal Blu-ray Disc Double-Layer DVD±RW/CD-RW Drive |
Samsung - Refurbished SpeedPlus 22x Internal Double-Layer DVD±RW/CD-RW Drive |
boardwalk empire season 1 |
Transformers: Dark of the Moon - Widescreen Dubbed Subtitle - DVD |
Asus - Xonar DS 7.1 Channels Sound Card |
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: 32num_train_epochs: 10per_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robinper_device_train_batch_size: 32num_train_epochs: 10max_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: 32prediction_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.0660 | 500 | 1.5004 |
| 0.1319 | 1000 | 1.3619 |
| 0.1979 | 1500 | 1.2997 |
| 0.2638 | 2000 | 1.2668 |
| 0.3298 | 2500 | 1.2644 |
| 0.3957 | 3000 | 1.2217 |
| 0.4617 | 3500 | 1.1974 |
| 0.5276 | 4000 | 1.1509 |
| 0.5936 | 4500 | 1.1375 |
| 0.6595 | 5000 | 1.0972 |
| 0.7255 | 5500 | 1.0952 |
| 0.7915 | 6000 | 1.0865 |
| 0.8574 | 6500 | 1.0440 |
| 0.9234 | 7000 | 1.0393 |
| 0.9893 | 7500 | 1.0047 |
| 1.0553 | 8000 | 0.9702 |
| 1.1212 | 8500 | 0.9571 |
| 1.1872 | 9000 | 0.9331 |
| 1.2531 | 9500 | 0.9373 |
| 1.3191 | 10000 | 0.8899 |
| 1.3850 | 10500 | 0.8995 |
| 1.4510 | 11000 | 0.8907 |
| 1.5170 | 11500 | 0.8648 |
| 1.5829 | 12000 | 0.8956 |
| 1.6489 | 12500 | 0.8712 |
| 1.7148 | 13000 | 0.8435 |
| 1.7808 | 13500 | 0.8381 |
| 1.8467 | 14000 | 0.8392 |
| 1.9127 | 14500 | 0.8212 |
| 1.9786 | 15000 | 0.8336 |
| 2.0446 | 15500 | 0.7688 |
| 2.1105 | 16000 | 0.7363 |
| 2.1765 | 16500 | 0.7304 |
| 2.2424 | 17000 | 0.7449 |
| 2.3084 | 17500 | 0.7310 |
| 2.3744 | 18000 | 0.7017 |
| 2.4403 | 18500 | 0.7134 |
| 2.5063 | 19000 | 0.7116 |
| 2.5722 | 19500 | 0.7085 |
| 2.6382 | 20000 | 0.7013 |
| 2.7041 | 20500 | 0.6862 |
| 2.7701 | 21000 | 0.7048 |
| 2.8360 | 21500 | 0.7106 |
| 2.9020 | 22000 | 0.6690 |
| 2.9679 | 22500 | 0.6692 |
| 3.0339 | 23000 | 0.6549 |
| 3.0999 | 23500 | 0.6064 |
| 3.1658 | 24000 | 0.6001 |
| 3.2318 | 24500 | 0.6160 |
| 3.2977 | 25000 | 0.6230 |
| 3.3637 | 25500 | 0.6168 |
| 3.4296 | 26000 | 0.6124 |
| 3.4956 | 26500 | 0.6064 |
| 3.5615 | 27000 | 0.5966 |
| 3.6275 | 27500 | 0.5970 |
| 3.6934 | 28000 | 0.5957 |
| 3.7594 | 28500 | 0.5758 |
| 3.8254 | 29000 | 0.5944 |
| 3.8913 | 29500 | 0.6091 |
| 3.9573 | 30000 | 0.5827 |
| 4.0232 | 30500 | 0.5627 |
| 4.0892 | 31000 | 0.5316 |
| 4.1551 | 31500 | 0.5260 |
| 4.2211 | 32000 | 0.5356 |
| 4.2870 | 32500 | 0.5200 |
| 4.3530 | 33000 | 0.5279 |
| 4.4189 | 33500 | 0.5216 |
| 4.4849 | 34000 | 0.5399 |
| 4.5509 | 34500 | 0.5405 |
| 4.6168 | 35000 | 0.5313 |
| 4.6828 | 35500 | 0.5025 |
| 4.7487 | 36000 | 0.5438 |
| 4.8147 | 36500 | 0.5182 |
| 4.8806 | 37000 | 0.5035 |
| 4.9466 | 37500 | 0.5313 |
| 5.0125 | 38000 | 0.5047 |
| 5.0785 | 38500 | 0.4640 |
| 5.1444 | 39000 | 0.4758 |
| 5.2104 | 39500 | 0.4756 |
| 5.2763 | 40000 | 0.4680 |
| 5.3423 | 40500 | 0.4724 |
| 5.4083 | 41000 | 0.4844 |
| 5.4742 | 41500 | 0.4728 |
| 5.5402 | 42000 | 0.4774 |
| 5.6061 | 42500 | 0.4779 |
| 5.6721 | 43000 | 0.4835 |
| 5.7380 | 43500 | 0.4780 |
| 5.8040 | 44000 | 0.4844 |
| 5.8699 | 44500 | 0.4832 |
| 5.9359 | 45000 | 0.4705 |
| 6.0018 | 45500 | 0.4726 |
| 6.0678 | 46000 | 0.4291 |
| 6.1338 | 46500 | 0.4427 |
| 6.1997 | 47000 | 0.4451 |
| 6.2657 | 47500 | 0.4265 |
| 6.3316 | 48000 | 0.4312 |
| 6.3976 | 48500 | 0.4321 |
| 6.4635 | 49000 | 0.4496 |
| 6.5295 | 49500 | 0.4494 |
| 6.5954 | 50000 | 0.4302 |
| 6.6614 | 50500 | 0.4343 |
| 6.7273 | 51000 | 0.4383 |
| 6.7933 | 51500 | 0.4334 |
| 6.8593 | 52000 | 0.4516 |
| 6.9252 | 52500 | 0.4335 |
| 6.9912 | 53000 | 0.4383 |
| 7.0571 | 53500 | 0.4149 |
| 7.1231 | 54000 | 0.4068 |
| 7.1890 | 54500 | 0.4050 |
| 7.2550 | 55000 | 0.3994 |
| 7.3209 | 55500 | 0.4156 |
| 7.3869 | 56000 | 0.4134 |
| 7.4528 | 56500 | 0.3972 |
| 7.5188 | 57000 | 0.4005 |
| 7.5848 | 57500 | 0.4231 |
| 7.6507 | 58000 | 0.3953 |
| 7.7167 | 58500 | 0.4096 |
| 7.7826 | 59000 | 0.4046 |
| 7.8486 | 59500 | 0.4136 |
| 7.9145 | 60000 | 0.4047 |
| 7.9805 | 60500 | 0.4022 |
| 8.0464 | 61000 | 0.3902 |
| 8.1124 | 61500 | 0.3929 |
| 8.1783 | 62000 | 0.3921 |
| 8.2443 | 62500 | 0.3826 |
| 8.3102 | 63000 | 0.3825 |
| 8.3762 | 63500 | 0.3873 |
| 8.4422 | 64000 | 0.3858 |
| 8.5081 | 64500 | 0.3787 |
| 8.5741 | 65000 | 0.3976 |
| 8.6400 | 65500 | 0.3970 |
| 8.7060 | 66000 | 0.3838 |
| 8.7719 | 66500 | 0.3764 |
| 8.8379 | 67000 | 0.3871 |
| 8.9038 | 67500 | 0.3913 |
| 8.9698 | 68000 | 0.3941 |
| 9.0357 | 68500 | 0.3885 |
| 9.1017 | 69000 | 0.3736 |
| 9.1677 | 69500 | 0.3656 |
| 9.2336 | 70000 | 0.3771 |
| 9.2996 | 70500 | 0.3759 |
| 9.3655 | 71000 | 0.3799 |
| 9.4315 | 71500 | 0.3785 |
| 9.4974 | 72000 | 0.3742 |
| 9.5634 | 72500 | 0.3631 |
| 9.6293 | 73000 | 0.3768 |
| 9.6953 | 73500 | 0.3708 |
| 9.7612 | 74000 | 0.3818 |
| 9.8272 | 74500 | 0.3755 |
| 9.8932 | 75000 | 0.3735 |
| 9.9591 | 75500 | 0.3888 |
@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},
}