Izziemirg commited on
Commit
4c06e10
·
verified ·
1 Parent(s): 6778ab7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +158 -0
README.md CHANGED
@@ -1,3 +1,161 @@
1
  ---
2
  license: mit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: mit
3
+ language:
4
+ - en
5
+ metrics:
6
+ - f1
7
+ - accuracy
8
+ - roc_auc
9
+ base_model:
10
+ - microsoft/deberta-v3-base
11
+ pipeline_tag: text-classification
12
+ tags:
13
+ - medical
14
+ - pharmacovigilance
15
+ - clinical-nlp
16
+ - drug-safety
17
+ - adverse-drug-reactions
18
+ - deberta
19
+ - classification
20
+ datasets:
21
+ - custom
22
+ model-index:
23
+ - name: MedSentinel ADR Severity Classifier
24
+ results:
25
+ - task:
26
+ type: text-classification
27
+ name: ADR Severity Classification
28
+ metrics:
29
+ - type: f1
30
+ value: 0.9272
31
+ name: Accuracy (Kaggle)
32
+ - type: accuracy
33
+ value: 0.9440
34
+ name: Accuracy (Test set)
35
  ---
36
+
37
+ # MedSentinel — ADR Severity Classifier
38
+
39
+ **MedSentinel** is a fine-tuned [DeBERTa-v3-Base](https://huggingface.co/microsoft/deberta-v3-base)
40
+ model for classifying the severity of Adverse Drug Reactions (ADRs) from patient-reported
41
+ narrative text. It is the core AI component of the MedSentinel ADR Intelligence Platform,
42
+ designed to assist clinical practitioners in triaging pharmacovigilance signals.
43
+
44
+ ## Model Details
45
+
46
+ | Property | Value |
47
+ |---|---|
48
+ | **Base model** | microsoft/deberta-v3-base |
49
+ | **Architecture** | DeBERTa-v3 (12 layers, 768 hidden, ~86M params) |
50
+ | **Task** | Binary text classification (Severe / Non-Severe) |
51
+ | **Training strategy** | 5-fold stratified cross-validation ensemble |
52
+ | **Kaggle score** | 0.92720 (ensemble) · 0.91544 (single model) |
53
+ | **Tokenizer** | SentencePiece (max length 256) |
54
+
55
+ ## Intended Use
56
+
57
+ This model is intended for **research and clinical decision support** in the context of
58
+ pharmacovigilance. It classifies free-text patient ADR reports as either severe or
59
+ non-severe to help clinicians prioritize signals requiring immediate attention.
60
+
61
+ **Intended users:** Clinical practitioners, pharmacovigilance researchers, healthcare data scientists.
62
+
63
+ **Out-of-scope uses:** This model should not be used as a sole basis for clinical decisions.
64
+ It is a decision-support tool and should always be reviewed by a qualified healthcare professional.
65
+
66
+ ## Training Data
67
+
68
+ The model was trained on a dataset of **8,153 patient-reported drug experience narratives**
69
+ sourced from drug review platforms. Labels indicate ADR severity:
70
+
71
+ - `0` — Non-severe adverse drug reaction
72
+ - `1` — Severe adverse drug reaction
73
+
74
+ **Class distribution:** 53.4% severe · 46.6% non-severe (near-balanced)
75
+
76
+ ## Training Configuration
77
+
78
+ ```python
79
+ # Key hyperparameters
80
+ learning_rate = 2e-5
81
+ optimizer = "adafactor"
82
+ batch_size = 16 # effective 64 with gradient accumulation
83
+ gradient_accumulation = 4
84
+ epochs = 8 # with early stopping (patience=3)
85
+ warmup_ratio = 0.1
86
+ lr_scheduler = "cosine"
87
+ weight_decay = 0.01
88
+ max_seq_length = 256
89
+ fp16 = False # DeBERTa-v3 incompatibility
90
+ cv_folds = 5
91
+ ```
92
+
93
+ ## Evaluation Results
94
+
95
+ | Metric | Score |
96
+ |---|---|
97
+ | **Kaggle F1 (ensemble)** | **0.92720** |
98
+ | Kaggle F1 (single model) | 0.91544 |
99
+ | Validation F1 (macro) | 0.9050 |
100
+ | Validation accuracy | 94.4% |
101
+
102
+ ## How to Use
103
+
104
+ ```python
105
+ from transformers import AutoTokenizer, AutoModelForSequenceClassification
106
+ import torch
107
+ from scipy.special import softmax
108
+
109
+ model_id = "Izziemirg/medsentinel-adr-deberta"
110
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
111
+ model = AutoModelForSequenceClassification.from_pretrained(model_id)
112
+ model.eval()
113
+
114
+ def classify_adr(text):
115
+ inputs = tokenizer(
116
+ text,
117
+ return_tensors="pt",
118
+ truncation=True,
119
+ max_length=256,
120
+ padding=True
121
+ )
122
+ with torch.no_grad():
123
+ logits = model(**inputs).logits.numpy()
124
+
125
+ probs = softmax(logits, axis=-1)[0]
126
+ label = "Severe" if probs[1] > 0.5 else "Non-Severe"
127
+ return {"label": label, "confidence": round(float(probs.max()), 4)}
128
+
129
+ # Example
130
+ text = "I experienced severe insomnia, heart palpitations, and extreme anxiety
131
+ after taking this medication for two weeks."
132
+ print(classify_adr(text))
133
+ # {'label': 'Severe', 'confidence': 0.9731}
134
+ ```
135
+
136
+ ## Limitations
137
+
138
+ - Trained on English-language patient-reported text only
139
+ - Performance may degrade on formal clinical notes (different register than training data)
140
+ - Mixed-sentiment texts (severe symptoms but positive drug efficacy) remain a known
141
+ edge case — the model may under-predict severity in these cases
142
+ - Not validated on real-world clinical deployment data
143
+
144
+ ## Citation
145
+
146
+ If you use this model in your research, please cite:
147
+
148
+ ```bibtex
149
+ @misc{mirghani2025medsentinel,
150
+ title = {MedSentinel: ADR Severity Classification with DeBERTa-v3},
151
+ author = {Mirghani, Izzie},
152
+ year = {2026},
153
+ howpublished = {HuggingFace Hub},
154
+ url = {https://huggingface.co/Izziemirg/medsentinel-adr-deberta}
155
+ }
156
+ ```
157
+
158
+ ## Developed By
159
+
160
+ **Izzie Mirghani** MS Business Analytics, UVA Darden
161
+ Part of the **MedSentinel ADR Intelligence Platform** project.