SentenceTransformer based on DeepChem/ChemBERTa-77M-MLM
This is a sentence-transformers model finetuned from DeepChem/ChemBERTa-77M-MLM. 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: DeepChem/ChemBERTa-77M-MLM
- Maximum Sequence Length: 512 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': 512, 'do_lower_case': False}) with Transformer model: RobertaModel
(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})
)
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("HassanCS/chemBERTa-tuned-on-ClinTox-4")
# Run inference
sentences = [
'COc1ccc(C(=O)CC(=O)c2ccc(C(C)(C)C)cc2)cc1',
'C[N+]1(C)CCC(=C(c2ccccc2)c2ccccc2)CC1',
'C=C1CC2CCC34CC5OC6C(OC7CCC(CC(=O)CC8C(CC9OC(CCC1O2)CC(C)C9=C)OC(CC(O)CN)C8OC)OC7C6O3)C5O4',
]
embeddings = model.encode(sentences)
print(embeddings.shape)
# [3, 384]
# Get the similarity scores for the embeddings
similarities = model.similarity(embeddings, embeddings)
print(similarities.shape)
# [3, 3]
Evaluation
Metrics
Triplet
- Dataset:
all-dev - Evaluated with
TripletEvaluator
| Metric | Value |
|---|---|
| cosine_accuracy | 0.7845 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 35,520 training samples
- Columns:
anchor,positive, andnegative - Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 14 tokens
- mean: 29.75 tokens
- max: 68 tokens
- min: 3 tokens
- mean: 47.08 tokens
- max: 221 tokens
- min: 3 tokens
- mean: 53.95 tokens
- max: 189 tokens
- Samples:
anchor positive negative CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)OCC(=O)OC1CCC2(C)C(=CCC3C2CCC2(C)C(c4cccnc4)=CCC32)C1CCOC(=O)c1ncn2c1CN(C)C(=O)c1cc(F)ccc1-2CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)OCOc1ccc(C(CN(C)C)C2(O)CCCCC2)cc1C[NH2+]C1(C)C2CCC(C2)C1(C)CCC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)OCNC(=O)c1cc(Oc2ccc(NC(=O)Nc3ccc(Cl)c(C(F)(F)F)c3)cc2)ccn1.Cc1ccc(S(=O)(=O)O)cc1Nc1ncnc2c1ncn2C1OC(CO)C(O)C1O - Loss:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Evaluation Dataset
Unnamed Dataset
- Size: 1,480 evaluation samples
- Columns:
anchor,positive, andnegative - Approximate statistics based on the first 1000 samples:
anchor positive negative type string string string details - min: 18 tokens
- mean: 54.07 tokens
- max: 169 tokens
- min: 18 tokens
- mean: 58.71 tokens
- max: 244 tokens
- min: 23 tokens
- mean: 71.06 tokens
- max: 209 tokens
- Samples:
anchor positive negative CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1C#CC1(O)CCC2C3CCC4=C(CCC(=O)C4)C3CCC21CCC(C)CC(NC(=O)C(CCc1ccccc1)NC(=O)CN1CCOCC1)C(=O)NC(Cc1ccccc1)C(=O)NC(CC(C)C)C(=O)C1(C)CO1CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1C=CC1(C)CC(OC(=O)CSC2CC3CCC(C2)[NH+]3C)C2(C)C(C)CCC3(CCC(=O)C32)C(C)C1OCOC(=O)NC(C(=O)NC(Cc1ccccc1)C(O)CN(Cc1ccc(-c2ccccn2)cc1)NC(=O)C(NC(=O)OC)C(C)(C)C)C(C)(C)CCC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1CC(Cc1cc2c(c(C(N)=O)c1)N(CCCO)CC2)[NH2+]CCOc1ccccc1OCC(F)(F)FCC(C)C1(C(=O)NC2CC(=O)OC2(O)CF)CC(c2nccc3ccccc23)=NO1 - Loss:
MultipleNegativesRankingLosswith these parameters:{ "scale": 20.0, "similarity_fct": "cos_sim" }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy: stepsper_device_train_batch_size: 16per_device_eval_batch_size: 16learning_rate: 2e-05num_train_epochs: 10warmup_ratio: 0.1fp16: Truebatch_sampler: no_duplicates
All Hyperparameters
Click to expand
overwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 16per_device_eval_batch_size: 16per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 2e-05weight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 10max_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: 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: no_duplicatesmulti_dataset_batch_sampler: proportional
Training Logs
| Epoch | Step | Training Loss | Validation Loss | all-dev_cosine_accuracy |
|---|---|---|---|---|
| 0.2252 | 500 | 4.2712 | 3.3651 | 0.45 |
| 0.4505 | 1000 | 3.5714 | 2.5580 | 0.6223 |
| 0.6757 | 1500 | 3.3655 | 2.5956 | 0.6169 |
| 0.9009 | 2000 | 3.2218 | 2.6932 | 0.6493 |
| 1.1257 | 2500 | 3.0911 | 2.7852 | 0.6736 |
| 1.3509 | 3000 | 3.0007 | 2.7838 | 0.6703 |
| 1.5761 | 3500 | 3.0536 | 2.5324 | 0.7311 |
| 1.8014 | 4000 | 3.0286 | 2.6623 | 0.6892 |
| 2.0261 | 4500 | 2.9539 | 2.6397 | 0.7088 |
| 2.2514 | 5000 | 2.9252 | 2.5550 | 0.7419 |
| 2.4766 | 5500 | 2.944 | 2.5391 | 0.7419 |
| 2.7018 | 6000 | 3.028 | 2.6421 | 0.6919 |
| 2.9270 | 6500 | 2.9389 | 2.5931 | 0.7209 |
| 3.1518 | 7000 | 2.9006 | 2.6597 | 0.7365 |
| 3.3770 | 7500 | 2.9107 | 2.4841 | 0.7709 |
| 3.6023 | 8000 | 2.9802 | 2.5128 | 0.7493 |
| 3.8275 | 8500 | 2.9498 | 2.5716 | 0.7439 |
| 4.0523 | 9000 | 2.9004 | 2.4889 | 0.7669 |
| 4.2775 | 9500 | 2.89 | 2.5824 | 0.7453 |
| 4.5027 | 10000 | 2.9343 | 2.4388 | 0.7757 |
| 4.7279 | 10500 | 2.9666 | 2.4759 | 0.7520 |
| 4.9532 | 11000 | 2.9153 | 2.6096 | 0.7399 |
| 5.1779 | 11500 | 2.873 | 2.5489 | 0.7520 |
| 5.4032 | 12000 | 2.8978 | 2.5579 | 0.7527 |
| 5.6284 | 12500 | 2.9576 | 2.5336 | 0.7581 |
| 5.8536 | 13000 | 2.93 | 2.4656 | 0.7730 |
| 6.0784 | 13500 | 2.8825 | 2.4987 | 0.7730 |
| 6.3036 | 14000 | 2.8863 | 2.4866 | 0.7818 |
| 6.5288 | 14500 | 2.9221 | 2.4416 | 0.7818 |
| 6.7541 | 15000 | 2.9544 | 2.4705 | 0.7622 |
| 6.9793 | 15500 | 2.8929 | 2.4991 | 0.7669 |
| 7.2041 | 16000 | 2.8656 | 2.5163 | 0.7689 |
| 7.4293 | 16500 | 2.8866 | 2.5390 | 0.7689 |
| 7.6545 | 17000 | 2.9675 | 2.4476 | 0.7872 |
| 7.8797 | 17500 | 2.9094 | 2.4572 | 0.775 |
| 8.1045 | 18000 | 2.8743 | 2.4677 | 0.7743 |
| 8.3297 | 18500 | 2.8748 | 2.4658 | 0.7872 |
| 8.5550 | 19000 | 2.9201 | 2.4412 | 0.7865 |
| 8.7802 | 19500 | 2.9437 | 2.4620 | 0.7811 |
| 9.0050 | 20000 | 2.881 | 2.4608 | 0.7797 |
| 9.2302 | 20500 | 2.8628 | 2.4801 | 0.7770 |
| 9.4554 | 21000 | 2.884 | 2.4699 | 0.7831 |
| 9.6806 | 21500 | 2.9658 | 2.4519 | 0.7845 |
| 9.9059 | 22000 | 2.8991 | 2.4474 | 0.7845 |
Framework Versions
- Python: 3.11.11
- Sentence Transformers: 3.3.1
- Transformers: 4.47.1
- PyTorch: 2.5.1+cu124
- Accelerate: 1.2.1
- Datasets: 3.2.0
- Tokenizers: 0.21.0
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{henderson2017efficient,
title={Efficient Natural Language Response Suggestion for Smart Reply},
author={Matthew Henderson and Rami Al-Rfou and Brian Strope and Yun-hsuan Sung and Laszlo Lukacs and Ruiqi Guo and Sanjiv Kumar and Balint Miklos and Ray Kurzweil},
year={2017},
eprint={1705.00652},
archivePrefix={arXiv},
primaryClass={cs.CL}
}
- Downloads last month
- 1
Model tree for HassanCS/chemBERTa-tuned-on-ClinTox-4
Base model
DeepChem/ChemBERTa-77M-MLM