Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup
Paper
•
2101.06983
•
Published
•
1
This is a sentence-transformers model finetuned from Alibaba-NLP/gte-large-en-v1.5. It maps sentences & paragraphs to a 1024-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': 8192, 'do_lower_case': False}) with Transformer model: NewModel
(1): Pooling({'word_embedding_dimension': 1024, 'pooling_mode_cls_token': True, 'pooling_mode_mean_tokens': False, 'pooling_mode_max_tokens': False, 'pooling_mode_mean_sqrt_len_tokens': False, 'pooling_mode_weightedmean_tokens': False, 'pooling_mode_lasttoken': False, 'include_prompt': True})
)
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 = [
'steinel led floodlight with sensor xled home 1 silver led floodlights anylamp produced by steinel identifiers is 4007841002688 category of toolsandhomeimprovement',
'steinel led floodlight with sensor xled home 1 silver led lighting anylamp produced by steinel identifiers is 4007841002688 category of toolsandhomeimprovement',
'desk organizers quillcom durable bookends with reinforced rib designheavygauge steel construction9 height identifiers is 90117bebk category of officeproducts',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
ironwood pharmaceuticals inc class a a 1 full quote netdaniacom pharmaceuticals produced by source nasdaq identifiers is isinus46333x1081 category of automotive |
ironwood pharmaceuticals inc class a pharmaceuticals a 1 news netdaniacom produced by source nasdaq identifiers is isinus46333x1081 category of automotive |
873010s21 hp 600gb 12g 10k 25 dp sas hdd null price 873010s2110pack new 873010s21 600gb hdd 10 pack wholesale description10 x 600gb 25inch serial attached scsi sassff digitally signed ds 12g dual portenterprise hotplug 512n 10k hard drivein hpe drive tray as picturedfor g1g7 proliant sas serversgenuine number and firmwaregenuine certified drivepart numbers option part 873010b21 smartbuy 873010s21 produced by hp enterprise identifiers is 873010s2110pack category of computersandaccessories key specifications are specifications category proliant harddrive subcategory 10k generation sas part number 873010s2110pack products id 489761 type hard drive hotswap capacity 600gb interface serial attached scsi spindle speed 10000rpm ports dual port data transfer rate 12gbs bytes per sector 512n |
873010s21 hp 600gb 12g 10k 25 dp sas hdd null price 873010s21 new 873010s21 600gb hdd wholesale description600gb 25inch serial attached scsi sassff digitally signed ds 12g dual portenterprise hotplug 512n 10k hard drivein hpe drive tray as picturedfor g1g7 proliant sas serversgenuine number and firmwaregenuine certified drivepart numbers option part 873010b21 smartbuy 873010s21 produced by hp enterprise identifiers is 873010s21 category of computersandaccessories key specifications are specifications category proliant harddrive subcategory 10k generation sas part number 873010s21 products id 489758 type hard drive hotswap capacity 600gb interface serial attached scsi spindle speed 10000rpm ports dual port data transfer rate 12gbs bytes per sector 512n |
armrest fabric gb 2010 audi a4avant argentina market body middle front pr6e3gb model data prn0ln5fn2en2m gb identifiers is 8k0864207a category of automotive |
armrest fabric gb 2009 audi a5s5 coupesportback south africa market body middle front pr6e3gb model data coupeprn2e gb identifiers is 8k0864207a category of automotive |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
anchor and positive| anchor | positive | |
|---|---|---|
| type | string | string |
| details |
|
|
| anchor | positive |
|---|---|
rennline race hook front universal 8 in red each 2000 bmw 323i base wagon chassis panels sheet metal page 3 identifiers is rene01r8 category of automotive |
rennline race hook front universal 8 in red each 2000 bmw 323i base wagon chassis panels sheet metal page 3 identifiers is rene01r8 category of automotive |
happy new year 2017 peace patch icon card design vector image patch images over 13 000 happy new year 2017 greeting card design with varsity college typography and stitch patch peace symbol icon as number eps10 vector vector image identifiers is 14478945 category of officeproducts |
happy new year 2017 peace patch icon card design vector image happy new year 2017 greeting card design with varsity college typography and stitch patch peace symbol icon as number eps10 vector download a free preview or high quality adobe illustrator ai eps pdf resolution jpeg versions identifiers is 14478945 category of officeproducts |
hp deskjet d4155 cartridges for ink jet printers quillcom yields up to 399 pagessized and priced for occasional printingoriginal hp ink a little less ink at very affordable price identifiers is 901d8j33an category of officeproducts |
hp photosmart c4150 cartridges for ink jet printers quillcom yields up to 399 pagessized and priced for occasional printingoriginal hp ink a little less ink at very affordable price identifiers is 901d8j33an category of officeproducts |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepslearning_rate: 1e-05num_train_epochs: 2warmup_ratio: 0.1fp16: Trueauto_find_batch_size: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 8per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 1e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 2max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.1warmup_steps: 0log_level: passivelog_level_replica: warninglog_on_each_node: Truelogging_nan_inf_filter: Truesave_safetensors: Truesave_on_each_node: Falsesave_only_model: Falserestore_callback_states_from_checkpoint: Falseno_cuda: Falseuse_cpu: Falseuse_mps_device: Falseseed: 42data_seed: Nonejit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Falsedataloader_num_workers: 0dataloader_prefetch_factor: Nonepast_index: -1disable_tqdm: Falseremove_unused_columns: Truelabel_names: Noneload_best_model_at_end: Falseignore_data_skip: Falsefsdp: []fsdp_min_num_params: 0fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}fsdp_transformer_layer_cls_to_wrap: Noneaccelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}deepspeed: Nonelabel_smoothing_factor: 0.0optim: adamw_torchoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Nonehub_model_id: Nonehub_strategy: every_savehub_private_repo: Falsehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseeval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters: auto_find_batch_size: Truefull_determinism: Falsetorchdynamo: Noneray_scope: lastddp_timeout: 1800torch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Nonedispatch_batches: Nonesplit_batches: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseeval_use_gather_object: Falsebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | loss |
|---|---|---|---|
| 0.1990 | 7000 | 0.0057 | 0.0026 |
| 0.3981 | 14000 | 0.0019 | 0.0018 |
| 0.5971 | 21000 | 0.0016 | 0.0012 |
| 0.7962 | 28000 | 0.001 | 0.0009 |
| 0.9952 | 35000 | 0.001 | 0.0009 |
| 1.1943 | 42000 | 0.0007 | 0.0008 |
| 1.3933 | 49000 | 0.0004 | 0.0009 |
| 1.5924 | 56000 | 0.0003 | 0.0009 |
| 1.7914 | 63000 | 0.0002 | 0.0008 |
@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{gao2021scaling,
title={Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup},
author={Luyu Gao and Yunyi Zhang and Jiawei Han and Jamie Callan},
year={2021},
eprint={2101.06983},
archivePrefix={arXiv},
primaryClass={cs.LG}
}
Base model
Alibaba-NLP/gte-large-en-v1.5