CoolFace
Modelpublic

HassanCS/chemBERTa-tuned-on-ClinTox-using-MultipleNegativesRankingLoss

sourceHugging Faceupdated 2y agoView on Hugging Face
0likes11downloads
Model Card

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 <!-- at revision ed8a5374f2024ec8da53760af91a33fb8f6a15ff -->
  • —Maximum Sequence Length: 512 tokens
  • —Output Dimensionality: 384 dimensions
  • —Similarity Function: Cosine Similarity <!-- - Training Dataset: Unknown --> <!-- - Language: Unknown --> <!-- - License: Unknown -->

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:

bash
pip install -U sentence-transformers

Then you can load this model and run inference.

python
from sentence_transformers import SentenceTransformer

# Download from the 🤗 Hub
model = SentenceTransformer("HassanCS/chemBERTa-tuned-on-ClinTox-using-MultipleNegativesRankingLoss")
# Run inference
sentences = [
    'CON=C(C(=O)NC1C(=O)N2C(C(=O)[O-])=C(C[N+]3(C)CCCC3)CSC12)c1csc(N)n1',
    'CC1CNc2c(cccc2S(=O)(=O)NC(CCC[NH+]=C(N)N)C(=O)N2CCC(C)CC2C(=O)[O-])C1',
    'CC(C)C1(C(=O)NC2CC(=O)OC2(O)CF)CC(c2nccc3ccccc23)=NO1',
]
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]

<!--

Direct Usage (Transformers)

<details><summary>Click to see the direct usage in Transformers</summary>

</details> -->

<!--

Downstream Usage (Sentence Transformers)

You can finetune this model on your own dataset.

<details><summary>Click to expand</summary>

</details> -->

<!--

Out-of-Scope Use

List how the model may foreseeably be misused and address what users ought not to do with the model. -->

Evaluation

Metrics

Triplet
MetricValue
cosine_accuracy0.7135

<!--

Bias, Risks and Limitations

What are the known or foreseeable issues stemming from this model? You could also flag here known failure cases or weaknesses of the model. -->

<!--

Recommendations

What are recommendations with respect to the foreseeable issues? For example, filtering explicit content. -->

Training Details

Training Dataset

Unnamed Dataset
  • —Size: 118,400 training samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 20 tokens</li><li>mean: 33.0 tokens</li><li>max: 60 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 47.34 tokens</li><li>max: 212 tokens</li></ul> | <ul><li>min: 3 tokens</li><li>mean: 53.88 tokens</li><li>max: 212 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:-------------------------------------------------------|:---------------------------------------------------------------------------------------------|:-----------------------------------------------------| | <code>CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)O</code> | <code>CC(=O)OC1CCC2(C)C(=CCC3C2CCC2(C)C(c4cccnc4)=CCC32)C1</code> | <code>CCOC(=O)c1ncn2c1CN(C)C(=O)c1cc(F)ccc1-2</code> | | <code>CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)O</code> | <code>COc1ccc(C(CN(C)C)C2(O)CCCCC2)cc1</code> | <code>C[NH2+]C1(C)C2CCC(C2)C1(C)C</code> | | <code>CC(C)CC(NC(=O)CNC(=O)c1cc(Cl)ccc1Cl)B(O)O</code> | <code>CNC(=O)c1cc(Oc2ccc(NC(=O)Nc3ccc(Cl)c(C(F)(F)F)c3)cc2)ccn1.Cc1ccc(S(=O)(=O)O)cc1</code> | <code>Nc1ncnc2c1ncn2C1OC(CO)C(O)C1O</code> |
  • —Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
      "triplet_margin": 5
  }

Evaluation Dataset

Unnamed Dataset
  • —Size: 1,480 evaluation samples
  • —Columns: <code>anchor</code>, <code>positive</code>, and <code>negative</code>
  • —Approximate statistics based on the first 1000 samples: | | anchor | positive | negative | |:--------|:------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:------------------------------------------------------------------------------------| | type | string | string | string | | details | <ul><li>min: 18 tokens</li><li>mean: 54.07 tokens</li><li>max: 169 tokens</li></ul> | <ul><li>min: 18 tokens</li><li>mean: 60.4 tokens</li><li>max: 244 tokens</li></ul> | <ul><li>min: 30 tokens</li><li>mean: 71.25 tokens</li><li>max: 141 tokens</li></ul> |
  • —Samples: | anchor | positive | negative | |:------------------------------------------------------------------------|:------------------------------------------------------------|:-------------------------------------------------------------------------| | <code>CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1</code> | <code>CC12CCCCCC(Cc3ccc(O)cc31)C2[NH3+]</code> | <code>CC(C)C(CN1CCC(C)(c2cccc(O)c2)C(C)C1)NC(=O)C1Cc2ccc(O)cc2CN1</code> | | <code>CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1</code> | <code>COc1cc2c(cc1OC)C1CC(=O)C(CC(C)C)C[NH+]1CC2</code> | <code>CC(C)C(CN1CCC(C)(c2cccc(O)c2)C(C)C1)NC(=O)C1Cc2ccc(O)cc2CN1</code> | | <code>CC(C)OC(=O)CCCC=CCC1C(O)CC(O)C1C=CC(O)COc1cccc(C(F)(F)F)c1</code> | <code>CNH+CCC=C1c2ccccc2COc2ccc(CC(=O)[O-])cc21</code> | <code>CC(C)C1(C(=O)NC2CC(=O)OC2(O)CF)CC(c2nccc3ccccc23)=NO1</code> |
  • —Loss: <code>TripletLoss</code> with these parameters:
