Views
No views yet
SentenceTransformer(
(0): Transformer({'max_seq_length': 128, 'do_lower_case': False, 'architecture': 'RobertaModel'})
(1): Pooling({'word_embedding_dimension': 1024, '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})
(2): Normalize()
)pip install -U chem-mrl>=0.7.31from chem_mrl import ChemMRL
2
3# Download from the 🤗 Hub
4model = ChemMRL("Derify/ChemMRL-beta")
5# Run inference
6sentences = [
7 "Clc1nccc(C#CCCc2nc3ccccc3o2)n1",
8 "O=Cc1nc2ccccc2o1",
9 "O[C@H]1CN(C(Cc2ccccc2)c2ccccc2)C[C@@H]1Cc1cnc[nH]1",
10]
11embeddings = model.backbone.encode(sentences)
12print(embeddings.shape)
13# [3, 1024]
14
15# Get the similarity scores for the embeddings
16similarities = model.backbone.similarity(embeddings, embeddings)
17print(similarities)
18# tensor([[1.0000, 0.3200, 0.1209],
19# [0.3200, 1.0000, 0.0950],
20# [0.1209, 0.0950, 1.0000]])
21
22# Load the model with half precision
23model = ChemMRL("Derify/ChemMRL-beta", use_half_precision=True)
24sentences = [
25 "Clc1nccc(C#CCCc2nc3ccccc3o2)n1",
26 "O=Cc1nc2ccccc2o1",
27 "O[C@H]1CN(C(Cc2ccccc2)c2ccccc2)C[C@@H]1Cc1cnc[nH]1",
28]
29embeddings = model.embed(sentences) # Use the embed method for half precision
30print(embeddings.shape)
31# [3, 1024]pubchem_10m_genmol_similaritychem_mrl.evaluation.EmbeddingSimilarityEvaluator.EmbeddingSimilarityEvaluator with these parameters:
1{
2 "precision": "float32"
3}| Split | Metric | Value |
|---|---|---|
| validation | spearman | 0.993212 |
| test | spearman | 0.993243 |
smiles_a, smiles_b, and label| smiles_a | smiles_b | label | |
|---|---|---|---|
| type | string | string | float |
| details |
|
|
|
Matryoshka2dLoss with these parameters:1{
2 "loss": "TanimotoSentLoss",
3 "n_layers_per_step": -1,
4 "last_layer_weight": 2.0,
5 "prior_layers_weight": 1.0,
6 "kl_div_weight": 0.5,
7 "kl_temperature": 0.3,
8 "matryoshka_dims": [
9 1024,
10 512,
11 256,
12 128,
13 64,
14 32,
15 16,
16 8
17 ],
18 "matryoshka_weights": [
19 1,
20 1,
21 1,
22 1,
23 1,
24 1,
25 1,
26 1
27 ],
28 "n_dims_per_step": -1
29}eval_strategy: stepsper_device_train_batch_size: 64per_device_eval_batch_size: 128learning_rate: 8e-06weight_decay: 6.505130550397454e-06warmup_ratio: 0.2data_seed: 42fp16: Truetf32: Trueload_best_model_at_end: Trueoptim: adamw_apex_fuseddataloader_pin_memory: Falseoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: stepsprediction_loss_only: Trueper_device_train_batch_size: 64per_device_eval_batch_size: 128per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: Nonelearning_rate: 8e-06weight_decay: 6.505130550397454e-06adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: 1.0num_train_epochs: 3max_steps: -1lr_scheduler_type: linearlr_scheduler_kwargs: {}warmup_ratio: 0.2warmup_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: 42jit_mode_eval: Falseuse_ipex: Falsebf16: Falsefp16: Truefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Falsefp16_full_eval: Falsetf32: Truelocal_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: Trueignore_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_apex_fusedoptim_args: Noneadafactor: Falsegroup_by_length: Falselength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Falsedataloader_persistent_workers: Falseskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falsehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_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: Noneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: Falseneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Falseuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Falseprompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | pubchem_10m_genmol_similarity_spearman |
|---|---|---|---|
| 0.0796 | 24500 | 121.4633 | - |
| 0.08 | 24616 | - | 0.9739 |
| 0.1592 | 49000 | 118.6111 | - |
| 0.16 | 49232 | - | 0.9817 |
| 0.2389 | 73500 | 117.491 | - |
| 0.24 | 73848 | - | 0.9848 |
| 0.3185 | 98000 | 116.3786 | - |
| 0.32 | 98464 | - | 0.9865 |
| 0.3997 | 123000 | 115.9773 | - |
| 0.4 | 123080 | - | 0.9873 |
| 0.4794 | 147500 | 115.2441 | - |
| 0.48 | 147696 | - | 0.9885 |
| 0.5590 | 172000 | 114.8674 | - |
| 0.56 | 172312 | - | 0.9887 |
| 0.6386 | 196500 | 114.6483 | - |
| 0.64 | 196928 | - | 0.9892 |
| 0.7199 | 221500 | 114.0507 | - |
| 0.72 | 221544 | - | 0.9898 |
| 0.7995 | 246000 | 113.5606 | - |
| 0.8 | 246160 | - | 0.9902 |
| 0.8791 | 270500 | 113.2762 | - |
| 0.88 | 270776 | - | 0.9907 |
| 0.9587 | 295000 | 113.3295 | - |
| 0.96 | 295392 | - | 0.9908 |
| 1.0400 | 320000 | 112.9253 | - |
| 1.04 | 320008 | - | 0.9909 |
| 1.1196 | 344500 | 112.584 | - |
| 1.12 | 344624 | - | 0.9910 |
| 1.1992 | 369000 | 112.616 | - |
| 1.2 | 369240 | - | 0.9916 |
| 1.2788 | 393500 | 112.4692 | - |
| 1.28 | 393856 | - | 0.9914 |
| 1.3585 | 418000 | 112.2679 | - |
| 1.3600 | 418472 | - | 0.9917 |
| 1.4397 | 443000 | 112.1639 | - |
| 1.44 | 443088 | - | 0.9919 |
| 1.5193 | 467500 | 112.1139 | - |
| 1.52 | 467704 | - | 0.9921 |
| 1.5990 | 492000 | 111.8096 | - |
| 1.6 | 492320 | - | 0.9923 |
| 1.6786 | 516500 | 111.8252 | - |
| 1.6800 | 516936 | - | 0.9922 |
| 1.7598 | 541500 | 111.836 | - |
| 1.76 | 541552 | - | 0.9924 |
| 1.8395 | 566000 | 111.8471 | - |
| 1.8400 | 566168 | - | 0.9924 |
| 1.9191 | 590500 | 111.7778 | - |
| 1.92 | 590784 | - | 0.9925 |
| 1.9987 | 615000 | 111.4892 | - |
| 2.0 | 615400 | - | 0.9927 |
| 2.0799 | 640000 | 111.2659 | - |
| 2.08 | 640016 | - | 0.9928 |
| 2.1596 | 664500 | 111.3635 | - |
| 2.16 | 664632 | - | 0.9927 |
| 2.2392 | 689000 | 111.0114 | - |
| 2.24 | 689248 | - | 0.9928 |
| 2.3188 | 713500 | 111.0559 | - |
| 2.32 | 713864 | - | 0.9929 |
| 2.3984 | 738000 | 110.5276 | - |
| 2.4 | 738480 | - | 0.9929 |
| 2.4797 | 763000 | 110.9828 | - |
| 2.48 | 763096 | - | 0.9930 |
| 2.5593 | 787500 | 110.8404 | - |
| 2.56 | 787712 | - | 0.9930 |
| 2.6389 | 812000 | 111.1937 | - |
| 2.64 | 812328 | - | 0.9931 |
| 2.7186 | 836500 | 110.6662 | - |
| 2.7200 | 836944 | - | 0.9931 |
| 2.7998 | 861500 | 110.7714 | - |
| 2.8 | 861560 | - | 0.9932 |
| 2.8794 | 886000 | 110.7638 | - |
| 2.88 | 886176 | - | 0.9932 |
| 2.9591 | 910500 | 110.7021 | - |
| 2.96 | 910792 | - | 0.9932 |
| 2.9997 | 923000 | 110.6097 | - |
1@inproceedings{reimers-2019-sentence-bert,
2 title = "Sentence-BERT: Sentence Embeddings using Siamese BERT-Networks",
3 author = "Reimers, Nils and Gurevych, Iryna",
4 booktitle = "Proceedings of the 2019 Conference on Empirical Methods in Natural Language Processing",
5 month = "11",
6 year = "2019",
7 publisher = "Association for Computational Linguistics",
8 url = "https://arxiv.org/abs/1908.10084",
9}1@misc{li20242d,
2 title={2D Matryoshka Sentence Embeddings},
3 author={Xianming Li and Zongxi Li and Jing Li and Haoran Xie and Qing Li},
4 year={2024},
5 eprint={2402.14776},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL}
8}1@misc{kusupati2024matryoshka,
2 title={Matryoshka Representation Learning},
3 author={Aditya Kusupati and Gantavya Bhatt and Aniket Rege and Matthew Wallingford and Aditya Sinha and Vivek Ramanujan and William Howard-Snyder and Kaifeng Chen and Sham Kakade and Prateek Jain and Ali Farhadi},
4 year={2024},
5 eprint={2205.13147},
6 archivePrefix={arXiv},
7 primaryClass={cs.LG}
8}1@online{kexuefm-8847,
2 title={CoSENT: A more efficient sentence vector scheme than Sentence-BERT},
3 author={Su Jianlin},
4 year={2022},
5 month={Jan},
6 url={https://kexue.fm/archives/8847},
7}1@online{cortes-2025-tanimotosentloss,
2 title={TanimotoSentLoss: Tanimoto Loss for SMILES Embeddings},
3 author={Emmanuel Cortes},
4 year={2025},
5 month={Jan},
6 url={https://github.com/emapco/chem-mrl},
7}