Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks
Paper • 1908.10084 • Published • 15
How to use Jimmy-Ooi/TTM_800_8_8_0.0001_AdamW with sentence-transformers:
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("Jimmy-Ooi/TTM_800_8_8_0.0001_AdamW")
sentences = [
"CCOC(OCC)c1ccc(/C=C/C(=O)C2CCc3ccccc3C2=O)cc1",
"O=C(/C=C/c1cccc(O)c1)NCCCNC(=O)/C=C/c1cccc(O)c1",
"CCCCCCS(=O)(=O)Cc1cc(=O)c(O)co1",
"CCOC(=O)/C=C/c1cc(=O)c(O)co1"
]
embeddings = model.encode(sentences)
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [4, 4]This is a sentence-transformers model finetuned from google-bert/bert-base-cased on the csv 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': 512, 'do_lower_case': False, 'architecture': 'BertModel'})
(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("Jimmy-Ooi/TTM_800_8_8_0.0001_AdamW")
# Run inference
sentences = [
'O=C(/C=C/c1ccc(O)c(O)c1)NC(Cc1ccccc1)C(=O)NO',
'Cc1cccc(C(=O)Nc2cccc(C(=O)/C=C/c3ccc4c(c3)c3ccccc3n4C)c2)c1',
'COc1ccc(CCc2ccc(O)cc2O)cc1',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 768]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities)
# tensor([[ 1.0000, -0.1056, -0.2395],
# [-0.1056, 1.0000, 0.9876],
# [-0.2395, 0.9876, 1.0000]])
premise, hypothesis, and label| premise | hypothesis | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
SoftmaxLosspremise, hypothesis, and label| premise | hypothesis | label | |
|---|---|---|---|
| type | string | string | int |
| details |
|
|
|
SoftmaxLossper_device_train_batch_size: 64num_train_epochs: 8warmup_steps: 100optim: adamw_torchweight_decay: 0.0001fp16: Trueper_device_eval_batch_size: 64per_device_train_batch_size: 64num_train_epochs: 8max_steps: -1learning_rate: 5e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 100optim: adamw_torchoptim_args: Noneweight_decay: 0.0001adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Falsefp16: Truebf16_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: 64prediction_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: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss |
|---|---|---|
| 0.0533 | 100 | 0.9256 |
| 0.1066 | 200 | 0.6870 |
| 0.1599 | 300 | 0.6471 |
| 0.2132 | 400 | 0.6166 |
| 0.2665 | 500 | 0.5977 |
| 0.3198 | 600 | 0.5855 |
| 0.3731 | 700 | 0.5860 |
| 0.4264 | 800 | 0.5744 |
| 0.4797 | 900 | 0.5765 |
| 0.5330 | 1000 | 0.5681 |
| 0.5864 | 1100 | 0.5625 |
| 0.6397 | 1200 | 0.5667 |
| 0.6930 | 1300 | 0.5581 |
| 0.7463 | 1400 | 0.5521 |
| 0.7996 | 1500 | 0.5476 |
| 0.8529 | 1600 | 0.5482 |
| 0.9062 | 1700 | 0.5588 |
| 0.9595 | 1800 | 0.5476 |
| 1.0128 | 1900 | 0.5382 |
| 1.0661 | 2000 | 0.5425 |
| 1.1194 | 2100 | 0.5534 |
| 1.1727 | 2200 | 0.5509 |
| 1.2260 | 2300 | 0.5356 |
| 1.2793 | 2400 | 0.5399 |
| 1.3326 | 2500 | 0.5328 |
| 1.3859 | 2600 | 0.5358 |
| 1.4392 | 2700 | 0.5393 |
| 1.4925 | 2800 | 0.5331 |
| 1.5458 | 2900 | 0.5202 |
| 1.5991 | 3000 | 0.5282 |
| 1.6525 | 3100 | 0.5331 |
| 1.7058 | 3200 | 0.5326 |
| 1.7591 | 3300 | 0.5331 |
| 1.8124 | 3400 | 0.5303 |
| 1.8657 | 3500 | 0.5285 |
| 1.9190 | 3600 | 0.5257 |
| 1.9723 | 3700 | 0.5358 |
| 2.0256 | 3800 | 0.5266 |
| 2.0789 | 3900 | 0.5316 |
| 2.1322 | 4000 | 0.5226 |
| 2.1855 | 4100 | 0.5271 |
| 2.2388 | 4200 | 0.5119 |
| 2.2921 | 4300 | 0.5294 |
| 2.3454 | 4400 | 0.5168 |
| 2.3987 | 4500 | 0.5218 |
| 2.4520 | 4600 | 0.5155 |
| 2.5053 | 4700 | 0.5239 |
| 2.5586 | 4800 | 0.5249 |
| 2.6119 | 4900 | 0.5222 |
| 2.6652 | 5000 | 0.5144 |
| 2.7186 | 5100 | 0.5211 |
| 2.7719 | 5200 | 0.5239 |
| 2.8252 | 5300 | 0.5101 |
| 2.8785 | 5400 | 0.5166 |
| 2.9318 | 5500 | 0.5235 |
| 2.9851 | 5600 | 0.5154 |
| 3.0384 | 5700 | 0.5170 |
| 3.0917 | 5800 | 0.5159 |
| 3.1450 | 5900 | 0.5190 |
| 3.1983 | 6000 | 0.5166 |
| 3.2516 | 6100 | 0.5116 |
| 3.3049 | 6200 | 0.5117 |
| 3.3582 | 6300 | 0.5038 |
| 3.4115 | 6400 | 0.5107 |
| 3.4648 | 6500 | 0.5143 |
| 3.5181 | 6600 | 0.5168 |
| 3.5714 | 6700 | 0.5002 |
| 3.6247 | 6800 | 0.5083 |
| 3.6780 | 6900 | 0.5130 |
| 3.7313 | 7000 | 0.5091 |
| 3.7846 | 7100 | 0.5164 |
| 3.8380 | 7200 | 0.5130 |
| 3.8913 | 7300 | 0.5101 |
| 3.9446 | 7400 | 0.4955 |
| 3.9979 | 7500 | 0.5065 |
| 4.0512 | 7600 | 0.5111 |
| 4.1045 | 7700 | 0.5077 |
| 4.1578 | 7800 | 0.5178 |
| 4.2111 | 7900 | 0.5068 |
| 4.2644 | 8000 | 0.5005 |
| 4.3177 | 8100 | 0.5010 |
| 4.3710 | 8200 | 0.5043 |
| 4.4243 | 8300 | 0.4964 |
| 4.4776 | 8400 | 0.5016 |
| 4.5309 | 8500 | 0.5069 |
| 4.5842 | 8600 | 0.5082 |
| 4.6375 | 8700 | 0.5083 |
| 4.6908 | 8800 | 0.5071 |
| 4.7441 | 8900 | 0.5082 |
| 4.7974 | 9000 | 0.5117 |
| 4.8507 | 9100 | 0.5023 |
| 4.9041 | 9200 | 0.4969 |
| 4.9574 | 9300 | 0.5069 |
| 5.0107 | 9400 | 0.5061 |
| 5.0640 | 9500 | 0.4983 |
| 5.1173 | 9600 | 0.5004 |
| 5.1706 | 9700 | 0.5047 |
| 5.2239 | 9800 | 0.4958 |
| 5.2772 | 9900 | 0.5076 |
| 5.3305 | 10000 | 0.5048 |
| 5.3838 | 10100 | 0.5018 |
| 5.4371 | 10200 | 0.5090 |
| 5.4904 | 10300 | 0.5019 |
| 5.5437 | 10400 | 0.5001 |
| 5.5970 | 10500 | 0.4958 |
| 5.6503 | 10600 | 0.5004 |
| 5.7036 | 10700 | 0.5025 |
| 5.7569 | 10800 | 0.5004 |
| 5.8102 | 10900 | 0.4970 |
| 5.8635 | 11000 | 0.5054 |
| 5.9168 | 11100 | 0.5062 |
| 5.9701 | 11200 | 0.4970 |
| 6.0235 | 11300 | 0.5052 |
| 6.0768 | 11400 | 0.5016 |
| 6.1301 | 11500 | 0.4965 |
| 6.1834 | 11600 | 0.4988 |
| 6.2367 | 11700 | 0.5051 |
| 6.2900 | 11800 | 0.4899 |
| 6.3433 | 11900 | 0.4931 |
| 6.3966 | 12000 | 0.5085 |
| 6.4499 | 12100 | 0.5011 |
| 6.5032 | 12200 | 0.4992 |
| 6.5565 | 12300 | 0.5007 |
| 6.6098 | 12400 | 0.5081 |
| 6.6631 | 12500 | 0.4911 |
| 6.7164 | 12600 | 0.4992 |
| 6.7697 | 12700 | 0.5037 |
| 6.8230 | 12800 | 0.4926 |
| 6.8763 | 12900 | 0.4957 |
| 6.9296 | 13000 | 0.4964 |
| 6.9829 | 13100 | 0.5046 |
| 7.0362 | 13200 | 0.5048 |
| 7.0896 | 13300 | 0.4954 |
| 7.1429 | 13400 | 0.5026 |
| 7.1962 | 13500 | 0.4963 |
| 7.2495 | 13600 | 0.4908 |
| 7.3028 | 13700 | 0.4945 |
| 7.3561 | 13800 | 0.4999 |
| 7.4094 | 13900 | 0.4935 |
| 7.4627 | 14000 | 0.4909 |
| 7.5160 | 14100 | 0.4917 |
| 7.5693 | 14200 | 0.4948 |
| 7.6226 | 14300 | 0.4942 |
| 7.6759 | 14400 | 0.5051 |
| 7.7292 | 14500 | 0.5062 |
| 7.7825 | 14600 | 0.4935 |
| 7.8358 | 14700 | 0.4935 |
| 7.8891 | 14800 | 0.5019 |
| 7.9424 | 14900 | 0.5043 |
| 7.9957 | 15000 | 0.4964 |
@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",
}
Base model
google-bert/bert-base-cased