Kumud2k16 commited on
Commit
7316d61
·
verified ·
1 Parent(s): 1254908

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +169 -142
README.md CHANGED
@@ -1,199 +1,226 @@
1
  ---
2
- library_name: transformers
3
- tags: []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  ---
5
 
6
- # Model Card for Model ID
7
 
8
- <!-- Provide a quick summary of what the model is/does. -->
9
 
 
10
 
 
11
 
12
- ## Model Details
 
 
 
 
 
13
 
14
- ### Model Description
15
 
16
- <!-- Provide a longer summary of what this model is. -->
17
-
18
- This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
19
-
20
- - **Developed by:** [More Information Needed]
21
- - **Funded by [optional]:** [More Information Needed]
22
- - **Shared by [optional]:** [More Information Needed]
23
- - **Model type:** [More Information Needed]
24
- - **Language(s) (NLP):** [More Information Needed]
25
- - **License:** [More Information Needed]
26
- - **Finetuned from model [optional]:** [More Information Needed]
27
-
28
- ### Model Sources [optional]
29
-
30
- <!-- Provide the basic links for the model. -->
31
-
32
- - **Repository:** [More Information Needed]
33
- - **Paper [optional]:** [More Information Needed]
34
- - **Demo [optional]:** [More Information Needed]
35
-
36
- ## Uses
37
-
38
- <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
39
-
40
- ### Direct Use
41
-
42
- <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
43
-
44
- [More Information Needed]
45
-
46
- ### Downstream Use [optional]
47
-
48
- <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
49
-
50
- [More Information Needed]
51
 
52
  ### Out-of-Scope Use
 
53
 
54
- <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
55
-
56
- [More Information Needed]
57
-
58
- ## Bias, Risks, and Limitations
59
-
60
- <!-- This section is meant to convey both technical and sociotechnical limitations. -->
61
-
62
- [More Information Needed]
63
-
64
- ### Recommendations
65
-
66
- <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
67
-
68
- Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
69
-
70
- ## How to Get Started with the Model
71
-
72
- Use the code below to get started with the model.
73
-
74
- [More Information Needed]
75
-
76
- ## Training Details
77
-
78
- ### Training Data
79
-
80
- <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
81
-
82
- [More Information Needed]
83
-
84
- ### Training Procedure
85
-
86
- <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
87
-
88
- #### Preprocessing [optional]
89
-
90
- [More Information Needed]
91
-
92
-
93
- #### Training Hyperparameters
94
-
95
- - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
96
-
97
- #### Speeds, Sizes, Times [optional]
98
-
99
- <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
100
-
101
- [More Information Needed]
102
-
103
- ## Evaluation
104
-
105
- <!-- This section describes the evaluation protocols and provides the results. -->
106
-
107
- ### Testing Data, Factors & Metrics
108
 
109
- #### Testing Data
 
 
 
 
 
 
 
110
 
111
- <!-- This should link to a Dataset Card if possible. -->
 
 
 
 
112
 
113
- [More Information Needed]
114
 
115
- #### Factors
116
 
117
- <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
119
- [More Information Needed]
 
 
 
120
 
121
- #### Metrics
 
122
 
123
- <!-- These are the evaluation metrics being used, ideally with a description of why. -->
124
 
125
- [More Information Needed]
126
 
127
- ### Results
 
 
 
 
128
 
129
- [More Information Needed]
130
 
131
- #### Summary
132
 
 
133
 
 
 
134
 
135
- ## Model Examination [optional]
 
136
 
137
- <!-- Relevant interpretability work for the model goes here -->
138
 
139
- [More Information Needed]
 
 
140
 
141
- ## Environmental Impact
 
 
142
 
143
- <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
144
 
145
- Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
146
 
147
- - **Hardware Type:** [More Information Needed]
148
- - **Hours used:** [More Information Needed]
149
- - **Cloud Provider:** [More Information Needed]
150
- - **Compute Region:** [More Information Needed]
151
- - **Carbon Emitted:** [More Information Needed]
152
 
