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

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

Metric Value
cosine_accuracy 0.7845

Training Details

Training Dataset

Unnamed Dataset

  • Size: 35,520 training samples
  • Columns: anchor, positive, and negative
  • 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)O CC(=O)OC1CCC2(C)C(=CCC3C2CCC2(C)C(c4cccnc4)=CCC32)C1 CCOC(=O)c1ncn2c1CN(C)C(=O)c1cc(F)ccc1-2
    CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)O COc1ccc(C(CN(C)C)C2(O)CCCCC2)cc1 C[NH2+]C1(C)C2CCC(C2)C1(C)C
    CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)O CNC(=O)c1cc(Oc2ccc(NC(=O)Nc3ccc(Cl)c(C(F)(F)F)c3)cc2)ccn1.Cc1ccc(S(=O)(=O)O)cc1 Nc1ncnc2c1ncn2C1OC(CO)C(O)C1O
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Evaluation Dataset

Unnamed Dataset

  • Size: 1,480 evaluation samples
  • Columns: anchor, positive, and negative
  • 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)c1 C#CC1(O)CCC2C3CCC4=C(CCC(=O)C4)C3CCC21C CC(C)CC(NC(=O)C(CCc1ccccc1)NC(=O)CN1CCOCC1)C(=O)NC(Cc1ccccc1)C(=O)NC(CC(C)C)C(=O)C1(C)CO1
    CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1 C=CC1(C)CC(OC(=O)CSC2CC3CCC(C2)[NH+]3C)C2(C)C(C)CCC3(CCC(=O)C32)C(C)C1O COC(=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)C
    CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1 CC(Cc1cc2c(c(C(N)=O)c1)N(CCCO)CC2)[NH2+]CCOc1ccccc1OCC(F)(F)F CC(C)C1(C(=O)NC2CC(=O)OC2(O)CF)CC(c2nccc3ccccc23)=NO1
  • Loss: MultipleNegativesRankingLoss with these parameters:
    {
        "scale": 20.0,
        "similarity_fct": "cos_sim"
    }
    

Training Hyperparameters

Non-Default Hyperparameters

  • eval_strategy: steps
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • learning_rate: 2e-05
  • num_train_epochs: 10
  • warmup_ratio: 0.1
  • fp16: True
  • batch_sampler: no_duplicates

All Hyperparameters

Click to expand
  • overwrite_output_dir: False
  • do_predict: False
  • eval_strategy: steps
  • prediction_loss_only: True
  • per_device_train_batch_size: 16
  • per_device_eval_batch_size: 16
  • per_gpu_train_batch_size: None
  • per_gpu_eval_batch_size: None
  • gradient_accumulation_steps: 1
  • eval_accumulation_steps: None
  • torch_empty_cache_steps: None
  • learning_rate: 2e-05
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • max_grad_norm: 1.0
  • num_train_epochs: 10
  • max_steps: -1
  • lr_scheduler_type: linear
  • lr_scheduler_kwargs: {}
  • warmup_ratio: 0.1
  • warmup_steps: 0
  • log_level: passive
  • log_level_replica: warning
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • save_safetensors: True
  • save_on_each_node: False
  • save_only_model: False
  • restore_callback_states_from_checkpoint: False
  • no_cuda: False
  • use_cpu: False
  • use_mps_device: False
  • seed: 42
  • data_seed: None
  • jit_mode_eval: False
  • use_ipex: False
  • bf16: False
  • fp16: True
  • fp16_opt_level: O1
  • half_precision_backend: auto
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • local_rank: 0
  • ddp_backend: None
  • tpu_num_cores: None
  • tpu_metrics_debug: False
  • debug: []
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_prefetch_factor: None
  • past_index: -1
  • disable_tqdm: False
  • remove_unused_columns: True
  • label_names: None
  • load_best_model_at_end: False
  • ignore_data_skip: False
  • fsdp: []
  • fsdp_min_num_params: 0
  • fsdp_config: {'min_num_params': 0, 'xla': False, 'xla_fsdp_v2': False, 'xla_fsdp_grad_ckpt': False}
  • fsdp_transformer_layer_cls_to_wrap: None
  • accelerator_config: {'split_batches': False, 'dispatch_batches': None, 'even_batches': True, 'use_seedable_sampler': True, 'non_blocking': False, 'gradient_accumulation_kwargs': None}
  • deepspeed: None
  • label_smoothing_factor: 0.0
  • optim: adamw_torch
  • optim_args: None
  • adafactor: False
  • group_by_length: False
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • skip_memory_metrics: True
  • use_legacy_prediction_loop: False
  • push_to_hub: False
  • resume_from_checkpoint: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_private_repo: None
  • hub_always_push: False
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • include_inputs_for_metrics: False
  • include_for_metrics: []
  • eval_do_concat_batches: True
  • fp16_backend: auto
  • push_to_hub_model_id: None
  • push_to_hub_organization: None
  • mp_parameters:
  • auto_find_batch_size: False
  • full_determinism: False
  • torchdynamo: None
  • ray_scope: last
  • ddp_timeout: 1800
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • dispatch_batches: None
  • split_batches: None
  • include_tokens_per_second: False
  • include_num_input_tokens_seen: False
  • neftune_noise_alpha: None
  • optim_target_modules: None
  • batch_eval_metrics: False
  • eval_on_start: False
  • use_liger_kernel: False
  • eval_use_gather_object: False
  • average_tokens_across_devices: False
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_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
7
Safetensors
Model size
3.43M params
Tensor type
F32
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for HassanCS/chemBERTa-tuned-on-ClinTox-4

Finetuned
(7)
this model

Evaluation results