A
QLoRA-fine-tuned
Qwen2.5-7B-Instruct
specialised for clinical-trial tasks, trained on ~26k instruction examples derived from the
ClinicalTrials.gov registry.
The base model scores 0.000 on phase classification not because it lacks the knowledge, but because
it won't answer in the required format — fine-tuning buys format discipline and faithfulness.
1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4MODEL_ID = "OmkarShewale/clintrial-qwen2.5-7b-sft"
5tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
6model = AutoModelForCausalLM.from_pretrained(MODEL_ID, dtype=torch.bfloat16, device_map="auto")
7
8SYSTEM = (
9 "You are a clinical research assistant. You help patients and clinicians understand "
10 "clinical trials. Answer only from the information provided, be precise, and never "
11 "invent eligibility criteria, conditions, or outcomes."
12)
13
14criteria = """Inclusion Criteria:
151. Adults aged 18 years or older with confirmed type 2 diabetes
162. HbA1c between 7.0% and 10.5% at screening
17
18Exclusion Criteria:
191. History of severe hypoglycaemia within the last 6 months
202. Pregnancy or breastfeeding
21"""
22
23messages = [
24 {"role": "system", "content": SYSTEM},
25 {"role": "user", "content":
26 'Extract the eligibility criteria from the trial text below into JSON with two lists, '
27 '"inclusion" and "exclusion". Copy each criterion verbatim; do not add any.\n\n'
28 f"Trial eligibility text:\n{criteria}"},
29]
30
31enc = tokenizer.apply_chat_template(messages, add_generation_prompt=True,
32 return_tensors="pt", return_dict=True).to(model.device)
33out = model.generate(**enc, max_new_tokens=1024, do_sample=False)
34print(tokenizer.decode(out[0, enc["input_ids"].shape[1]:], skip_special_tokens=True))
A
GRPO / RLVR variant (RL against a programmatic reward: JSON validity + criterion F1) was also
trained; it matched this SFT model but did not beat it, because SFT had already saturated the reward.
Details in the
repo.
Built from 8,000 real ClinicalTrials.gov studies. Targets come from the registry's own structured
fields (not a teacher LLM), so labels are auditable. Splits are partitioned by trial, not by
example, to prevent leakage.
Apache-2.0, inherited from Qwen2.5. Source registry data is public-domain U.S. government work.