Scaling Deep Contrastive Learning Batch Size under Memory Limited Setup
Paper
•
2101.06983
•
Published
•
1
This is a sentence-transformers model finetuned from comet24082002/finetune_bge_simsce_V1. 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': 512, 'do_lower_case': False}) with Transformer model: XLMRobertaModel
(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})
(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("comet24082002/ft_bge_newLaw_CachedMultipleNegativeRankingLoss_SimSCE_V1_5epochs")
# Run inference
sentences = [
'Các tổ chức nào được phép kinh doanh ngoại hối ở Việt Nam?',
'"Điều 2. Giải thích từ ngữ\nTại Thông tư này, các từ ngữ dưới đây được hiểu như sau:\n1. Tổ chức tín dụng được phép hoạt động ngoại hối là các ngân hàng, tổ chức tín dụng phi ngân hàng và chi nhánh ngân hàng nước ngoài được kinh doanh, cung ứng dịch vụ ngoại hối (sau đây gọi là tổ chức tín dụng được phép).\n..."',
'"Điều 24. Mục đích sử dụng các quỹ\n...\n2. Mục đích sử dụng Quỹ:\n...\ne) Quỹ phúc lợi tập trung được trích lập từ lợi nhuận sau thuế của Công ty mẹ và nguồn đóng góp khác (nếu có). Quỹ phúc lợi được dùng để:\n- Đầu tư xây dựng hoặc sửa chữa các công trình phúc lợi của Công ty mẹ;\n- Chi cho các hoạt động phúc lợi của người lao động trong Công ty mẹ bao gồm cả người quản lý, kiểm soát viên của Công ty mẹ làm việc theo hợp đồng lao động và người quản lý, kiểm soát viên của Công ty mẹ do nhà nước bổ nhiệm;\n- Góp một phần vốn để đầu tư xây dựng các công trình phúc lợi chung trong ngành hoặc với các đơn vị khác theo hợp đồng;\n- Sử dụng một phần quỹ phúc lợi để trợ cấp khó khăn đột xuất cho những người lao động kể cả những trường hợp về hưu, về mất sức, lâm vào hoàn cảnh khó khăn, không nơi nương tựa hoặc làm công tác từ thiện xã hội;\n- Mức chi sử dụng quỹ do Tổng giám đốc Công ty mẹ quyết định được ghi trong quy chế quản lý, sử dụng quỹ của Công ty mẹ."',
]
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 |
|---|---|
Hội viên Hội Văn nghệ dân gian Việt Nam có những quyền hạn gì? |
Quyền của hội viên |
Giáo viên muốn xét thăng hạng giáo viên trung học cơ sở hạng I có cần được cấp chứng chỉ bồi dưỡng hay không? |
Giáo viên trung học cơ sở hạng I - Mã số V.07.04.30 |
Trong kinh doanh vận tải hành khách bằng xe buýt theo tuyến cố định, nhân viên xe buýt không giúp đỡ hành khách đi xe là người khuyết tật sẽ bị xử phạt thế nào? |
Xử phạt nhân viên phục vụ trên xe buýt, xe vận chuyển hành khách theo tuyến cố định, xe vận chuyển hành khách theo hợp đồng, xe vận chuyển khách du lịch vi phạm quy định về trật tự an toàn giao thông |
CachedMultipleNegativesRankingLoss with these parameters:{
"scale": 20.0,
"similarity_fct": "cos_sim"
}
per_device_train_batch_size: 256learning_rate: 2e-05num_train_epochs: 5warmup_ratio: 0.1overwrite_output_dir: Falsedo_predict: Falseeval_strategy: noprediction_loss_only: Trueper_device_train_batch_size: 256per_device_eval_batch_size: 8per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 5max_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: 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: 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: 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: Falsebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportional| Epoch | Step | Training Loss |
|---|---|---|
| 0.0476 | 2 | 1.5732 |
| 0.0952 | 4 | 1.6162 |
| 0.1429 | 6 | 1.3108 |
| 0.1905 | 8 | 1.0944 |
| 0.2381 | 10 | 0.8889 |
| 0.2857 | 12 | 0.7499 |
| 0.3333 | 14 | 0.601 |
| 0.3810 | 16 | 0.565 |
| 0.4286 | 18 | 0.4791 |
| 0.4762 | 20 | 0.4314 |
| 0.5238 | 22 | 0.4619 |
| 0.5714 | 24 | 0.3768 |
| 0.6190 | 26 | 0.4344 |
| 0.6667 | 28 | 0.3748 |
| 0.7143 | 30 | 0.3172 |
| 0.7619 | 32 | 0.3971 |
| 0.8095 | 34 | 0.2847 |
| 0.8571 | 36 | 0.3426 |
| 0.9048 | 38 | 0.4206 |
| 0.9524 | 40 | 0.276 |
| 1.0 | 42 | 0.1399 |
| 1.0476 | 44 | 0.2204 |
| 1.0952 | 46 | 0.2922 |
| 1.1429 | 48 | 0.2728 |
| 1.1905 | 50 | 0.2355 |
| 1.2381 | 52 | 0.2075 |
| 1.2857 | 54 | 0.2285 |
| 1.3333 | 56 | 0.2303 |
| 1.3810 | 58 | 0.2122 |
| 1.4286 | 60 | 0.2553 |
| 1.4762 | 62 | 0.2361 |
| 1.5238 | 64 | 0.2407 |
| 1.5714 | 66 | 0.2206 |
| 1.6190 | 68 | 0.2375 |
| 1.6667 | 70 | 0.2509 |
| 1.7143 | 72 | 0.1977 |
| 1.7619 | 74 | 0.2391 |
| 1.8095 | 76 | 0.1676 |
| 1.8571 | 78 | 0.3073 |
| 1.9048 | 80 | 0.2181 |
| 1.9524 | 82 | 0.265 |
| 2.0 | 84 | 0.1474 |
| 2.0476 | 86 | 0.1838 |
| 2.0952 | 88 | 0.2052 |
| 2.1429 | 90 | 0.1581 |
| 2.1905 | 92 | 0.1753 |
| 2.2381 | 94 | 0.1829 |
| 2.2857 | 96 | 0.2051 |
| 2.3333 | 98 | 0.2081 |
| 2.3810 | 100 | 0.194 |
| 2.4286 | 102 | 0.1139 |
| 2.4762 | 104 | 0.2349 |
| 2.5238 | 106 | 0.1427 |
| 2.5714 | 108 | 0.1654 |
| 2.6190 | 110 | 0.187 |
| 2.6667 | 112 | 0.1615 |
| 2.7143 | 114 | 0.1933 |
| 2.7619 | 116 | 0.1608 |
| 2.8095 | 118 | 0.1548 |
| 2.8571 | 120 | 0.1659 |
| 2.9048 | 122 | 0.1498 |
| 2.9524 | 124 | 0.1927 |
| 3.0 | 126 | 0.0566 |
| 3.0476 | 128 | 0.1493 |
| 3.0952 | 130 | 0.1435 |
| 3.1429 | 132 | 0.157 |
| 3.1905 | 134 | 0.1999 |
| 3.2381 | 136 | 0.1026 |
| 3.2857 | 138 | 0.1718 |
| 3.3333 | 140 | 0.1603 |
| 3.3810 | 142 | 0.1537 |
| 3.4286 | 144 | 0.1709 |
| 3.4762 | 146 | 0.1661 |
| 3.5238 | 148 | 0.1389 |
| 3.5714 | 150 | 0.1447 |
| 3.6190 | 152 | 0.1482 |
| 3.6667 | 154 | 0.1344 |
| 3.7143 | 156 | 0.1348 |
| 3.7619 | 158 | 0.1271 |
| 3.8095 | 160 | 0.1549 |
| 3.8571 | 162 | 0.124 |
| 3.9048 | 164 | 0.1555 |
| 3.9524 | 166 | 0.1215 |
| 4.0 | 168 | 0.1073 |
| 4.0476 | 170 | 0.1432 |
| 4.0952 | 172 | 0.133 |
| 4.1429 | 174 | 0.1253 |
| 4.1905 | 176 | 0.1433 |
| 4.2381 | 178 | 0.1671 |
| 4.2857 | 180 | 0.0884 |
| 4.3333 | 182 | 0.1326 |
| 4.3810 | 184 | 0.1318 |
| 4.4286 | 186 | 0.1445 |
| 4.4762 | 188 | 0.1168 |
| 4.5238 | 190 | 0.1106 |
| 4.5714 | 192 | 0.1235 |
| 4.6190 | 194 | 0.1252 |
| 4.6667 | 196 | 0.1265 |
| 4.7143 | 198 | 0.1885 |
| 4.7619 | 200 | 0.1168 |
| 4.8095 | 202 | 0.1035 |
| 4.8571 | 204 | 0.1822 |
| 4.9048 | 206 | 0.1227 |
| 4.9524 | 208 | 0.1332 |
| 5.0 | 210 | 0.0698 |
@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
comet24082002/finetune_bge_simsce_V1