Views
No views yet
QED > 0.85, similarity > 0.5, with similarity also bounded below 1.0), and then keeps the top-scoring pair per anchor molecule.relative_margin=0.05 and max_negative_score_threshold = pos_score * percentage_margin. Training uses triplet-format samples with 5 mined negatives per anchor-positive pair and optimizes a multiple-negatives ranking objective, while reranking evaluation uses n-tuple samples with 30 mined negatives per query.1pip install -U "transformers>=4.57.1,<5.0.0"
2pip install -U sentence-transformers1from sentence_transformers import CrossEncoder
2
3# Download from the 🤗 Hub
4model = CrossEncoder("Derify/ChemRanker-alpha-sim")
5# Get scores for pairs of texts
6pairs = [
7 ['c1snnc1C[NH2+]Cc1cc2c(s1)CCC2', 'c1snnc1CCC[NH2+]Cc1cc2c(s1)CCC2'],
8 ['c1sc2c(c1-c1nc(C3CCOC3)no1)CCCC2', 'O=CCc1noc(-c2csc3c2CCCC3)n1'],
9 ['c1sc(C[NH2+]C2CC2)nc1C[NH+]1CCN2CCCC2C1', 'FC(F)[NH2+]Cc1nc(C[NH+]2CCN3CCCC3C2)cs1'],
10 ['c1sc(CC[NH+]2CCOCC2)nc1C[NH2+]C1CC1', 'CCc1nc(C[NH2+]C2CC2)cs1'],
11 ['c1sc(CC2CCC[NH2+]2)nc1C1CCCO1', 'c1sc(CC2CCC[NH2+]2)nc1C1CCCC1'],
12]
13scores = model.predict(pairs)
14print(scores.shape)
15# (5,)
16
17# Or rank different texts based on similarity to a single text
18ranks = model.rank(
19 'c1snnc1C[NH2+]Cc1cc2c(s1)CCC2',
20 [
21 'c1snnc1CCC[NH2+]Cc1cc2c(s1)CCC2',
22 'O=CCc1noc(-c2csc3c2CCCC3)n1',
23 'FC(F)[NH2+]Cc1nc(C[NH+]2CCN3CCCC3C2)cs1',
24 'CCc1nc(C[NH2+]C2CC2)cs1',
25 'c1sc(CC2CCC[NH2+]2)nc1C1CCCC1',
26 ]
27)
28# [{'corpus_id': ..., 'score': ...}, {'corpus_id': ..., 'score': ...}, ...]CrossEncoderRerankingEvaluator with these parameters:
1{
2 "at_k": 10
3}| Metric | Value |
|---|---|
| map | 0.4323 |
| mrr@10 | 0.6975 |
| ndcg@10 | 0.7034 |
smiles_a, smiles_b, and negative| smiles_a | smiles_b | negative | |
|---|---|---|---|
| type | string | string | string |
| details |
|
|
|
| smiles_a | smiles_b | negative |
|---|---|---|
c1sc2cc3c(cc2c1CC[NH2+]C1CC1)OCCO3 | FC(F)(F)[NH2+]CCc1csc2cc3c(cc12)OCCO3 | [NH3+]CCCc1cc2c(cc1C1CC1)OCO2 |
c1sc2cc3c(cc2c1CC[NH2+]C1CC1)OCCO3 | FC(F)(F)[NH2+]CCc1csc2cc3c(cc12)OCCO3 | COc1cc2c(cc1C[NH2+]C1CCC1)OCO2 |
c1sc2cc3c(cc2c1CC[NH2+]C1CC1)OCCO3 | FC(F)(F)[NH2+]CCc1csc2cc3c(cc12)OCCO3 | O=c1[nH]c2cc3c(cc2cc1CNC1CCCCC1)OCCO3 |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 10.0,
3 "num_negatives": 4,
4 "activation_fn": "torch.nn.modules.activation.Sigmoid"
5}smiles_a, smiles_b, negative_1, negative_2, negative_3, negative_4, negative_5, negative_6, negative_7, negative_8, negative_9, negative_10, negative_11, negative_12, negative_13, negative_14, negative_15, negative_16, negative_17, negative_18, negative_19, negative_20, negative_21, negative_22, negative_23, negative_24, negative_25, negative_26, negative_27, negative_28, negative_29, and negative_30| smiles_a | smiles_b | negative_1 | negative_2 | negative_3 | negative_4 | negative_5 | negative_6 | negative_7 | negative_8 | negative_9 | negative_10 | negative_11 | negative_12 | negative_13 | negative_14 | negative_15 | negative_16 | negative_17 | negative_18 | negative_19 | negative_20 | negative_21 | negative_22 | negative_23 | negative_24 | negative_25 | negative_26 | negative_27 | negative_28 | negative_29 | negative_30 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| type | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string | string |
| details |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| smiles_a | smiles_b | negative_1 | negative_2 | negative_3 | negative_4 | negative_5 | negative_6 | negative_7 | negative_8 | negative_9 | negative_10 | negative_11 | negative_12 | negative_13 | negative_14 | negative_15 | negative_16 | negative_17 | negative_18 | negative_19 | negative_20 | negative_21 | negative_22 | negative_23 | negative_24 | negative_25 | negative_26 | negative_27 | negative_28 | negative_29 | negative_30 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
c1snnc1C[NH2+]Cc1cc2c(s1)CCC2 | c1snnc1CCC[NH2+]Cc1cc2c(s1)CCC2 | c1snnc1CCC[NH2+]Cc1cc2c(s1)CCC2 | Cn1cc(C[NH2+]Cc2cc3c(s2)CCC3)nn1 | Cn1cc(CC[NH2+]Cc2cc3c(s2)CCC3)nn1 | Cc1cc(C[NH2+]Cc2csnn2)sc1C | NC(=O)c1csc(C[NH2+]Cc2cc3c(s2)CCC3)c1 | Cc1cc(CC[NH2+]Cc2csnn2)sc1C | Ic1ccc(C[NH2+]Cc2cc3c(s2)CCC3)o1 | Cc1cc(C[NH2+]CCCCc2cc3c(s2)CCC3)c(C)s1 | c1ccc(C[NH2+]Cc2cc3c(s2)CCC3)cc1 | c1ncc(C[NH2+]Cc2csnn2)s1 | FC(F)c1csc(C[NH2+]Cc2cc3c(s2)CCC3)c1 | c1c(C[NH2+]CC2CC2)sc2c1CSCC2 | N#Cc1cc(F)cc(C[NH2+]Cc2cc3c(s2)CCC3)c1 | c1cc(C[NH2+]Cc2nc3c(s2)CCC3)no1 | CCc1ccc(C[NH2+]Cc2csnn2)s1 | NCc1csc(NCc2cc3c(s2)CCC3)n1 | C[object Object]Cc1nnc(-c2cc3c(s2)CCCC3)o1 | Fc1cc(C[NH2+]Cc2cc3c(s2)CCC3)ccc1Br |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H2+]2)cs1 | c1cc(C[NH2+]C2CC2)c(C[NH+]2CCN3CCCCC3C2)o1 | O=C(Cc1nc(CCl)cs1)N1CCC[NH+]2CCCC2C1 | CC[NH2+]Cc1csc(N2CCC3C(CCC[NH+]3C)C2)n1 | c1sc(C[NH2+]C2CC2)nc1C[NH+]1CCCCC1 | [NH3+]Cc1nc(C[NH+]2CCCC2C2CCCC2)cs1 | Cc1csc(C[NH+]2CCC3C[NH2+]CC3C2)n1 | c1cc(C[NH+]2CCCN3CCCC3C2)nc(C2CC2)n1 | Cc1ccsc1C[NH2+]CCN1CCN2CCCC2C1 | c1sc(C[NH2+]C2CCCC2)nc1C[NH+]1CCCCC1 | Brc1csc(C[NH2+]CCN2CCN3CCCCC3C2)c1 | Cc1nc(CCC[NH2+]C2CCN3CCCCC23)cs1 | CCOC(=O)c1nc(CN2CC3CCC[NH2+]C3C2)cs1 | CCCC(=O)c1nc(CN2CC3CCC[NH2+]C3C2)cs1 | CC(C)(C)c1csc(CN2CCC[NH2+]C(C3CC3)C2)n1 | COCc1nc(CN2CCC([NH3+])C2)cs1 | CCC[NH2+]Cc1nc(C[NH+]2CC3CCC2C3)cs1 | CCC1CN2CCCC2C[NH+]1CCc1csc(C)n1 |
MultipleNegativesRankingLoss with these parameters:
1{
2 "scale": 10.0,
3 "num_negatives": 4,
4 "activation_fn": "torch.nn.modules.activation.Sigmoid"
5}eval_strategy: epochper_device_train_batch_size: 256per_device_eval_batch_size: 256torch_empty_cache_steps: 1000learning_rate: 3e-05weight_decay: 1e-05max_grad_norm: Nonelr_scheduler_type: warmup_stable_decaylr_scheduler_kwargs: {'num_decay_steps': 6385, 'warmup_type': 'linear', 'decay_type': '1-sqrt'}warmup_steps: 6385seed: 12data_seed: 24681357bf16: Truebf16_full_eval: Truetf32: Truedataloader_num_workers: 8dataloader_prefetch_factor: 2load_best_model_at_end: Trueoptim: stable_adamwoptim_args: decouple_lr=True,max_lr=3e-05dataloader_persistent_workers: Trueresume_from_checkpoint: Falsegradient_checkpointing: Truetorch_compile: Truetorch_compile_backend: inductortorch_compile_mode: max-autotuneeval_on_start: Truebatch_sampler: no_duplicatesoverwrite_output_dir: Falsedo_predict: Falseeval_strategy: epochprediction_loss_only: Trueper_device_train_batch_size: 256per_device_eval_batch_size: 256per_gpu_train_batch_size: Noneper_gpu_eval_batch_size: Nonegradient_accumulation_steps: 1eval_accumulation_steps: Nonetorch_empty_cache_steps: 1000learning_rate: 3e-05weight_decay: 1e-05adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08max_grad_norm: Nonenum_train_epochs: 3max_steps: -1lr_scheduler_type: warmup_stable_decaylr_scheduler_kwargs: {'num_decay_steps': 6385, 'warmup_type': 'linear', 'decay_type': '1-sqrt'}warmup_ratio: 0.0warmup_steps: 6385log_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: 12data_seed: 24681357jit_mode_eval: Falsebf16: Truefp16: Falsefp16_opt_level: O1half_precision_backend: autobf16_full_eval: Truefp16_full_eval: Falsetf32: Truelocal_rank: 0ddp_backend: Nonetpu_num_cores: Nonetpu_metrics_debug: Falsedebug: []dataloader_drop_last: Truedataloader_num_workers: 8dataloader_prefetch_factor: 2past_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}parallelism_config: Nonedeepspeed: Nonelabel_smoothing_factor: 0.0optim: stable_adamwoptim_args: decouple_lr=True,max_lr=3e-05adafactor: Falsegroup_by_length: Falselength_column_name: lengthproject: huggingfacetrackio_space_id: trackioddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falsedataloader_pin_memory: Truedataloader_persistent_workers: Trueskip_memory_metrics: Trueuse_legacy_prediction_loop: Falsepush_to_hub: Falseresume_from_checkpoint: Falsehub_model_id: Nonehub_strategy: every_savehub_private_repo: Nonehub_always_push: Falsehub_revision: Nonegradient_checkpointing: Truegradient_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: Truetorch_compile_backend: inductortorch_compile_mode: max-autotuneinclude_tokens_per_second: Falseinclude_num_input_tokens_seen: noneftune_noise_alpha: Noneoptim_target_modules: Nonebatch_eval_metrics: Falseeval_on_start: Trueuse_liger_kernel: Falseliger_kernel_config: Noneeval_use_gather_object: Falseaverage_tokens_across_devices: Trueprompts: Nonebatch_sampler: no_duplicatesmulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}| Epoch | Step | Training Loss | Validation Loss | ndcg@10 |
|---|---|---|---|---|
| 1.0963 | 7000 | 0.0046 | - | - |
| 1.2529 | 8000 | 0.0043 | - | - |
| 1.4096 | 9000 | 0.0038 | - | - |
| 1.5662 | 10000 | 0.0035 | - | - |
| 1.7228 | 11000 | 0.0033 | - | - |
| 1.8794 | 12000 | 0.0031 | - | - |
| 2.0 | 12770 | - | 1.5814 | 0.6986 |
| 2.0360 | 13000 | 0.003 | - | - |
| 2.1926 | 14000 | 0.0027 | - | - |
| 2.3493 | 15000 | 0.0025 | - | - |
| 2.5059 | 16000 | 0.0025 | - | - |
| 2.6625 | 17000 | 0.0024 | - | - |
| 2.8191 | 18000 | 0.0024 | - | - |
| 2.9757 | 19000 | 0.0024 | - | - |
| 3.0 | 19155 | - | 1.5688 | 0.7034 |
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{moreira2025nvretrieverimprovingtextembedding,
2 title={NV-Retriever: Improving text embedding models with effective hard-negative mining},
3 author={Gabriel de Souza P. Moreira and Radek Osmulski and Mengyao Xu and Ronay Ak and Benedikt Schifferer and Even Oldridge},
4 year={2025},
5 eprint={2407.15831},
6 archivePrefix={arXiv},
7 primaryClass={cs.IR},
8 url={https://arxiv.org/abs/2407.15831},
9}