153
- ## Technical Specifications [optional]
 
 
 
154
 
155
- ### Model Architecture and Objective
156
 
157
- [More Information Needed]
158
 
159
- ### Compute Infrastructure
160
 
161
- [More Information Needed]
162
 
163
- #### Hardware
164
 
165
- [More Information Needed]
166
 
167
- #### Software
168
 
169
- [More Information Needed]
170
 
171
- ## Citation [optional]
172
 
173
- <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
174
 
175
- **BibTeX:**
176
 
177
- [More Information Needed]
 
 
 
 
 
178
 
179
- **APA:**
180
 
181
- [More Information Needed]
 
182
 
183
- ## Glossary [optional]
 
 
 
 
 
 
184
 
185
- <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
186
 
187
- [More Information Needed]
188
 
189
- ## More Information [optional]
190
 
191
- [More Information Needed]
 
 
 
 
 
 
 
192
 
193
- ## Model Card Authors [optional]
194
 
195
- [More Information Needed]
 
 
 
 
 
 
 
 
 
 
196
 
197
- ## Model Card Contact
198
 
199
- [More Information Needed]
 
 
 
 
1
  ---
2
+ language: en
3
+ license: mit
4
+ tags:
5
+ - summarization
6
+ - radiology
7
+ - medical
8
+ - bart
9
+ - healthcare
10
+ datasets:
11
+ - openi
12
+ metrics:
13
+ - rouge
14
+ model-index:
15
+ - name: radiology-expression-summarizer
16
+ results:
17
+ - task:
18
+ type: summarization
19
+ name: Radiology Report Summarization
20
+ metrics:
21
+ - type: rouge
22
+ value: 0.5174
23
+ name: ROUGE-1 F1
24
+ - type: rouge
25
+ value: 0.3881
26
+ name: ROUGE-2 F1
27
+ - type: rouge
28
+ value: 0.5092
29
+ name: ROUGE-L F1
30
  ---
31
 
32
+ # Radiology Expression Summarizer
33
 
34
+ A fine-tuned BART-base model that generates the IMPRESSION section of chest X-ray radiology reports from the FINDINGS section. Built as a portfolio project to demonstrate end-to-end NLP pipeline development, from data preparation through model training to live deployment.
35
 
36
+ ## Model Description
37
 
38
+ This model takes detailed radiological FINDINGS as input and produces a concise IMPRESSION summary, mimicking the workflow that radiologists follow when writing clinical reports. The IMPRESSION is the most important section of a radiology report — it summarizes the key clinical findings and is what physicians refer to most often.
39
 