json
  {
      "distance_metric": "TripletDistanceMetric.EUCLIDEAN",
      "triplet_margin": 5
  }

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: 5
  • —warmup_ratio: 0.1
  • —fp16: True
  • —batch_sampler: no_duplicates
All Hyperparameters

<details><summary>Click to expand</summary>

  • —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: 5
  • —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: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}
  • —fsdp_transformer_layer_cls_to_wrap: None
  • —accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': 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

</details>

Training Logs

EpochStepTraining LossValidation Lossall-dev_cosine_accuracy
0.06765005.08215.17370.4047
0.135110004.98695.17660.4230
0.202715004.55624.91020.5345
0.270320003.23644.37120.6534
0.337825002.07384.07040.6736
0.405430001.42394.02000.6635
0.473035001.15783.72020.6791
0.540540000.96693.71970.6831
0.608145000.7143.88180.6547
0.675750000.53594.09870.6243
0.743255000.56633.81270.6500
0.810860000.48273.83460.6676
0.878465000.47583.83330.6507
0.945970000.47593.68720.6912
1.013575000.46513.72290.6831
1.081180000.47393.80410.6662
1.148685000.44583.82350.6703
1.216290000.41893.79570.6716
1.283895000.45043.74220.6784
1.3514100000.4133.75880.6770
1.4189105000.38083.97500.6615
1.4865110000.38533.74170.6953
1.5541115000.3793.73190.6993
1.6216120000.4293.56200.7209
1.6892125000.37353.69000.7020
1.7568130000.39083.81820.6932
1.8243135000.38483.72280.7101
1.8919140000.37773.66040.7149
1.9595145000.39123.78490.6946
2.0269150000.32823.86070.7014
2.0945155000.33243.85730.6953
2.1620160000.38523.94200.7000
2.2296165000.36333.79280.7189
2.2972170000.34933.82170.7216
2.3647175000.35543.85460.6993
2.4323180000.33633.77640.6993
2.4999185000.3773.82240.6959
2.5674190000.35693.83760.7155
2.635195000.34144.00170.7034
2.7026200000.35673.74050.7135
2.7701205000.35243.94460.7189
2.8377210000.33473.81400.7169
2.9053215000.34584.07000.7088
2.9728220000.36323.79300.7081
3.0404225000.34963.98840.7236
3.1080230000.34263.71020.7155
3.1755235000.35793.92010.7135
3.2431240000.35534.22370.7270
3.3107245000.3453.80900.7189
3.3782250000.34753.78020.7284
3.4458255000.33263.75490.7250
3.5134260000.32283.67170.7216
3.5809265000.33113.82410.7155
3.6485270000.32153.81510.7142
3.7161275000.35343.86390.7149
3.7836280000.33694.09470.7101
3.8512285000.32294.04950.7101
3.9188290000.34424.04080.7169
3.9864295000.30593.94930.6959
4.0538300000.33494.04310.7108
4.1214305000.32664.02240.7189
4.1889310000.35013.95020.7169
4.2565315000.36763.89030.7196
4.3241320000.31913.79940.7162
4.3916325000.33173.78890.7182
4.4592330000.33043.86610.7108
4.5268335000.33323.88220.7115
4.5943340000.34353.79450.7088
4.6619345000.3173.87210.7243
4.7295350000.30383.86150.7209
4.7970355000.30933.83600.7162
4.8646360000.33093.82770.7155
4.9322365000.33783.79880.7128
4.9997370000.3113.80150.7135

Framework Versions

  • —Python: 3.11.11
  • —Sentence Transformers: 3.4.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
bibtex
@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",
}
TripletLoss
bibtex
@misc{hermans2017defense,
    title={In Defense of the Triplet Loss for Person Re-Identification},
    author={Alexander Hermans and Lucas Beyer and Bastian Leibe},
    year={2017},
    eprint={1703.07737},
    archivePrefix={arXiv},
    primaryClass={cs.CV}
}

<!--

Glossary

Clearly define terms in order to be accessible across audiences. -->

<!--

Model Card Authors

Lists the people who create the model card, providing recognition and accountability for the detailed work that goes into its construction. -->

<!--

Model Card Contact

Provides a way for people who have updates to the Model Card, suggestions, or questions, to contact the Model Card authors. -->