A supervised baseline:
all-MiniLM-L6-v2fine-tuned with MultipleNegativesRankingLoss on ESCI relevance labels (not bag-derived), used as a comparison point for the bag-of-documents retrieval research.
SentenceTransformer based on sentence-transformers/all-MiniLM-L6-v2
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.
Model Details
Model Description
- Model Type: Sentence Transformer
- Base model: sentence-transformers/all-MiniLM-L6-v2
- Maximum Sequence Length: 256 tokens
- Output Dimensionality: 384 dimensions
- Similarity Function: Cosine Similarity
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
Full Model Architecture
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()
)
Usage
Direct Usage (Sentence Transformers)
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 = [
'preservatives free eye drops',
'Refresh Plus Lubricant Eye Drops, Preservative-Free, 0.01 Fl Oz Single-Use Containers, 30 Count (Pack of 1)',
'Ocusoft Retaine MGD Ophthalmic Emulsion, Milky White Solution, 30 count Single Use Containers, 0.01 Fluid Ounce',
]
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.7632, 0.4848],
# [0.7632, 1.0000, 0.4949],
# [0.4848, 0.4949, 1.0000]])
Training Details
Training Dataset
Unnamed Dataset
- Size: 125,555 training samples
- Columns: sentence_0, sentence_1, and sentence_2
- Approximate statistics based on the first 1000 samples:
sentence_0 sentence_1 sentence_2 type string string string details min: 3 tokensmean: 6.87 tokensmax: 36 tokens min: 3 tokensmean: 26.27 tokensmax: 91 tokens min: 3 tokensmean: 26.04 tokensmax: 96 tokens - Samples:
sentence_0 sentence_1 sentence_2 e gift card App Store & iTunes Gift Cards - Email Delivery ASURION 4 Year Laptop Accident Protection Plan with Tech Support $600-699.99 mre's meals ready to eat military Ozark Outdoorz, LLC 2020 Pack Date/2025 Best by Date - XMRE 1300XT (Meals Ready to Eat) - 4 Pack Random 5000mAh Weather Radio,Solar Hand Crank Emergency Radio,NOAA/AM/FM Shortwave Outdoor Survival Portable Radio, Power Bank USB Charger,Flashlight/Reading Lamp,Headphone Jack,SOS nested magnesium glycinate chelate EquiLife - Full Spectrum Magnesium, Magnesium Glycinate, Boosts Mood, Promotes Restful Sleep, Improves Bone Health, Enhances Energy & Focus, Helps Steady Blood Pressure, Non-GMO, Vegan (90 Servings) Life Extension, Neuro-Mag, 90 Cápsulas vegetarianas - Loss: 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 }
Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 32num_train_epochs: 10per_device_eval_batch_size: 32multi_dataset_batch_sampler: round_robin
All Hyperparameters
per_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: {}
Training Logs
| Epoch | Step | Training Loss |
|---|---|---|
| 0.1274 | 500 | 0.9736 |
| 0.2548 | 1000 | 0.8578 |
| 0.3823 | 1500 | 0.8133 |
| 0.5097 | 2000 | 0.7662 |
| 0.6371 | 2500 | 0.7642 |
| 0.7645 | 3000 | 0.7438 |
| 0.8919 | 3500 | 0.7035 |
| 1.0194 | 4000 | 0.6752 |
| 1.1468 | 4500 | 0.6039 |
| 1.2742 | 5000 | 0.5819 |
| 1.4016 | 5500 | 0.5710 |
| 1.5291 | 6000 | 0.5514 |
| 1.6565 | 6500 | 0.5315 |
| 1.7839 | 7000 | 0.5164 |
| 1.9113 | 7500 | 0.5121 |
| 2.0387 | 8000 | 0.4657 |
| 2.1662 | 8500 | 0.3968 |
| 2.2936 | 9000 | 0.3996 |
| 2.4210 | 9500 | 0.3826 |
| 2.5484 | 10000 | 0.3845 |
| 2.6758 | 10500 | 0.3783 |
| 2.8033 | 11000 | 0.3745 |
| 2.9307 | 11500 | 0.3708 |
| 3.0581 | 12000 | 0.3310 |
| 3.1855 | 12500 | 0.2975 |
| 3.3129 | 13000 | 0.2886 |
| 3.4404 | 13500 | 0.2926 |
| 3.5678 | 14000 | 0.2910 |
| 3.6952 | 14500 | 0.2800 |
| 3.8226 | 15000 | 0.2918 |
| 3.9501 | 15500 | 0.2828 |
| 4.0775 | 16000 | 0.2514 |
| 4.2049 | 16500 | 0.2344 |
| 4.3323 | 17000 | 0.2299 |
| 4.4597 | 17500 | 0.2315 |
| 4.5872 | 18000 | 0.2357 |
| 4.7146 | 18500 | 0.2350 |
| 4.8420 | 19000 | 0.2358 |
| 4.9694 | 19500 | 0.2350 |
| 5.0968 | 20000 | 0.2065 |
| 5.2243 | 20500 | 0.1891 |
| 5.3517 | 21000 | 0.1934 |
| 5.4791 | 21500 | 0.1922 |
| 5.6065 | 22000 | 0.1962 |
| 5.7339 | 22500 | 0.1927 |
| 5.8614 | 23000 | 0.1853 |
| 5.9888 | 23500 | 0.1886 |
| 6.1162 | 24000 | 0.1669 |
| 6.2436 | 24500 | 0.1593 |
| 6.3710 | 25000 | 0.1661 |
| 6.4985 | 25500 | 0.1674 |
| 6.6259 | 26000 | 0.1651 |
| 6.7533 | 26500 | 0.1707 |
| 6.8807 | 27000 | 0.1619 |
| 7.0082 | 27500 | 0.1639 |
| 7.1356 | 28000 | 0.1431 |
| 7.2630 | 28500 | 0.1525 |
| 7.3904 | 29000 | 0.1479 |
| 7.5178 | 29500 | 0.1450 |
| 7.6453 | 30000 | 0.1430 |
| 7.7727 | 30500 | 0.1424 |
| 7.9001 | 31000 | 0.1467 |
| 8.0275 | 31500 | 0.1416 |
| 8.1549 | 32000 | 0.1287 |
| 8.2824 | 32500 | 0.1345 |
| 8.4098 | 33000 | 0.1349 |
| 8.5372 | 33500 | 0.1372 |
| 8.6646 | 34000 | 0.1344 |
| 8.7920 | 34500 | 0.1294 |
| 8.9195 | 35000 | 0.1324 |
| 9.0469 | 35500 | 0.1312 |
| 9.1743 | 36000 | 0.1295 |
| 9.3017 | 36500 | 0.1259 |
| 9.4292 | 37000 | 0.1316 |
| 9.5566 | 37500 | 0.1228 |
| 9.6840 | 38000 | 0.1277 |
| 9.8114 | 38500 | 0.1279 |
| 9.9388 | 39000 | 0.1228 |
Framework Versions
- Python: 3.14.4
- Sentence Transformers: 5.3.0
- Transformers: 5.4.0
- PyTorch: 2.11.0
- Accelerate: 1.13.0
- Datasets: 4.8.4
- Tokenizers: 0.22.2
Citation
BibTeX
Sentence Transformers
@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",
}
MultipleNegativesRankingLoss
@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},
}