ksg-dfci/TrialSpace-0526
SentenceTransformer
This is a sentence-transformers model trained on the mnridataset and contrastivedataset datasets. It maps sentences & paragraphs to a 1024-dimensional dense vector space and can be used for retrieval.
Model Details
Model Description
- Model Type: Sentence Transformer <!-- - Base model: Unknown -->
- Maximum Sequence Length: 2500 tokens
- Output Dimensionality: 1024 dimensions
- Similarity Function: Cosine Similarity
- Supported Modality: Text
- Training Datasets:
- mnri_dataset
- contrastive_dataset <!-- - Language: Unknown --> <!-- - License: Unknown -->
Model Sources
- Documentation: Sentence Transformers Documentation
- Repository: Sentence Transformers on GitHub
- Hugging Face: Sentence Transformers on Hugging Face
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': 'Qwen3Model'})
(1): Pooling({'embedding_dimension': 1024, 'pooling_mode': 'lasttoken', 'include_prompt': True})
(2): Normalize({})
)Usage
Direct Usage (Sentence Transformers)
First install the Sentence Transformers library:
pip install -U sentence-transformersThen you can load this model and run inference.
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("sentence_transformers_model_id")
# Run inference
queries = [
'Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 12\nSex: Male\nCancer type: Mediastinal mixed germ cell tumor\nHistology: Embryonal carcinoma, choriocarcinoma, and yolk sac tumor\nCurrent extent: Metastatic (mediastinal mass, mediastinal lymphadenopathy, and brain metastases in the right frontal and left parietal lobes). Most recent tumor markers (2018-03-30): AFP 310 ng/mL, Beta-hCG 850 mIU/mL, LDH 410 U/L; increasing trend.\nBiomarkers: SALL4 positive, AFP positive (yolk sac), Beta-hCG positive (choriocarcinoma), CD30 positive (embryonal carcinoma), Glypican-3 positive (yolk sac), Cytokeratin (AE1/AE3) positive. NGS: KRAS p.G12D pathogenic mutation, PTEN homozygous deletion, TP53 p.P72R (variant of uncertain significance), isochromosome 12p, gain of 20q.\nTreatment history:\n# 2015: bleomycin, etoposide, cisplatin; achieved partial response\n# 2016-02-09: Partial resection of anterior mediastinal mass\n# 2016-12-05-present: ifosfamide, cisplatin; achieved partial response, subsequently progressed',
]
documents = [
'Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 1 to 21 years. Sex allowed: Both. Cancer type allowed: mediastinal mixed germ cell tumor. Histology allowed: pediatric malignant solid tumor. Cancer burden allowed: high-risk (expected 5-year Event-Free Survival < 60%) and < 30% chance at long-term cure and disease status of Stable Disease or better. Prior treatment required: prior primary therapy. Prior treatment excluded: NA. Biomarkers required: satisfactory TIL cellular product availability (assessed during screening). Biomarkers excluded: NA.',
'Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 50 years. Sex allowed: Male. Cancer type allowed: Any cancer. Histology allowed: Hematologic. Cancer burden allowed: Any. Prior treatment required: NA. Prior treatment excluded: NA. Biomarkers required: NA. Biomarkers excluded: NA.',
'Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 29 years. Sex allowed: both. Cancer type allowed: mixed phenotype acute leukemia with T cell dominant phenotype. Histology allowed: mixed phenotype acute leukemia with T cell dominant phenotype. Cancer burden allowed: Second or greater relapse or first relapse post-allogeneic hematopoietic stem cell transplant or primary refractory disease or relapsed and refractory disease. Prior treatment required: NA. Prior treatment excluded: CD7 targeted therapy. Biomarkers required: CD7 expression on leukemic blasts (at least 90% of blasts positive by flow cytometry or immunohistochemistry) assessed during screening. Biomarkers excluded: NA.',
]
query_embeddings = model.encode_query(queries)
document_embeddings = model.encode_document(documents)
print(query_embeddings.shape, document_embeddings.shape)
# [1, 1024] [3, 1024]
# Get the similarity scores for the embeddings
similarities = model.similarity(query_embeddings, document_embeddings)
print(similarities)
# tensor([[0.4132, 0.2552, 0.1695]])<!--
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. -->
<!--
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 Datasets
mnri_dataset
- Dataset: mnri_dataset
- Size: 1,174,581 training samples
- Columns: <code>patientsummarytrunc</code> and <code>thisspacetrunc</code>
- Approximate statistics based on the first 1000 samples: | | patientsummarytrunc | thisspacetrunc | |:--------|:-------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------| | type | string | string | | details | <ul><li>min: 146 tokens</li><li>mean: 323.8 tokens</li><li>max: 554 tokens</li></ul> | <ul><li>min: 101 tokens</li><li>mean: 155.35 tokens</li><li>max: 283 tokens</li></ul> |
- Samples: | patientsummarytrunc | thisspacetrunc | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 6<br>Sex: Male<br>Cancer type: Kaposiform hemangioendothelioma of the right lower extremity<br>Histology: Spindle cell vascular neoplasm (CD31 positive, CD34 positive, ERG positive, HHV-8 negative)<br>Current extent: Localized; status post wide local excision on 2023-02-06 with negative margins<br>Biomarkers: PIK3CA p.E542K mutant; PTEN, AKT1, KRAS, and TP53 wild-type<br>Treatment history:<br># 2020-10-28 to 2021-04-04: vincristine; achieved partial response (tumor decreased from 7 cm to 5.2 cm)<br># 2021-11-29 to 2022-10-18: paclitaxel; achieved partial response (tumor decreased from 9 cm to 6.4 cm)<br># 2023-02-06: wide local excision of right calf mass; negative margins</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 14 years. Sex allowed: Male or Female. Cancer type allowed: Kaposiform hemangioendothelioma. Histology allowed: NA. Cancer burden allowed: NA. Prior treatment required: NA. Prior treatment excluded: sirolimus or other mTOR inhibitors. Biomarkers required: NA. Biomarkers excluded: NA.</code> | | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 14<br>Sex: Male<br>Cancer type: Kaposiform Hemangioendothelioma of the right lateral neck<br>Histology: Spindle cell proliferation with kaposiform architecture<br>Current extent: Stage T1N0M0; stable 3.1 cm mass in the right lateral neck as of 2021-02-08; platelets 228,000/uL as of 2020-12-12 (stable, no Kasabach-Merritt phenomenon)<br>Biomarkers: CD31 positive, CD34 positive, ERG positive, HHV-8 negative, GLUT1 negative/patchy, Ki-67 less than 5%, PIK3CA p.H1047R mutation, PTEN p.S167R mutation, STK11 wild-type, TSC1 wild-type<br>Treatment history:<br># 2018-11-21-2021-02-08: observation; stable disease</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 14 years. Sex allowed: Male or Female. Cancer type allowed: Kaposiform hemangioendothelioma. Histology allowed: NA. Cancer burden allowed: NA. Prior treatment required: NA. Prior treatment excluded: sirolimus or other mTOR inhibitors. Biomarkers required: NA. Biomarkers excluded: NA.</code> | | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 17 Sex: Male Cancer type: T-cell lymphoblastic lymphoma Histology: T-cell lymphoblastic lymphoma Current extent: Relapsed and refractory. As of 2019-12-06, anterior mediastinal mass measuring 5.5 cm with associated superior vena cava narrowing and bilateral hilar lymphadenopathy. As of 2020-04-21, bone marrow involvement with 22% lymphoblasts. LDH is elevated (normalized during remission, rose to 412 U/L at relapse in 2019-03-26, and remains elevated as of 2020-08-21). Biomarkers: TdT positive, CD3 positive, CD7 positive, CD2 positive, CD5 positive, CD19 negative, CD20 negative, CD45 positive, Ki-67 >95%; NOTCH1 p.V1744G, CDKN2A homozygous deletion, PTEN p.R130Q, 12q gain Treatment history: # 2016-07 to 2016-12: vincristine, prednisone, L-asparaginase; best response ...</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 29 years. Sex allowed: both. Cancer type allowed: T-cell acute lymphoblastic leukemia. Histology allowed: T-cell acute lymphoblastic leukemia. Cancer burden allowed: Second or greater relapse or first relapse post-allogeneic hematopoietic stem cell transplant or primary refractory disease or relapsed and refractory disease. Prior treatment required: NA. Prior treatment excluded: CD7 targeted therapy. Biomarkers required: CD7 expression on leukemic blasts (at least 90% of blasts positive by flow cytometry or immunohistochemistry) assessed during screening. Biomarkers excluded: NA.</code> |
- Loss: <code>MultipleNegativesRankingLoss</code> with these parameters:
{
"scale": 20.0,
"similarity_fct": "cos_sim",
"gather_across_devices": false,
"directions": [
"query_to_doc"
],
"partition_mode": "joint",
"hardness_mode": null,
"hardness_strength": 0.0
}contrastive_dataset
- Dataset: contrastive_dataset
- Size: 1,824,636 training samples
- Columns: <code>patientsummarytrunc</code>, <code>thisspacetrunc</code>, and <code>label</code>
- Approximate statistics based on the first 1000 samples: | | patientsummarytrunc | thisspacetrunc | label | |:--------|:-------------------------------------------------------------------------------------|:--------------------------------------------------------------------------------------|:----------------------------------------------------------------| | type | string | string | float | | details | <ul><li>min: 76 tokens</li><li>mean: 294.03 tokens</li><li>max: 525 tokens</li></ul> | <ul><li>min: 101 tokens</li><li>mean: 132.43 tokens</li><li>max: 179 tokens</li></ul> | <ul><li>min: -1.0</li><li>mean: -0.7</li><li>max: 1.0</li></ul> |
- Samples: | patientsummarytrunc | thisspacetrunc | label | |:---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:----------------------------------| | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 6<br>Sex: Male<br>Cancer type: Kaposiform hemangioendothelioma of the right lower extremity<br>Histology: Spindle cell vascular neoplasm (CD31 positive, CD34 positive, ERG positive, HHV-8 negative)<br>Current extent: Localized; status post wide local excision on 2023-02-06 with negative margins<br>Biomarkers: PIK3CA p.E542K mutant; PTEN, AKT1, KRAS, and TP53 wild-type<br>Treatment history:<br># 2020-10-28 to 2021-04-04: vincristine; achieved partial response (tumor decreased from 7 cm to 5.2 cm)<br># 2021-11-29 to 2022-10-18: paclitaxel; achieved partial response (tumor decreased from 9 cm to 6.4 cm)<br># 2023-02-06: wide local excision of right calf mass; negative margins</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 14 years. Sex allowed: Male or Female. Cancer type allowed: Kaposiform hemangioendothelioma. Histology allowed: NA. Cancer burden allowed: NA. Prior treatment required: NA. Prior treatment excluded: sirolimus or other mTOR inhibitors. Biomarkers required: NA. Biomarkers excluded: NA.</code> | <code>-0.19999999999999996</code> | | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 14<br>Sex: Male<br>Cancer type: Kaposiform Hemangioendothelioma of the right lateral neck<br>Histology: Spindle cell proliferation with kaposiform architecture<br>Current extent: Stage T1N0M0; stable 3.1 cm mass in the right lateral neck as of 2021-02-08; platelets 228,000/uL as of 2020-12-12 (stable, no Kasabach-Merritt phenomenon)<br>Biomarkers: CD31 positive, CD34 positive, ERG positive, HHV-8 negative, GLUT1 negative/patchy, Ki-67 less than 5%, PIK3CA p.H1047R mutation, PTEN p.S167R mutation, STK11 wild-type, TSC1 wild-type<br>Treatment history:<br># 2018-11-21-2021-02-08: observation; stable disease</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 14 years. Sex allowed: Male or Female. Cancer type allowed: Kaposiform hemangioendothelioma. Histology allowed: NA. Cancer burden allowed: NA. Prior treatment required: NA. Prior treatment excluded: sirolimus or other mTOR inhibitors. Biomarkers required: NA. Biomarkers excluded: NA.</code> | <code>-0.19999999999999996</code> | | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age: 46<br>Sex: Female<br>Cancer type: Retroperitoneal cancer<br>Histology: Epithelioid Hemangioendothelioma<br>Current extent: Metastatic (retroperitoneal mass, liver metastases, and ascites); progressive disease as of 2018-04-09<br>Biomarkers: CD31 positive, ERG positive, CD34 patchy positive, Pan-Cytokeratin negative, S100 negative, HMB-45 negative, SMA negative, Ki-67 15%, WWTR1-YAP1 fusion, PIK3CA p.E545K mutation, RB1 hemizygous loss, STK11 p.T123M mutation<br>Treatment history:<br># 2014-11-12: retroperitoneal debulking surgery; achieved no evidence of disease as of 2015-07-11<br># 2016-04-10-2017-05-16: paclitaxel; best response partial response (30 percent reduction in tumor diameter)<br># 2017-05-16-2018-04-09: capecitabine; best response stable disease</code> | <code>Instruct: Given a cancer patient summary, retrieve clinical trial options that are reasonable for that patient; or, given a clinical trial option, retrieve cancer patients who are reasonable candidates for that trial. Age range allowed: 0 to 14 years. Sex allowed: Male or Female. Cancer type allowed: Kaposiform hemangioendothelioma. Histology allowed: NA. Cancer burden allowed: NA. Prior treatment required: NA. Prior treatment excluded: sirolimus or other mTOR inhibitors. Biomarkers required: NA. Biomarkers excluded: NA.</code> | <code>-1.0</code> |
- Loss: <code>CoSENTLoss</code> with these parameters:
{
"scale": 20.0,
"similarity_fct": "pairwise_cos_sim"
}Training Hyperparameters
Non-Default Hyperparameters
per_device_train_batch_size: 10learning_rate: 2e-05warmup_steps: 0.01bf16: True
All Hyperparameters
<details><summary>Click to expand</summary>
per_device_train_batch_size: 10num_train_epochs: 3max_steps: -1learning_rate: 2e-05lr_scheduler_type: linearlr_scheduler_kwargs: Nonewarmup_steps: 0.01optim: adamwtorchfusedoptim_args: Noneweight_decay: 0.0adam_beta1: 0.9adam_beta2: 0.999adam_epsilon: 1e-08optim_target_modules: Nonegradient_accumulation_steps: 1average_tokens_across_devices: Truemax_grad_norm: 1.0label_smoothing_factor: 0.0bf16: Truefp16: Falsebf16_full_eval: Falsefp16_full_eval: Falsetf32: Nonegradient_checkpointing: Falsegradient_checkpointing_kwargs: Nonetorch_compile: Falsetorch_compile_backend: Nonetorch_compile_mode: Noneuse_liger_kernel: Falseliger_kernel_config: Noneuse_cache: Falseneftune_noise_alpha: Nonetorch_empty_cache_steps: Noneauto_find_batch_size: Falselog_on_each_node: Truelogging_nan_inf_filter: Trueinclude_num_input_tokens_seen: nolog_level: passivelog_level_replica: warningdisable_tqdm: Falseproject: huggingfacetrackio_space_id: Nonetrackio_bucket_id: Nonetrackio_static_space_id: Noneper_device_eval_batch_size: 8prediction_loss_only: Trueeval_on_start: Falseeval_do_concat_batches: Trueeval_use_gather_object: Falseeval_accumulation_steps: Noneinclude_for_metrics: []batch_eval_metrics: Falsesave_only_model: Falsesave_on_each_node: Falseenable_jit_checkpoint: Falsepush_to_hub: Falsehub_private_repo: Nonehub_model_id: Nonehub_strategy: every_savehub_always_push: Falsehub_revision: Noneload_best_model_at_end: Falseignore_data_skip: Falserestore_callback_states_from_checkpoint: Falsefull_determinism: Falseseed: 42data_seed: Noneuse_cpu: Falseaccelerator_config: {'splitbatches': False, 'dispatchbatches': None, 'evenbatches': True, 'useseedablesampler': True, 'nonblocking': False, 'gradientaccumulationkwargs': None}parallelism_config: Nonedataloader_drop_last: Truedataloader_num_workers: 0dataloader_pin_memory: Truedataloader_persistent_workers: Falsedataloader_prefetch_factor: Noneremove_unused_columns: Truelabel_names: Nonetrain_sampling_strategy: randomlength_column_name: lengthddp_find_unused_parameters: Noneddp_bucket_cap_mb: Noneddp_broadcast_buffers: Falseddp_static_graph: Noneddp_backend: Noneddp_timeout: 1800fsdp: []fsdp_config: {'minnumparams': 0, 'xla': False, 'xlafsdpv2': False, 'xlafsdpgrad_ckpt': False}deepspeed: Nonedebug: []skip_memory_metrics: Truedo_predict: Falseresume_from_checkpoint: Nonewarmup_ratio: Nonelocal_rank: -1prompts: Nonebatch_sampler: batch_samplermulti_dataset_batch_sampler: proportionalrouter_mapping: {}learning_rate_mapping: {}
</details>
Training Logs
<details><summary>Click to expand</summary>
</details>
Training Time
- Training: 7.8 hours
Framework Versions
- Python: 3.13.13
- Sentence Transformers: 5.4.1
- Transformers: 5.8.0
- PyTorch: 2.11.0+cu130
- Accelerate: 1.13.0
- Datasets: 4.8.5
- Tokenizers: 0.22.2
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",
}MultipleNegativesRankingLoss
@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},
}CoSENTLoss
@article{10531646,
author={Huang, Xiang and Peng, Hao and Zou, Dongcheng and Liu, Zhiwei and Li, Jianxin and Liu, Kay and Wu, Jia and Su, Jianlin and Yu, Philip S.},
journal={IEEE/ACM Transactions on Audio, Speech, and Language Processing},
title={CoSENT: Consistent Sentence Embedding via Similarity Ranking},
year={2024},
doi={10.1109/TASLP.2024.3402087}
}<!--
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. -->
