Views
No views yet
1{
2 "symptoms": ["chest discomfort", "fatigue"],
3 "duration": ["few days", "unspecified"],
4 "severity": ["unspecified", "mild"],
5 "urgent": true
6}1{
2 "symptoms": ["diarrhea", "fatigue"],
3 "duration": ["since yesterday", "unspecified"],
4 "severity": ["unspecified", "mild"],
5 "urgent": false
6}| Metric | Score |
|---|---|
| Valid JSON rate | 100% |
| Symptom F1 | 0.781 |
| Urgent Accuracy | 85.7% |
| Model | Method | F1 | Urgent Acc |
|---|---|---|---|
| Gemma-3-1B | LoRA | 0.781 | 85.7% |
| Gemma-3-1B | QLoRA | 0.740 | 82.9% |
| LLaMA-3.2-1B | LoRA | 0.743 | 74.3% |
| LLaMA-3.2-1B | QLoRA | 0.767 | 74.3% |
| Qwen1.5-1.8B | LoRA | 0.707 | 74.3% |
| Qwen1.5-1.8B | QLoRA | 0.696 | 87.9% |
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "YOUR_HF_USERNAME/ClinicalDistill-Gemma-1B"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=torch.bfloat16,
10 device_map="auto"
11)
12
13def extract_clinical(text):
14 prompt = f"""<instruction>
15Extract symptoms from the clinical note below. Reply with ONLY valid JSON.
16Format: {{"symptoms": ["s1"], "duration": ["d1"], "severity": ["sev1"], "urgent": true/false}}
17Use "unspecified" if unknown. urgent=true only for chest pain, breathing difficulty, stroke, severe bleeding.
18</instruction>
19<input>{text}</input>
20<o>"""
21
22 inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
23 with torch.no_grad():
24 outputs = model.generate(
25 **inputs,
26 max_new_tokens=200,
27 temperature=0.1,
28 do_sample=True,
29 pad_token_id=tokenizer.eos_token_id
30 )
31 response = tokenizer.decode(outputs[0], skip_special_tokens=True)
32 return response.split("<o>")[-1].replace("</o>", "").strip()
33
34print(extract_clinical("Patient has chest pain for 3 days and mild fever"))1@misc{shastri2026clinicaldistill,
2 title={Benchmarking Small LLMs for Clinical Symptom Extraction
3 on Resource-Constrained Compute},
4 author={Shastri, Janushi},
5 year={2026}
6}