|
--- |
|
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](https://www.SBERT.net) model finetuned from [DeepChem/ChemBERTa-77M-MLM](https://huggingface.co/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](https://huggingface.co/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 |
|
|
|
- **Documentation:** [Sentence Transformers Documentation](https://sbert.net) |
|
- **Repository:** [Sentence Transformers on GitHub](https://github.com/UKPLab/sentence-transformers) |
|
- **Hugging Face:** [Sentence Transformers on Hugging Face](https://huggingface.co/models?library=sentence-transformers) |
|
|
|
### 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-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] |
|
``` |
|
|
|
<!-- |
|
### 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 |
|
|
|
#### Binary Classification |
|
|
|
* Dataset: `all-dev` |
|
* Evaluated with [<code>BinaryClassificationEvaluator</code>](https://sbert.net/docs/package_reference/sentence_transformer/evaluation.html#sentence_transformers.evaluation.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** | |
|
|
|
<!-- |
|
## 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: 10,000 training samples |
|
* Columns: <code>smiles1</code>, <code>smiles2</code>, and <code>label</code> |
|
* Approximate statistics based on the first 1000 samples: |
|
| | smiles1 | smiles2 | label | |
|
|:--------|:-----------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------|:------------------------------------------------| |
|
| type | string | string | int | |
|
| details | <ul><li>min: 3 tokens</li><li>mean: 40.69 tokens</li><li>max: 221 tokens</li></ul> | <ul><li>min: 4 tokens</li><li>mean: 51.43 tokens</li><li>max: 221 tokens</li></ul> | <ul><li>0: ~14.90%</li><li>1: ~85.10%</li></ul> | |
|
* Samples: |
|
| smiles1 | smiles2 | label | |
|
|:----------------------------------------|:-------------------------------------------------------------|:---------------| |
|
| <code>Cn1c(=O)c2c(ncn2C)n(C)c1=O</code> | <code>Cc1cc2c(s1)=Nc1ccccc1NC=2N1CC[NH+](C)CC1</code> | <code>1</code> | |
|
| <code>Oc1ccc(OCc2ccccc2)cc1</code> | <code>Oc1ccc(CCCC[NH2+]CC(O)c2ccc(O)c(O)c2)cc1</code> | <code>1</code> | |
|
| <code>OCC(S)CS</code> | <code>CC12CCC(=O)C=C1CCC1C2C(O)CC2(C)C1CCC2(O)C(=O)CO</code> | <code>0</code> | |
|
* Loss: [<code>ContrastiveLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters: |
|
```json |
|
{ |
|
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE", |
|
"margin": 0.5, |
|
"size_average": true |
|
} |
|
``` |
|
|
|
### Evaluation Dataset |
|
|
|
#### Unnamed Dataset |
|
|
|
|
|
* Size: 5,000 evaluation samples |
|
* Columns: <code>smiles1</code>, <code>smiles2</code>, and <code>label</code> |
|
* Approximate statistics based on the first 1000 samples: |
|
| | smiles1 | smiles2 | label | |
|
|:--------|:------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------|:------------------------------------------------| |
|
| type | string | string | int | |
|
| details | <ul><li>min: 18 tokens</li><li>mean: 56.96 tokens</li><li>max: 209 tokens</li></ul> | <ul><li>min: 18 tokens</li><li>mean: 61.21 tokens</li><li>max: 244 tokens</li></ul> | <ul><li>0: ~10.00%</li><li>1: ~90.00%</li></ul> | |
|
* Samples: |
|
| smiles1 | smiles2 | label | |
|
|:---------------------------------------------------------------------------------------------------------|:-------------------------------------------------------------------|:---------------| |
|
| <code>CC(=CC(=O)OCCCCCCCCC(=O)[O-])CC1OCC(CC2OC2C(C)C(C)O)C(O)C1O</code> | <code>CC(C=CC(C)C(C)(C)O)C1CCC2C(=CC=C3CC(O)CC(O)C3)CCCC21C</code> | <code>1</code> | |
|
| <code>C=C1c2cccc([O-])c2C(=O)C2=C([O-])C3(O)C(=O)C(C(N)=O)=C([O-])C([NH+](C)C)C3C(O)C12</code> | <code>CC(c1ncncc1F)C(O)(Cn1cncn1)c1ccc(F)cc1F</code> | <code>1</code> | |
|
| <code>CC(C)CC1C(=O)N2CCCC2C2(O)OC(NC(=O)C3C=C4c5cccc6[nH]c(Br)c(c56)CC4[NH+](C)C3)(C(C)C)C(=O)N12</code> | <code>C[NH+](C)CCC=C1c2ccccc2Sc2ccc(Cl)cc21</code> | <code>1</code> | |
|
* Loss: [<code>ContrastiveLoss</code>](https://sbert.net/docs/package_reference/sentence_transformer/losses.html#contrastiveloss) with these parameters: |
|
```json |
|
{ |
|
"distance_metric": "SiameseDistanceMetric.COSINE_DISTANCE", |
|
"margin": 0.5, |
|
"size_average": true |
|
} |
|
``` |
|
|
|
### 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`: {'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 |
|
|
|
</details> |
|
|
|
### 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 |
|
```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", |
|
} |
|
``` |
|
|
|
#### ContrastiveLoss |
|
```bibtex |
|
@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} |
|
} |
|
``` |
|
|
|
<!-- |
|
## 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.* |
|
--> |