Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup
Paper
•
2101.06983
•
Published
•
1
This is a sentence-transformers model finetuned from answerdotai/ModernBERT-base on the al-atlas-moroccan-darija-pretraining-dataset dataset. 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.
SentenceTransformer(
(0): Transformer({'max_seq_length': 8192, 'do_lower_case': False}) with Transformer model: ModernBertModel
(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})
)
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("BounharAbdelaziz/ModernBERT-basemoroccan-arabic-epoch-2lr-0.0005batch-32")
# Run inference
sentences = [
'شحال للمطار؟',
'tachicart/mo_darija_merged',
"{'ar': 'كم سأدفع للوصول إلى المطار ؟'}",
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
text, dataset_source, and metadata| text | dataset_source | metadata | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| text | dataset_source | metadata |
|---|---|---|
سامي خضيرة : |
atlasia/facebook_darija_dataset |
{'pageName': "Football B'darija - فوتبول بالداريجة"} |
الأحداث كاتتطور بسرعة رهيبة ف بريتوريا !! |
atlasia/facebook_darija_dataset |
{'pageName': "Football B'darija - فوتبول بالداريجة"} |
الريال و تحدي جديد هاد الليلة باش يرجعو للمنافسة ف التشامبيانزليغ قدام خصم أقل ما يتقال عليه انو عتيد هو اتلانتا بيرغامو وليدات العبقري جيانبييرو غاسبيريني.. |
atlasia/facebook_darija_dataset |
{'pageName': "Football B'darija - فوتبول بالداريجة"} |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
text, dataset_source, and metadata| text | dataset_source | metadata | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| text | dataset_source | metadata |
|---|---|---|
كاين في اللاخر ديال هاد القاعة. انجيب ليك شويا دابا. و إلا حتاجيتي شي حاجا اخرى، قولها ليا. |
tachicart/mo_darija_merged |
{'ar': 'إنها في أخر القاعة . سوف آتي لك ببعض منها الآن . إذا أردت أي شيئاً آخر فقط أعلمني .'} |
واش كا دير التعديلات؟ |
tachicart/mo_darija_merged |
{'ar': 'هل تقومون بعمل تعديلات ؟'} |
بغينا ناخدو طابلة حدا الشرجم. |
tachicart/mo_darija_merged |
{'ar': 'نريد مائدة بجانب النافذة .'} |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
eval_strategy: stepsper_device_train_batch_size: 32per_device_eval_batch_size: 32learning_rate: 0.0005num_train_epochs: 2warmup_ratio: 0.03bf16: Trueoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 32per_device_eval_batch_size: 32per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 0.0005weight_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.03warmup_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: Truefp16: Falsefp16_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: Nonehub_always_push: Falsegradient_checkpointing: Falsegradient_checkpointing_kwargs: Noneinclude_inputs_for_metrics: Falseinclude_for_metrics: []eval_do_concat_batches: Truefp16_backend: autopush_to_hub_model_id: Nonepush_to_hub_organization: Nonemp_parameters: auto_find_batch_size: Falsefull_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: Falseuse_liger_kernel: Falseeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss | Validation Loss |
|---|---|---|---|
| 0.0114 | 1000 | 3.2165 | 3.9089 |
| 0.0227 | 2000 | 3.0702 | 3.4543 |
| 0.0341 | 3000 | 3.0376 | 3.5355 |
| 0.0454 | 4000 | 3.0205 | 3.4417 |
| 0.0568 | 5000 | 3.0262 | 3.4540 |
| 0.0681 | 6000 | 3.0141 | 3.4423 |
| 0.0795 | 7000 | 3.0152 | 3.4597 |
| 0.0908 | 8000 | 3.0089 | 3.4972 |
| 0.1022 | 9000 | 3.0201 | 3.4511 |
| 0.1135 | 10000 | 3.0043 | 3.4342 |
| 0.1249 | 11000 | 2.9931 | 3.4398 |
| 0.1362 | 12000 | 2.9955 | 3.4332 |
| 0.1476 | 13000 | 3.0002 | 3.4291 |
| 0.1590 | 14000 | 2.9924 | 3.4298 |
| 0.1703 | 15000 | 3.0046 | 3.4330 |
| 0.1817 | 16000 | 2.9917 | 3.4301 |
| 0.1930 | 17000 | 3.0091 | 3.4520 |
| 0.2044 | 18000 | 3.0021 | 3.4260 |
| 0.2157 | 19000 | 2.9968 | 3.4222 |
| 0.2271 | 20000 | 2.9966 | 3.4202 |
| 0.2384 | 21000 | 3.0037 | 3.4315 |
| 0.2498 | 22000 | 3.0024 | 3.4155 |
| 0.2611 | 23000 | 2.9916 | 3.4174 |
| 0.2725 | 24000 | 2.9891 | 3.4384 |
| 0.2839 | 25000 | 2.9956 | 3.4443 |
| 0.2952 | 26000 | 2.9966 | 3.4174 |
| 0.3066 | 27000 | 2.9927 | 3.4233 |
| 0.3179 | 28000 | 2.9895 | 3.4133 |
| 0.3293 | 29000 | 2.9924 | 3.4124 |
| 0.3406 | 30000 | 2.9879 | 3.4154 |
| 0.3520 | 31000 | 2.9952 | 3.4209 |
| 0.3633 | 32000 | 2.9901 | 3.4177 |
| 0.3747 | 33000 | 2.9913 | 3.4140 |
| 0.3860 | 34000 | 2.9985 | 3.4130 |
| 0.3974 | 35000 | 2.9953 | 3.4131 |
| 0.4087 | 36000 | 2.9987 | 3.4167 |
| 0.4201 | 37000 | 2.9917 | 3.4165 |
| 0.4315 | 38000 | 2.9908 | 3.4154 |
| 0.4428 | 39000 | 2.9866 | 3.4103 |
| 0.4542 | 40000 | 2.9931 | 3.4115 |
| 0.4655 | 41000 | 2.9807 | 3.4100 |
| 0.4769 | 42000 | 3.0011 | 3.4124 |
| 0.4882 | 43000 | 3.0037 | 3.4098 |
| 0.4996 | 44000 | 2.993 | 3.4082 |
| 0.5109 | 45000 | 3.0012 | 3.4181 |
| 0.5223 | 46000 | 3.0004 | 3.4117 |
| 0.5336 | 47000 | 3.0003 | 3.4090 |
| 0.5450 | 48000 | 2.9915 | 3.4055 |
| 0.5564 | 49000 | 2.9992 | 3.4034 |
| 0.5677 | 50000 | 2.9915 | 3.4061 |
| 0.5791 | 51000 | 3.0028 | 3.4055 |
| 0.5904 | 52000 | 2.9928 | 3.4027 |
| 0.6018 | 53000 | 2.9899 | 3.4076 |
| 0.6131 | 54000 | 2.9875 | 3.4032 |
| 0.6245 | 55000 | 2.9956 | 3.4044 |
| 0.6358 | 56000 | 2.9797 | 3.4011 |
| 0.6472 | 57000 | 2.988 | 3.4050 |
| 0.6585 | 58000 | 2.9832 | 3.4071 |
| 0.6699 | 59000 | 2.9889 | 3.4134 |
| 0.6812 | 60000 | 2.987 | 3.4057 |
| 0.6926 | 61000 | 3.0046 | 3.4094 |
| 0.7040 | 62000 | 2.984 | 3.4076 |
| 0.7153 | 63000 | 2.9834 | 3.4090 |
| 0.7267 | 64000 | 2.9932 | 3.4038 |
| 0.7380 | 65000 | 2.9829 | 3.4009 |
| 0.7494 | 66000 | 2.9976 | 3.4053 |
| 0.7607 | 67000 | 2.9868 | 3.3996 |
| 0.7721 | 68000 | 2.9925 | 3.3988 |
| 0.7834 | 69000 | 2.9935 | 3.4042 |
| 0.7948 | 70000 | 2.9877 | 3.4072 |
| 0.8061 | 71000 | 2.995 | 3.4045 |
| 0.8175 | 72000 | 2.9949 | 3.3988 |
| 0.8288 | 73000 | 2.9969 | 3.4013 |
| 0.8402 | 74000 | 3.0033 | 3.4027 |
| 0.8516 | 75000 | 2.99 | 3.4041 |
| 0.8629 | 76000 | 3.0038 | 3.3999 |
| 0.8743 | 77000 | 3.0072 | 3.4022 |
| 0.8856 | 78000 | 2.9878 | 3.4001 |
| 0.8970 | 79000 | 2.9821 | 3.3992 |
| 0.9083 | 80000 | 2.9921 | 3.3995 |
| 0.9197 | 81000 | 2.9959 | 3.3977 |
| 0.9310 | 82000 | 3.0004 | 3.3963 |
| 0.9424 | 83000 | 2.9784 | 3.4021 |
| 0.9537 | 84000 | 2.9923 | 3.3998 |
| 0.9651 | 85000 | 2.9836 | 3.3972 |
| 0.9765 | 86000 | 2.9949 | 3.3971 |
| 0.9878 | 87000 | 2.9925 | 3.3968 |
| 0.9992 | 88000 | 2.9777 | 3.3947 |
| 1.0105 | 89000 | 2.9785 | 3.3975 |
| 1.0219 | 90000 | 2.9988 | 3.3974 |
| 1.0332 | 91000 | 2.9898 | 3.3954 |
| 1.0446 | 92000 | 2.9866 | 3.3943 |
| 1.0559 | 93000 | 2.9909 | 3.3936 |
| 1.0673 | 94000 | 2.9843 | 3.3942 |
| 1.0786 | 95000 | 2.9858 | 3.3924 |
| 1.0900 | 96000 | 2.9942 | 3.3927 |
| 1.1013 | 97000 | 2.9955 | 3.3936 |
| 1.1127 | 98000 | 3.0003 | 3.3921 |
| 1.1241 | 99000 | 2.9878 | 3.3947 |
| 1.1354 | 100000 | 2.9972 | 3.3951 |
| 1.1468 | 101000 | 2.9874 | 3.3999 |
| 1.1581 | 102000 | 2.9828 | 3.3950 |
| 1.1695 | 103000 | 2.9956 | 3.3929 |
| 1.1808 | 104000 | 2.9886 | 3.3935 |
| 1.1922 | 105000 | 2.982 | 3.3921 |
| 1.2035 | 106000 | 2.9913 | 3.3916 |
| 1.2149 | 107000 | 2.9831 | 3.3924 |
| 1.2262 | 108000 | 2.9958 | 3.3926 |
| 1.2376 | 109000 | 2.9969 | 3.3924 |
| 1.2489 | 110000 | 2.9893 | 3.3920 |
| 1.2603 | 111000 | 2.9888 | 3.3936 |
| 1.2717 | 112000 | 2.9885 | 3.3925 |
| 1.2830 | 113000 | 2.9866 | 3.3913 |
| 1.2944 | 114000 | 2.9885 | 3.3907 |
| 1.3057 | 115000 | 2.9782 | 3.3917 |
| 1.3171 | 116000 | 2.9816 | 3.3907 |
| 1.3284 | 117000 | 2.9857 | 3.3923 |
| 1.3398 | 118000 | 2.9824 | 3.3925 |
| 1.3511 | 119000 | 2.9966 | 3.3911 |
| 1.3625 | 120000 | 2.9951 | 3.3923 |
| 1.3738 | 121000 | 2.9914 | 3.3907 |
| 1.3852 | 122000 | 2.9745 | 3.3916 |
| 1.3966 | 123000 | 3.0008 | 3.3928 |
| 1.4079 | 124000 | 2.9787 | 3.3942 |
| 1.4193 | 125000 | 2.9789 | 3.3929 |
| 1.4306 | 126000 | 2.9845 | 3.3928 |
| 1.4420 | 127000 | 2.9792 | 3.3919 |
| 1.4533 | 128000 | 2.9847 | 3.3911 |
| 1.4647 | 129000 | 2.9905 | 3.3910 |
| 1.4760 | 130000 | 2.9878 | 3.3916 |
| 1.4874 | 131000 | 2.987 | 3.3918 |
| 1.4987 | 132000 | 3.0025 | 3.3915 |
| 1.5101 | 133000 | 2.9829 | 3.3911 |
| 1.5214 | 134000 | 2.982 | 3.3914 |
| 1.5328 | 135000 | 2.9923 | 3.3912 |
| 1.5442 | 136000 | 2.9849 | 3.3918 |
| 1.5555 | 137000 | 3.0002 | 3.3917 |
| 1.5669 | 138000 | 2.9845 | 3.3918 |
| 1.5782 | 139000 | 2.9906 | 3.3923 |
| 1.5896 | 140000 | 2.9897 | 3.3921 |
| 1.6009 | 141000 | 2.9813 | 3.3919 |
| 1.6123 | 142000 | 2.9992 | 3.3919 |
| 1.6236 | 143000 | 2.9872 | 3.3919 |
| 1.6350 | 144000 | 2.9847 | 3.3919 |
| 1.6463 | 145000 | 2.994 | 3.3917 |
| 1.6577 | 146000 | 2.982 | 3.3916 |
| 1.6691 | 147000 | 2.9994 | 3.3914 |
| 1.6804 | 148000 | 2.9817 | 3.3914 |
| 1.6918 | 149000 | 2.9889 | 3.3914 |
| 1.7031 | 150000 | 2.9864 | 3.3914 |
| 1.7145 | 151000 | 2.9912 | 3.3913 |
| 1.7258 | 152000 | 2.9852 | 3.3912 |
| 1.7372 | 153000 | 2.987 | 3.3912 |
| 1.7485 | 154000 | 2.9762 | 3.3912 |
| 1.7599 | 155000 | 2.9864 | 3.3912 |
| 1.7712 | 156000 | 2.9947 | 3.3912 |
| 1.7826 | 157000 | 2.9937 | 3.3911 |
| 1.7939 | 158000 | 3.004 | 3.3912 |
| 1.8053 | 159000 | 2.9804 | 3.3912 |
| 1.8167 | 160000 | 2.9928 | 3.3912 |
| 1.8280 | 161000 | 2.9966 | 3.3912 |
| 1.8394 | 162000 | 2.9902 | 3.3912 |
| 1.8507 | 163000 | 2.9807 | 3.3912 |
| 1.8621 | 164000 | 2.9782 | 3.3911 |
| 1.8734 | 165000 | 2.9963 | 3.3912 |
| 1.8848 | 166000 | 2.9911 | 3.3911 |
| 1.8961 | 167000 | 2.9969 | 3.3911 |
| 1.9075 | 168000 | 2.9951 | 3.3911 |
| 1.9188 | 169000 | 2.9948 | 3.3911 |
| 1.9302 | 170000 | 2.9931 | 3.3911 |
| 1.9415 | 171000 | 2.9895 | 3.3911 |
| 1.9529 | 172000 | 2.9846 | 3.3911 |
| 1.9643 | 173000 | 2.9888 | 3.3911 |
| 1.9756 | 174000 | 2.9833 | 3.3911 |
| 1.9870 | 175000 | 2.9816 | 3.3911 |
| 1.9983 | 176000 | 2.9929 | 3.3911 |
@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
answerdotai/ModernBERT-base