TrialSpace-1226
TrialSpace-1226 embeds cancer patient histories and clinical trial cohorts into one vector space, so that patients can be matched to trial cohorts (and cohorts to patients) by cosine similarity. It is the retrieval model of the MatchMiner-AI 1226 release (collection), fine-tuned from google/embeddinggemma-2 on synthetic data only.
Research use only. Similarity scores are screening signals for review by clinicians and trial teams, not eligibility determinations, diagnoses or treatment recommendations.
Model
- Base: google/embeddinggemma-2 (Apache-2.0); see
NOTICE.md. - Output: 768-dimensional, L2-normalized embeddings; compare with cosine similarity.
- Inputs: a patient's cancer history summary, or a trial cohort's key eligibility criteria (the criteria that define its population, without common boilerplate exclusions).
- Length: trained on inputs of up to 4,096 tokens.
- Requires: sentence-transformers 6.1 or later.
Prompts: always use them
TrialSpace-1226 was trained with one instruction prompt for each side, and is only reliable when patients and cohorts are encoded with the prompt of their side. The prompts are saved with the model, so select them by name:
| Encode | prompt_name | Input text | Prefix the model adds |
|---|---|---|---|
| Patients | patient_summary | The patient's cancer history summary | task: sentence similarity | query: Find potentially eligible patient–cohort matches, prioritizing matching cancer type, disease burden, prior treatment, and required biomarkers. + blank line + Patient history: + newline |
| Cohorts | this_space | The cohort's key eligibility criteria | the same instruction + blank line + Cohort eligibility criteria: + newline |
patients = model.encode(patient_summaries, prompt_name="patient_summary")
cohorts = model.encode(cohort_key_criteria, prompt_name="this_space")
- Without a
prompt_name, sentence-transformers applies the default prompt (SentenceSimilarity: the instruction alone, with no "Patient history:" or "Cohort eligibility criteria:" heading). That is not how TrialSpace-1226 was trained, and it gives different vectors. Always passprompt_name. - With another library, prepend the exact prefix yourself; the strings are in
config_sentence_transformers.jsonunderprompts. The model applies mean pooling and L2 normalization. - Both sides need their own prompt, in either matching direction: patients always take
patient_summaryand cohorts always takethis_space, whether you search for trials for a patient or for patients for a cohort. - The
matchminer_aipackage applies both prompts itself (embed_for_matching).
Training
Fine-tuned with sentence-transformers on ksg-dfci/mmai-synthetic-1226:
- Trials: 5,000 interventional cancer treatment trials from ClinicalTrials.gov (first posted since 2020), each with a synthetic protocol and the cohorts extracted from it.
- Patients: 87,890 synthetic patients, each generated as eligible (positive) or ineligible (negative) for one of those cohorts, with longitudinal synthetic notes and serial summaries.
- Mining and labels: patients and cohorts were mined for candidate pairs in rounds, and a teacher LLM (NVIDIA Nemotron 3.5 Super) scored each candidate pair from 0 to 6.
- Fits: the model was fit on the labeled pairs after the first and second rounds; this is the second fit.
No real patient data were used in training.
Use
from huggingface_hub import snapshot_download
from sentence_transformers import SentenceTransformer
path = snapshot_download("ksg-dfci/TrialSpace-1226")
model = SentenceTransformer(path)
patients = model.encode(["Age: 64\nSex: Female\nCancer type: Lung cancer\nBiomarkers: EGFR exon 19 deletion\n..."],
prompt_name="patient_summary")
cohorts = model.encode(["Inclusion criteria:\nMetastatic EGFR-mutant non-small cell lung cancer\n..."],
prompt_name="this_space")
print(model.similarity(patients, cohorts))
With the matchminer_ai package, set embedding.model_path to the downloaded folder; embed_for_matching and
generate_candidate_matches then embed and retrieve in either direction. Never mix vectors from different
TrialSpace versions: re-embed every stored patient and cohort when changing models.
Limitations
- Trained on synthetic patients and trial text. Performance at a given institution, on its notes and protocols, needs local evaluation; no evaluation results are published with this release.
- Retrieval uses the patient's cancer history and the cohort's key criteria only. Boilerplate exclusions and per-criterion eligibility are checked by other models (see MatchEval-1226).
License
CC BY-NC-ND 4.0 (LICENSE.md), with the base model's Apache-2.0 notice (NOTICE.md, LICENSE-APACHE-2.0.txt).