40
+ - **Developed by:** Kumud Shorey
41
+ - **Model type:** Sequence-to-Sequence (Encoder-Decoder Transformer)
42
+ - **Language:** English
43
+ - **Base model:** [facebook/bart-base](https://huggingface.co/facebook/bart-base)
44
+ - **Fine-tuned for:** Medical text summarization
45
+ - **Live API:** [https://radiology-expression-summarizer.onrender.com](https://radiology-expression-summarizer.onrender.com)
46
 
47
+ ## Intended Use
48
 
49
+ ### Primary Use Cases
50
+ - Automated drafting of preliminary IMPRESSION sections from FINDINGS
51
+ - Research and educational demonstrations of medical NLP
52
+ - Baseline model for further fine-tuning on domain-specific data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  ### Out-of-Scope Use
55
+ **⚠️ This model is NOT intended for clinical use.** It has not been validated by medical professionals, is not approved by any regulatory body (FDA, CE, etc.), and should never be used to make medical decisions. All output should be reviewed by qualified radiologists.
56
 
57
+ ## Training Data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
 
59
+ - **Source:** Open-i NLMCXR dataset (Indiana University Chest X-ray Collection)
60
+ - **Original size:** 3,955 XML files
61
+ - **After cleaning:** 2,712 examples (removed missing values and duplicates)
62
+ - **Splits:**
63
+ - Train: 1,952 examples (72%)
64
+ - Validation: 217 examples (8%)
65
+ - Test: 543 examples (20%)
66
+ - **No data leakage:** Verified that no examples appear in multiple splits
67
 
68
+ ### Data Preprocessing
69
+ 1. XML files parsed to extract FINDINGS and IMPRESSION sections
70
+ 2. Removed examples with missing FINDINGS or IMPRESSION
71
+ 3. Removed duplicate examples
72
+ 4. Stratified random split with seed=42 for reproducibility
73
 
74
+ ## Training Procedure
75
 
76
+ ### Hyperparameters
77
 
78
+ | Parameter | Value |
79
+ |-----------|-------|
80
+ | Base model | facebook/bart-base |
81
+ | Number of parameters | 139M |
82
+ | Number of epochs | 5 |
83
+ | Per-device batch size | 4 |
84
+ | Gradient accumulation steps | 4 |
85
+ | Effective batch size | 16 |
86
+ | Learning rate | 3e-5 |
87
+ | Warmup steps | 100 |
88
+ | Weight decay | 0.01 |
89
+ | Mixed precision | FP16 (when GPU available) |
90
+ | Max source length | 512 tokens |
91
+ | Max target length | 128 tokens |
92
+ | Generation beams | 4 |
93
+ | Random seed | 42 |
94
 
95
+ ### Training Framework
96
+ - **Library:** Hugging Face Transformers
97
+ - **Trainer:** `Seq2SeqTrainer`
98
+ - **Hardware:** CPU (training); GPU recommended for production
99
 
100
+ ### Model Selection
101
+ The best checkpoint was selected based on highest ROUGE-1 F1 score on the validation set using `load_best_model_at_end=True`.
102
 
103
+ ## Evaluation Results
104
 
105
+ Evaluated on the held-out test set (543 examples):
106
 
107
+ | Metric | F1 Score |
108
+ |--------|----------|
109
+ | ROUGE-1 | **0.5174** |
110
+ | ROUGE-2 | **0.3881** |
111
+ | ROUGE-L | **0.5092** |
112
 
113
+ These scores exceed the project requirement of ROUGE-1 ≥ 0.3 by 72%.
114
 
115
+ ## How to Use
116
 
117
+ ### Quick Start
118
 
119
+ ```python
120
+ from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
121
 
122
+ tokenizer = AutoTokenizer.from_pretrained("Kumud2k16/radiology-expression-summarizer")
123
+ model = AutoModelForSeq2SeqLM.from_pretrained("Kumud2k16/radiology-expression-summarizer")
124
 
125
+ findings = "The lungs are clear bilaterally. Heart size is normal. No pleural effusion or pneumothorax."
126
 
127
+ inputs = tokenizer(findings, return_tensors="pt", max_length=512, truncation=True)
128
+ outputs = model.generate(**inputs, max_length=128, num_beams=4)
129
+ impression = tokenizer.decode(outputs[0], skip_special_tokens=True)
130
 
131
+ print(impression)
132
+ # Expected output: "No acute cardiopulmonary abnormalities."
133
+ ```
134
 
135
+ ### Live API
136
 
137
+ The model is deployed as a REST API on Render:
138
 
139
+ ```bash
140
+ curl -X POST https://radiology-expression-summarizer.onrender.com/summarize \
141
+ -H "Content-Type: application/json" \
142
+ -d '{"findings": "The lungs are clear bilaterally. Heart size is normal."}'
143
+ ```
144
 
145
+ Response:
146
+ ```json
147
+ {"impression": "No acute cardiopulmonary abnormalities."}
148
+ ```
149
 
150
+ **Note:** The free-tier deployment may take ~50 seconds to wake up after periods of inactivity (cold start).
151
 
152
+ ## Limitations and Recommendations
153
 
154
+ ### Known Limitations
155
 
156
+ 1. **Dataset bias:** Trained on a single institution's data (Indiana University). May not generalize to reports from other institutions with different writing styles or terminology conventions.
157
 
158
+ 2. **Hallucination risk:** Like all generative models, may occasionally produce plausible-sounding but incorrect medical content. All output must be reviewed by qualified clinicians.
159
 
160
+ 3. **Domain narrow:** Trained only on chest X-ray reports. Performance on other modalities (CT, MRI, ultrasound) or other anatomical regions is untested.
161
 
162
+ 4. **English only:** Cannot handle reports in other languages.
163
 
164
+ 5. **No clinical validation:** Has not been evaluated against clinical correctness metrics (e.g., CheXbert F1). ROUGE measures n-gram overlap, not factual accuracy.
165
 
166
+ 6. **Small training set:** Only 1,952 training examples. A larger dataset would likely improve performance.
167
 
168
+ 7. **Free-tier deployment:** The live API uses Render's free tier, which causes cold starts (~50 second initial response time after inactivity).
169
 
170
+ ### Recommendations for Future Work
171
 
172
+ - Fine-tune on **BioBART** or **BioGPT** instead of BART-base for better baseline medical understanding
173
+ - Evaluate using domain-specific metrics like **CheXbert F1** to measure clinical correctness
174
+ - Expand training data with reports from multiple institutions
175
+ - Add safety guardrails to detect uncertain predictions
176
+ - Conduct clinical validation studies before any real-world use
177
+ - Deploy on production infrastructure (GPU, no cold starts) for clinical-grade latency
178
 
179
+ ## Reproducibility
180
 
181
+ Full source code, training scripts, and evaluation code are available at:
182
+ **[GitHub Repository](https://github.com/Kumud2k16/radiology-expression-summarizer)**
183
 
184
+ The codebase includes:
185
+ - Data parsing and cleaning scripts
186
+ - Tokenization pipeline
187
+ - Training script with full hyperparameter logging
188
+ - Evaluation script with ROUGE computation
189
+ - FastAPI deployment code
190
+ - Dockerfile for containerized deployment
191
 
192
+ All random seeds are set to 42 for reproducibility.
193
 
194
+ ## Citation
195
 
196
+ If you use this model, please cite the original BART paper:
197
 
198
+ ```bibtex
199
+ @article{lewis2019bart,
200
+ title={BART: Denoising Sequence-to-Sequence Pre-training for Natural Language Generation, Translation, and Comprehension},
201
+ author={Lewis, Mike and Liu, Yinhan and Goyal, Naman and Ghazvininejad, Marjan and Mohamed, Abdelrahman and Levy, Omer and Stoyanov, Ves and Zettlemoyer, Luke},
202
+ journal={arXiv preprint arXiv:1910.13461},
203
+ year={2019}
204
+ }
205
+ ```
206
 
207
+ And the Open-i dataset:
208
 
209
+ ```bibtex
210
+ @article{demner2016preparing,
211
+ title={Preparing a collection of radiology examinations for distribution and retrieval},
212
+ author={Demner-Fushman, Dina and Kohli, Marc D and Rosenman, Marc B and Shooshan, Sonya E and Rodriguez, Laritza and Antani, Sameer and Thoma, George R and McDonald, Clement J},
213
+ journal={Journal of the American Medical Informatics Association},
214
+ volume={23},
215
+ number={2},
216
+ pages={304--310},
217
+ year={2016}
218
+ }
219
+ ```
220
 
221
+ ## Author
222
 
223
+ **Kumud Shorey**
224
+ Project completed as part of IT Career Switch training program.
225
+ GitHub: [@Kumud2k16](https://github.com/Kumud2k16)
226
+ Hugging Face: [@Kumud2k16](https://huggingface.co/Kumud2k16)