LoRA fine-tune of Gemma 4 E4B for clinical trial eligibility pre-screening. Given a patient profile and a trial's eligibility criteria, the model returns a structured 5-field verdict used inside TrialMatch — a fully offline, CPU-only clinical trial matching app.
Model Details
Model Description
trialmatch-gemma4 is a LoRA adapter trained on top of unsloth/gemma-4-E4B-it-unsloth-bnb-4bit. It is fine-tuned for a single task: reading a structured patient profile + clinical reasoning summary + trial eligibility criteria text and returning a structured eligibility verdict.
The model outputs exactly five fields:
VERDICT: MATCH | PARTIAL | NO
CONFIDENCE: 0–100
REASON: one plain-English sentence
DISQUALIFIERS: exact criterion text, or NONE
NEXT STEP: what the patient should do next
Demo: TrialMatch runs fully offline — see the repo for setup instructions
Uses
Direct Use
Load the LoRA adapter on top of Gemma 4 E4B and pass a patient profile + eligibility criteria to get a structured MATCH/PARTIAL/NO verdict. See How to Get Started below.
Downstream Use
Integrated into TrialMatch as the eligibility matching step. The app extracts a 13-field patient profile from a PDF, searches a local trial database, and passes each trial through this model to produce verdicts displayed in the Gradio UI.
Out-of-Scope Use
Not a medical device. This model does not provide medical advice, diagnosis, or treatment decisions.
Not suitable for final enrollment decisions — it is a pre-screening tool only.
Not suitable for conditions or trial types not represented in the training data.
Bias, Risks, and Limitations
Training data was synthetically generated using Gemma 4 — the model may reflect biases in that generation process.
PARTIAL cases are the hardest to distinguish (both misclassifications in the benchmark were PARTIAL ground-truth labels).
The model has not been validated against real patient records or regulatory enrollment criteria.
Eligibility criteria text is truncated to 1500 characters — very long criteria sections may lose information.
Recommendations
Use exclusively as a pre-screening aid. Any positive result must be reviewed by a licensed physician before a patient contacts a trial site.
How to Get Started with the Model
python
1from peft import PeftModel
2from transformers import AutoTokenizer, AutoModelForCausalLM
34base_model = AutoModelForCausalLM.from_pretrained(5"unsloth/gemma-4-E4B-it-unsloth-bnb-4bit",6 load_in_4bit=True,7 device_map="auto",8)9tokenizer = AutoTokenizer.from_pretrained("boweiiismyname/trialmatch-gemma4")10model = PeftModel.from_pretrained(base_model,"boweiiismyname/trialmatch-gemma4")1112prompt ="""You are a clinical trial eligibility screener.
1314PATIENT PROFILE:
15{patient_profile}
1617CLINICAL REASONING:
18{clinical_reasoning}
1920ELIGIBILITY CRITERIA:
21{eligibility_criteria}
2223Return exactly:
24VERDICT: MATCH|PARTIAL|NO
25CONFIDENCE: 0-100
26REASON: one sentence
27DISQUALIFIERS: criterion text or NONE
28NEXT STEP: what to do next"""2930inputs = tokenizer(text=prompt.format(31 patient_profile="...",32 clinical_reasoning="...",33 eligibility_criteria="...",34), return_tensors="pt").to("cuda")3536outputs = model.generate(**inputs, max_new_tokens=120, do_sample=False)37print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Training Details
Training Data
120+ synthetic patient profiles generated by Gemma 4 for 60 real recruiting trials sourced from ClinicalTrials.gov. Each profile was run through the base TrialMatch matcher to produce a ground-truth label. Profiles were split roughly 50/50 MATCH-leaning and NO-leaning to prevent class imbalance. Stored as training_data.jsonl.
Training Procedure
Training Hyperparameters
Training regime: bf16 mixed precision (T4 GPU)
LoRA rank (r): 16
LoRA alpha: 16
Target modules: language layers only (finetune_vision_layers=False)
Epochs: 3
Batch size: 2 (effective 8 with gradient accumulation × 4)
Learning rate: 2e-4, linear schedule with 5 warmup steps
Optimizer: adamw_8bit
Max sequence length: 2048
Speeds, Sizes, Times
Hardware: Google Colab T4 GPU (free tier)
Training time: ~1.5 hours
Adapter size: ~50 MB (LoRA weights only)
Evaluation
Testing Data
20 held-out examples from training_data.jsonl, sampled with random.seed(99) (different from training split).
Metrics
Exact-match accuracy on VERDICT field (MATCH / PARTIAL / NO). Confidence score is model-reported (0–100).
Results
Metric
Fine-tuned Gemma 4 E4B
Accuracy
90.0% (18 / 20)
Avg confidence score
96.5 / 100
Correct MATCH verdicts
3 / 3 (100%)
Avg response time (T4 GPU)
25.9s / example
Both misclassifications were PARTIAL ground-truth — the most ambiguous category. All 3 true MATCH cases were correctly identified, which is the critical metric for a pre-screening tool (missing a match costs a patient trial access).
Environmental Impact
Hardware: NVIDIA T4 (Google Colab)
Hours used: ~1.5 hours
Cloud Provider: Google
Compute Region: us-central1
Technical Specifications
Model Architecture
LoRA adapters (r=16) applied to language attention and MLP layers of Gemma 4 E4B. Vision layers are frozen — the adapter is text-only. Base model loaded in 4-bit NF4 quantisation via bitsandbytes.