metadata
tags:
- sentence-transformers
- sentence-similarity
- feature-extraction
- generated_from_trainer
- dataset_size:10000
- loss:ContrastiveLoss
base_model: DeepChem/ChemBERTa-77M-MLM
widget:
- source_sentence: CC(C)N=c1cc2n(-c3ccc(Cl)cc3)c3ccccc3nc-2cc1Nc1ccc(Cl)cc1
sentences:
- C[NH+]1CCC(=C2c3ccccc3CCn3c(C=O)c[nH+]c32)CC1
- COc1ccc(C(=O)CC(=O)c2ccc(C(C)(C)C)cc2)cc1
- CC1CNc2c(cccc2S(=O)(=O)NC(CCC[NH+]=C(N)N)C(=O)N2CCC(C)CC2C(=O)[O-])C1
- source_sentence: CC(C)c1ccc2oc3nc(N)c(C(=O)[O-])cc3c(=O)c2c1
sentences:
- COC1=CC(=O)CC(C)C12Oc1c(Cl)c(OC)cc(OC)c1C2=O
- CON=C(C(=O)NC1C(=O)N2C(C(=O)[O-])=C(C[N+]3(C)CCCC3)CSC12)c1csc(N)n1
- >-
CC1C=CC=CC=CC=CC=CC=CC=CC(OC2OC(C)C(O)C([NH3+])C2O)CC2OC(O)(CC(O)CC(O)C(O)CCC(O)CC(O)CC(=O)OC(C)C(C)C1O)CC(O)C2C(=O)[O-]
- source_sentence: C[NH2+]C1CCc2[nH]c3ccc(C(N)=O)cc3c2C1
sentences:
- >-
CC(OC(=O)c1ccccc1)C1=CCC23OCC[NH+](C)CC12CC(O)C12OC4(O)CCC1(C)C(CC=C32)C4
- >-
CC(=O)NC(Cc1ccc2ccccc2c1)C(=O)NC(Cc1ccc(Cl)cc1)C(=O)NC(Cc1cccnc1)C(=O)NC(CO)C(=O)NC(Cc1ccc(NC(=O)C2CC(=O)NC(=O)N2)cc1)C(=O)NC(Cc1ccc(NC(N)=O)cc1)C(=O)NC(CC(C)C)C(=O)NC(CCCC[NH2+]C(C)C)C(=O)N1CCCC1C(=O)NC(C)C(N)=O
- C[NH+](C)CCOC(=O)C(c1ccccc1)C1(O)CCCC1
- source_sentence: CC(C)n1c(C=CC(O)CC(O)CC(=O)[O-])c(-c2ccc(F)cc2)c2ccccc21
sentences:
- C#CC1(O)CCC2C3CCC4=C(CCC(=O)C4)C3CCC21C
- CC(C=CC(C)C(C)(C)O)C1CCC2C(=CC=C3CC(O)CC(O)C3)CCCC21C
- CC(C)CNCc1ccc(-c2ccccc2S(=O)(=O)N2CCCC2)cc1
- source_sentence: CC#CCn1c(N2CCCC([NH3+])C2)nc2c1c(=O)n(Cc1nc(C)c3ccccc3n1)c(=O)n2C
sentences:
- C[N+]1(C)CCCC(OC(=O)C(O)(c2ccccc2)c2ccccc2)C1
- CC(Cc1ccc(O)c(O)c1)C(C)Cc1ccc(O)c(O)c1
- CC12CCC(=O)C=C1CCC1C2C(O)CC2(C)C1CCC2(O)C(=O)COC(=O)CCC1CCCC1
pipeline_tag: sentence-similarity
library_name: sentence-transformers
metrics:
- cosine_accuracy
- cosine_accuracy_threshold
- cosine_f1
- cosine_f1_threshold
- cosine_precision
- cosine_recall
- cosine_ap
model-index:
- name: SentenceTransformer based on DeepChem/ChemBERTa-77M-MLM
results:
- task:
type: binary-classification
name: Binary Classification
dataset:
name: all dev
type: all-dev
metrics:
- type: cosine_accuracy
value: 0.9066
name: Cosine Accuracy
- type: cosine_accuracy_threshold
value: 0.5664876699447632
name: Cosine Accuracy Threshold
- type: cosine_f1
value: 0.9510122731564041
name: Cosine F1
- type: cosine_f1_threshold
value: 0.5664876699447632
name: Cosine F1 Threshold
- type: cosine_precision
value: 0.9067813562712542
name: Cosine Precision
- type: cosine_recall
value: 0.9997794441993825
name: Cosine Recall
- type: cosine_ap
value: 0.9523113003188102
name: Cosine Ap
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-3")
# Run inference
sentences = [
'CC#CCn1c(N2CCCC([NH3+])C2)nc2c1c(=O)n(Cc1nc(C)c3ccccc3n1)c(=O)n2C',
'CC12CCC(=O)C=C1CCC1C2C(O)CC2(C)C1CCC2(O)C(=O)COC(=O)CCC1CCCC1',
'CC(Cc1ccc(O)c(O)c1)C(C)Cc1ccc(O)c(O)c1',
]
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
Binary Classification
- Dataset:
all-dev
- Evaluated with
BinaryClassificationEvaluator
Metric | Value |
---|---|
cosine_accuracy | 0.9066 |
cosine_accuracy_threshold | 0.5665 |
cosine_f1 | 0.951 |
cosine_f1_threshold | 0.5665 |
cosine_precision | 0.9068 |
cosine_recall | 0.9998 |
cosine_ap | 0.9523 |
Training Details
Training Dataset
Unnamed Dataset
- Size: 10,000 training samples
- Columns:
smiles1
,smiles2
, andlabel
- Approximate statistics based on the first 1000 samples:
smiles1 smiles2 label type string string int details - min: 3 tokens
- mean: 40.69 tokens
- max: 221 tokens
- min: 4 tokens
- mean: 51.43 tokens
- max: 221 tokens
- 0: ~14.90%
- 1: ~85.10%
- Samples:
smiles1 smiles2 label Cn1c(=O)c2c(ncn2C)n(C)c1=O
Cc1cc2c(s1)=Nc1ccccc1NC=2N1CCNH+CC1
1
Oc1ccc(OCc2ccccc2)cc1
Oc1ccc(CCCC[NH2+]CC(O)c2ccc(O)c(O)c2)cc1
1
OCC(S)CS
CC12CCC(=O)C=C1CCC1C2C(O)CC2(C)C1CCC2(O)C(=O)CO
0
- Loss:
ContrastiveLoss
with these parameters:{ "distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE", "margin": 0.5, "size_average": true }
Evaluation Dataset
Unnamed Dataset
- Size: 5,000 evaluation samples
- Columns:
smiles1
,smiles2
, andlabel
- Approximate statistics based on the first 1000 samples:
smiles1 smiles2 label type string string int details - min: 18 tokens
- mean: 56.96 tokens
- max: 209 tokens
- min: 18 tokens
- mean: 61.21 tokens
- max: 244 tokens
- 0: ~10.00%
- 1: ~90.00%
- Samples:
smiles1 smiles2 label CC(=CC(=O)OCCCCCCCCC(=O)[O-])CC1OCC(CC2OC2C(C)C(C)O)C(O)C1O
CC(C=CC(C)C(C)(C)O)C1CCC2C(=CC=C3CC(O)CC(O)C3)CCCC21C
1
C=C1c2cccc([O-])c2C(=O)C2=C([O-])C3(O)C(=O)C(C(N)=O)=C([O-])C(NH+C)C3C(O)C12
CC(c1ncncc1F)C(O)(Cn1cncn1)c1ccc(F)cc1F
1
CC(C)CC1C(=O)N2CCCC2C2(O)OC(NC(=O)C3C=C4c5cccc6[nH]c(Br)c(c56)CC4NH+C3)(C(C)C)C(=O)N12
CNH+CCC=C1c2ccccc2Sc2ccc(Cl)cc21
1
- Loss:
ContrastiveLoss
with these parameters:{ "distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE", "margin": 0.5, "size_average": true }
Training Hyperparameters
Non-Default Hyperparameters
eval_strategy
: stepsper_device_train_batch_size
: 16per_device_eval_batch_size
: 16learning_rate
: 2e-05num_train_epochs
: 5warmup_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
: 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
: 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_ap |
---|---|---|---|---|
0.8 | 500 | 0.0264 | 0.0112 | 0.9213 |
1.6 | 1000 | 0.0152 | 0.0122 | 0.9362 |
2.4 | 1500 | 0.0134 | 0.0128 | 0.9463 |
3.2 | 2000 | 0.0112 | 0.0134 | 0.9502 |
4.0 | 2500 | 0.01 | 0.0125 | 0.9513 |
4.8 | 3000 | 0.0097 | 0.0132 | 0.9523 |
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",
}
ContrastiveLoss
@inproceedings{hadsell2006dimensionality,
author={Hadsell, R. and Chopra, S. and LeCun, Y.},
booktitle={2006 IEEE Computer Society Conference on Computer Vision and Pattern Recognition (CVPR'06)},
title={Dimensionality Reduction by Learning an Invariant Mapping},
year={2006},
volume={2},
number={},
pages={1735-1742},
doi={10.1109/CVPR.2006.100}
}