CoolFace
Modelpublic

vab46/nomic-embed-text-v1.5_Clinical-Trials_Matryoshka_final

sourceHugging Faceapache-2.0updated 29d agoView on Hugging Face
1likes167downloads
Model Card

nomic-embed text-v1.5 Clinical-Trials Matryoshka

This is a sentence-transformers model finetuned from nomic-ai/nomic-embed-text-v1.5 on the dataset from Clinical_trials_anchor-positive-pairs_EmbeddingModel-data_final. It maps sentences & paragraphs to a 768-dimensional dense vector space and can be used for semantic textual similarity, semantic search, paraphrase mining, classification, clustering, and more.

Model Details

Model Description

Model Sources

Full Model Architecture

SentenceTransformer(
  (0): Transformer({'transformer_task': 'feature-extraction', 'modality_config': {'text': {'method': 'forward', 'method_output_name': 'last_hidden_state'}}, 'module_output_name': 'token_embeddings', 'architecture': 'NomicBertModel'})
  (1): Pooling({'embedding_dimension': 768, 'pooling_mode': 'mean', '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("vab46/nomic-embed-text-v1.5_Clinical-Trials_Matryoshka_final")
# Run inference
documents = [
    'TITLE: Safety and Efficacy of Six-Channel Radiofrequency Ablation System for Renal Denervation in Patients With Untreated Grade I Hypertension: a Pilot Study\nSUMMARY: Prospective, Multi-Center, Randomized, shame-Controlled, Uptake clinical trial to evaluate the efficacy and safety of the six-channel radio-frequency(RF) renal denervation system-comprising the six-channel RF generator (specification model: 25D1G, software release version: SRG-V1) and the disposable ultra-guiding RF denervation catheter (specification model: 25C6W127F115T)-for renal denervation in patients with grade I hypertension and without taking antihypertensive medicines.\nINCLUSION_CRITERIA: 1. Male or female, aged 18 to 65 years inclusive\n2. Hypertension duration longer than 3 months\n3. Hypertensive subjects who have been stopped taking antihypertensive drugs continuously and stably for at least 4 weeks or who do not take antihypertensive drugs , with office systolic/diastolic blood pressure still ≥140/90 mmHg and \\<160/100 mmHg, and 24-hour ambulatory mean systolic /diastolic pressure ≥130/80 mmHg and \\<140/90 mmHg;\n4. The subject or his/her legal representative fully understands the content of the informed consent form for this trial and voluntarily signs the written informed consent form.',
]
queries = [
    "I have high blood pressure, but I'm not on any medication. Can I participate in this study?",
    'What is the primary goal of this clinical trial regarding pain management in premature newborns?',
    "I'm on a ventilator and feel really short of breath. Can anything be done to make me feel more comfortable?",
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 768] [3, 768]

# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.5783, 0.0218, 0.0940]])

<!--

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

Information Retrieval
Metricdim_768dim_512dim_256dim_128dim_64
cosine_accuracy@10.54760.53490.52350.49050.4409
cosine_accuracy@30.6620.64170.65310.60480.5667
cosine_accuracy@50.69380.68740.68360.66070.6213
cosine_accuracy@100.73950.73950.73060.71160.6773
cosine_precision@10.54760.53490.52350.49050.4409
cosine_precision@30.22070.21390.21770.20160.1889
cosine_precision@50.13880.13750.13670.13210.1243
cosine_precision@100.0740.0740.07310.07120.0677
cosine_recall@10.54760.53490.52350.49050.4409
cosine_recall@30.6620.64170.65310.60480.5667
cosine_recall@50.69380.68740.68360.66070.6213
cosine_recall@100.73950.73950.73060.71160.6773
cosine_ndcg@100.64330.63460.6280.59740.5563
cosine_mrr@100.61260.60150.59510.56120.5179
cosine_map@1000.61620.60490.59860.56540.5228
Comparison with the baseline model performance on same data
metricdimensionsbase_valueft_valuediff%change
0accuracy@17680.432020.5476490.11562926.76471
1accuracy@15120.430750.5362130.10546424.48378
2accuracy@12560.4002540.5184240.1181729.52381
3accuracy@11280.37230.4993650.12706534.12969
4accuracy@1640.294790.4561630.16137254.74138
5accuracy@37680.528590.6531130.12452423.55769
6accuracy@35120.5196950.6416770.12198223.47188
7accuracy@32560.5019060.6365950.13468926.83544
8accuracy@31280.4739520.607370.13341828.15013
9accuracy@3640.4167730.5705210.15374836.89024
10accuracy@57680.5743330.7001270.12579421.90265
11accuracy@55120.5705210.6874210.116920.48998
12accuracy@52560.5501910.6747140.12452422.63279
13accuracy@51280.5209660.6531130.13214725.36585
14accuracy@5640.4650570.6175350.15247832.78689
15accuracy@107680.6226180.7407880.1181718.97959
16accuracy@105120.6099110.7344350.12452420.41667
17accuracy@102560.607370.7242690.116919.24686
18accuracy@101280.5743330.7026680.12833522.34513
19accuracy@10640.5235070.6709020.14739528.15534
20recall@17680.432020.5476490.11562926.76471
21recall@15120.430750.5362130.10546424.48378
22recall@12560.4002540.5184240.1181729.52381
23recall@11280.37230.4993650.12706534.12969
24recall@1640.294790.4561630.16137254.74138
25recall@37680.528590.6531130.12452423.55769
26recall@35120.5196950.6416770.12198223.47188
27recall@32560.5019060.6365950.13468926.83544
28recall@31280.4739520.607370.13341828.15013
29recall@3640.4167730.5705210.15374836.89024
30recall@57680.5743330.7001270.12579421.90265
31recall@55120.5705210.6874210.116920.48998
32recall@52560.5501910.6747140.12452422.63279
33recall@51280.5209660.6531130.13214725.36585
34recall@5640.4650570.6175350.15247832.78689
35recall@107680.6226180.7407880.1181718.97959
36recall@105120.6099110.7344350.12452420.41667
37recall@102560.607370.7242690.116919.24686
38recall@101280.5743330.7026680.12833522.34513
39recall@10640.5235070.6709020.14739528.15534
40precision@17680.432020.5476490.11562926.76471
41precision@15120.430750.5362130.10546424.48378
42precision@12560.4002540.5184240.1181729.52381
43precision@11280.37230.4993650.12706534.12969
44precision@1640.294790.4561630.16137254.74138
45precision@37680.1761970.2177040.04150823.55769
46precision@35120.1732320.2138920.04066123.47188
47precision@32560.1673020.2121980.04489626.83544
48precision@31280.1579840.2024570.04447328.15013
49precision@3640.1389240.1901740.05124936.89024
50precision@57680.1148670.1400250.02515921.90265
51precision@55120.1141040.1374840.0233820.48998
52precision@52560.1100380.1349430.02490522.63279
53precision@51280.1041930.1306230.02642925.36585
54precision@5640.0930110.1235070.03049632.78689
55precision@107680.0622620.0740790.01181718.97959
56precision@105120.0609910.0734430.01245220.41667
57precision@102560.0607370.0724270.0116919.24686
58precision@101280.0574330.0702670.01283422.34513
59precision@10640.0523510.067090.0147428.15534
60map@1007680.4961520.6132220.1170723.59553
61map@1005120.4920570.6038530.11179622.72006
62map@1002560.4697490.5924480.12269926.12
63map@1001280.4410450.5705480.12950329.36267
64map@100640.3748520.5296230.1547741.28835
65mrr@107680.4916780.6101030.11842524.08598
66mrr@105120.4867970.6002890.11349223.31392
67mrr@102560.4647690.588660.12389126.6565
68mrr@101280.4353130.5662230.13091130.07274
69mrr@10640.3681280.5246020.15647442.50527
70ndcg@107680.5230480.6416480.118622.67486
71ndcg@105120.5163470.6326010.11625422.5146
72ndcg@102560.4988440.6214550.12261124.57903
73ndcg@101280.4685570.5992040.13064627.88273
74ndcg@10640.4055030.5598060.15430338.05217
AVERAGE27.30715
VARIANCE60.62231
STD_DEV7.786033
For the list of Sequential Evaluator score on nested mashtroyska embeddings [768, 512, 256, 128, 64]:-

Initial(pre-trained) score:- 0.405----------->Final(fine-tuned) score:- 0.56

<!--

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: 7,079 training samples
  • Columns: <code>positive</code> and <code>anchor</code>
  • Approximate statistics based on the first 100 samples: | | positive | anchor | |:---------|:-------------------------------------------------------------------------------------|:-----------------------------------------------------------------------------------| | type | string | string | | modality | text | text | | details | <ul><li>min: 72 tokens</li><li>mean: 290.18 tokens</li><li>max: 675 tokens</li></ul> | <ul><li>min: 11 tokens</li><li>mean: 21.08 tokens</li><li>max: 42 tokens</li></ul> |
  • Samples: | positive | anchor | |:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:---------------------------------------------------------------------------------------------------------------------------| | <code>TITLE: Risk Classification and Prediction of Histopathological Subtypes in Basal Cell Carcinoma Using a CNN-Based Artificial Intelligence Model on Dermoscopic Images<br>SUMMARY: This retrospective observational study aims to develop and evaluate a convolutional neural network (CNN)-based artificial intelligence model for risk classification and histopathological subtype prediction of basal cell carcinoma (BCC) using clinical and dermoscopic images. Histopathologically confirmed BCC cases from a dermatology archive will be included. The primary objective is to assess the diagnostic performance of the CNN model in classifying BCC as low-risk or high-risk. Secondary objectives include predicting histopathological subtypes and comparing the model's performance with that of dermatology physicians. Histopathological diagnosis will serve as the reference standard. All archived data will be anonymized before analysis.<br>INCLUSIONCRITERIA:<br>Patients with histopathologically confirmed basal cell carc...</code> | <code>Are dermoscopic images with sufficient image quality and resolution required for participation in this trial?</code> | | <code>TITLE: Postural Control Mechanism During a Stationary Wheelchair Wheelie<br>SUMMARY: The purpose of this study was to investigate the postural control during a stationary wheelchair wheelie. A group of participants was recruited for this observational study. Participants were asked to perform and maintain the stationary phase of a wheelchair wheelie, during which kinematic and kinetic data were recorded.<br>INCLUSIONCRITERIA:<br>Spinal cord injury at or below the T1 (first thoracic) level.<br>Between 20 and 65 years of age.<br>Currently using a manual wheelchair as the primary means of mobility.<br>Able to perform and maintain a wheelchair wheelie for at least 20 seconds</code> | <code>Is there an age restriction for participants in this clinical trial, and if so, what is it?</code> | | <code>TITLE: The Effect of Mandala Art Therapy on Fear and Anxiety of Childbirth in Expectant Fathers Waiting Outside the Delivery Room: A Randomized Controlled Study<br>SUMMARY: This randomized controlled trial is designed to evaluate the effectiveness of mandala art therapy in reducing childbirth fear and state anxiety among fathers whose partners are nulliparous pregnant women and who are waiting in the obstetric ward waiting area during labor. Eligible participants will be randomly allocated to either the intervention or the control group. Fathers assigned to the intervention group will participate in a single 20-25-minute mandala art therapy session, whereas those in the control group will receive standard care without any additional intervention. Childbirth fear and state anxiety will be assessed using the Fathers' Birth Fear Scale and the State subscale of the Spielberger State-Trait Anxiety Inventory, respectively, at baseline and immediately following the intervention. The findings of ...</code> | <code>Could a father with a partner expecting their first child qualify for this study?</code> |
  • Loss: <code>MatryoshkaLoss</code> with these parameters:
json
  {
      "loss": "MultipleNegativesRankingLoss",
      "matryoshka_dims": [
          768,
          512,
          256,
          128,
          64
      ],
      "matryoshka_weights": [
          1,
          1,
          1,
          1,
          1
      ],
      "n_dims_per_step": -1
  }

Training Hyperparameters

Non-Default Hyperparameters
  • num_train_epochs: 4
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • warmup_steps: 0.1
  • gradient_accumulation_steps: 8
  • fp16: True
  • per_device_eval_batch_size: 32
  • load_best_model_at_end: True
  • batch_sampler: no_duplicates
All Hyperparameters

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

  • per_device_train_batch_size: 8
  • num_train_epochs: 4
  • max_steps: -1
  • learning_rate: 2e-05
  • lr_scheduler_type: cosine
  • lr_scheduler_kwargs: None
  • warmup_steps: 0.1
  • optim: adamwtorchfused
  • optim_args: None
  • weight_decay: 0.0
  • adam_beta1: 0.9
  • adam_beta2: 0.999
  • adam_epsilon: 1e-08
  • optim_target_modules: None
  • gradient_accumulation_steps: 8
  • average_tokens_across_devices: True
  • max_grad_norm: 1.0
  • label_smoothing_factor: 0.0
  • bf16: False
  • fp16: True
  • bf16_full_eval: False
  • fp16_full_eval: False
  • tf32: None
  • gradient_checkpointing: False
  • gradient_checkpointing_kwargs: None
  • torch_compile: False
  • torch_compile_backend: None
  • torch_compile_mode: None
  • use_liger_kernel: False
  • liger_kernel_config: None
  • use_cache: False
  • neftune_noise_alpha: None
  • torch_empty_cache_steps: None
  • auto_find_batch_size: False
  • log_on_each_node: True
  • logging_nan_inf_filter: True
  • include_num_input_tokens_seen: no
  • log_level: passive
  • log_level_replica: warning
  • disable_tqdm: False
  • project: huggingface
  • trackio_space_id: None
  • trackio_bucket_id: None
  • trackio_static_space_id: None
  • per_device_eval_batch_size: 32
  • prediction_loss_only: True
  • eval_on_start: False
  • eval_do_concat_batches: True
  • eval_use_gather_object: False
  • eval_accumulation_steps: None
  • include_for_metrics: []
  • batch_eval_metrics: False
  • save_only_model: False
  • save_on_each_node: False
  • enable_jit_checkpoint: False
  • push_to_hub: False
  • hub_private_repo: None
  • hub_model_id: None
  • hub_strategy: every_save
  • hub_always_push: False
  • hub_revision: None
  • load_best_model_at_end: True
  • ignore_data_skip: False
  • restore_callback_states_from_checkpoint: False
  • full_determinism: False
  • seed: 42
  • data_seed: None
  • use_cpu: False
  • accelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}
  • parallelism_config: None
  • dataloader_drop_last: False
  • dataloader_num_workers: 0
  • dataloader_pin_memory: True
  • dataloader_persistent_workers: False
  • dataloader_prefetch_factor: None
  • dataloader_multiprocessing_context: None
  • dataloader_in_order: True
  • remove_unused_columns: True
  • label_names: None
  • train_sampling_strategy: random
  • length_column_name: length
  • ddp_find_unused_parameters: None
  • ddp_bucket_cap_mb: None
  • ddp_broadcast_buffers: False
  • ddp_static_graph: None
  • ddp_backend: None
  • ddp_timeout: 1800
  • fsdp: None
  • fsdp_config: None
  • deepspeed: None
  • debug: []
  • skip_memory_metrics: True
  • do_predict: False
  • resume_from_checkpoint: None
  • local_rank: -1
  • prompts: None
  • batch_sampler: no_duplicates
  • multi_dataset_batch_sampler: proportional
  • router_mapping: {}
  • learning_rate_mapping: {}
  • warmup_ratio: None

</details>

Training Logs

EpochStepTraining Lossdim_768_cosine_ndcg@10dim_512_cosine_ndcg@10dim_256_cosine_ndcg@10dim_128_cosine_ndcg@10dim_64_cosine_ndcg@10
0.0904104.1897-----
0.1808203.0473-----
0.2712302.3585-----
0.3616401.5994-----
0.4520501.6686-----
0.5424601.5741-----
0.6328701.5577-----
0.7232801.5720-----
0.8136901.3066-----
0.90401001.3134-----
0.99441101.3546-----
1.0111-0.62860.62070.61170.58640.5414
1.08141201.0738-----
1.17181301.1824-----
1.26211400.9235-----
1.35251501.1639-----
1.44291600.9303-----
1.53331700.8958-----
1.62371801.0578-----
1.71411901.0462-----
1.80452000.9778-----
1.89492100.8817-----
1.98532200.8784-----
2.0222-0.64160.63260.62150.59920.5598
2.07232300.7649-----
2.16272400.6925-----
2.25312500.7085-----
2.34352600.6575-----
2.43392700.7791-----
2.52432800.6990-----
2.61472900.6887-----
2.70513000.8579-----
2.79553100.7612-----
2.88593200.5202-----
2.97633300.7271-----
3.0333-0.64220.63600.62840.59850.5562
3.06333400.6966-----
3.15373500.5423-----
3.24413600.6177-----
3.33453700.5960-----
3.42493800.5821-----
3.51533900.4473-----
3.60564000.6135-----
3.69604100.5474-----
3.78644200.4391-----
3.87684300.5270-----
3.96724400.5693-----
4.0444-0.64330.63460.62800.59740.5563
  • The bold row denotes the saved checkpoint.

Training Time

  • Training: 31.6 minutes

Framework Versions

  • Python: 3.13.15
  • Sentence Transformers: 5.7.0
  • Transformers: 5.15.0
  • PyTorch: 2.11.0+cu128
  • Accelerate: 1.14.0
  • Datasets: 4.0.0
  • Tokenizers: 0.22.2

Additional Resources

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",
}
MatryoshkaLoss
bibtex
@misc{kusupati2024matryoshka,
    title={Matryoshka Representation Learning},
    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},
    year={2024},
    eprint={2205.13147},
    archivePrefix={arXiv},
    primaryClass={cs.LG}
}
MultipleNegativesRankingLoss
bibtex
@misc{oord2019representationlearningcontrastivepredictive,
      title={Representation Learning with Contrastive Predictive Coding},
      author={Aaron van den Oord and Yazhe Li and Oriol Vinyals},
      year={2019},
      eprint={1807.03748},
      archivePrefix={arXiv},
      primaryClass={cs.LG},
      url={https://arxiv.org/abs/1807.03748},
}

<!--

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. -->