sank29mane commited on
Commit
3ec439f
Β·
verified Β·
1 Parent(s): 89a052c

Update model description with comprehensive details from GitHub research project

Browse files
Files changed (1) hide show
  1. README.md +254 -189
README.md CHANGED
@@ -1,204 +1,269 @@
1
  ---
2
  library_name: peft
3
  base_model: microsoft/phi-2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
-
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]
200
 
 
201
 
202
- ### Framework versions
 
 
 
203
 
204
- - PEFT 0.7.2.dev0
 
1
  ---
2
  library_name: peft
3
  base_model: microsoft/phi-2
4
+ tags:
5
+ - biomedical
6
+ - summarization
7
+ - lay-summary
8
+ - healthcare
9
+ - nlp
10
+ - fine-tuned
11
+ - lora
12
+ - peft
13
+ - elife
14
+ - plos
15
+ - medical-text
16
+ language:
17
+ - en
18
+ license: mit
19
+ metrics:
20
+ - rouge
21
+ - bertscore
22
+ - readability
23
+ datasets:
24
+ - elife
25
+ - plos
26
+ pipeline_tag: text2text-generation
27
  ---
28
 
29
+ # Phi-2 BioLaySum: Biomedical Lay Summarization Model πŸ†
30
+
31
+ ## πŸ“– Model Overview
32
+
33
+ **Phi-2 BioLaySum** is a **champion model** that emerged as the most efficient and highest-performing solution for generating lay summaries of biomedical articles. This model converts complex medical research into easily understandable summaries for the general public, significantly enhancing accessibility to scientific literature.
34
+
35
+ **πŸ₯‡ Key Achievement**: This model **outperformed** T5-Base, T5-Large, FlanT5-Base, BioGPT, and Falconsi-Medical_summarisation across all evaluation dimensions (relevance, readability, and factuality) while maintaining optimal computational efficiency.
36
+
37
+ ## 🎯 Model Purpose
38
+
39
+ This model addresses the critical need to bridge the gap between complex biomedical research and public health literacy by:
40
+ - Converting medical articles into patient-friendly summaries
41
+ - Supporting healthcare communication between professionals and patients
42
+ - Enhancing public access to biomedical research findings
43
+ - Enabling better-informed health decisions by the general public
44
+
45
+ ## πŸ—οΈ Model Architecture
46
+
47
+ - **Base Model**: microsoft/phi-2
48
+ - **Fine-tuning Technique**: LoRA (Low-Rank Adaptation) + PEFT (Parameter Efficient Fine-tuning)
49
+ - **Model Type**: Text-to-Text Generation (Summarization)
50
+ - **Language**: English
51
+ - **Domain**: Biomedical/Healthcare
52
+
53
+ ## πŸ“Š Performance Highlights
54
+
55
+ ### Why Phi-2 is the Champion Model:
56
+ - βœ… **Superior Performance**: Best scores across relevance, readability, and factuality metrics
57
+ - βœ… **Resource Efficiency**: Optimal performance-to-resource ratio
58
+ - βœ… **Compact Size**: Most efficient in terms of model size and computational requirements
59
+ - βœ… **Cost-Effective**: Best balance of quality and computational cost
60
+
61
+ ### Evaluation Results:
62
+ - **Relevance**: Measured using ROUGE (1, 2, L) and BERTScore
63
+ - **Readability**: Assessed via Flesch-Kincaid Grade Level (FKGL) and Dale-Chall Readability Score (DCRS)
64
+ - **Factuality**: Verified using BARTScore and factual consistency checks
65
+
66
+ ## πŸš€ Quick Start
67
+
68
+ ### Loading the Model
69
+
70
+ ```python
71
+ from peft import PeftModel, PeftConfig
72
+ from transformers import AutoModelForCausalLM, AutoTokenizer
73
+ import torch
74
+
75
+ # Load the base model and tokenizer
76
+ base_model_name = "microsoft/phi-2"
77
+ model = AutoModelForCausalLM.from_pretrained(
78
+ base_model_name,
79
+ torch_dtype=torch.float16,
80
+ device_map="auto"
81
+ )
82
+ tokenizer = AutoTokenizer.from_pretrained(base_model_name)
83
+
84
+ # Load the fine-tuned adapter
85
+ model = PeftModel.from_pretrained(model, "sank29mane/phi-2-biolaysum")
86
+
87
+ # Set padding token
88
+ if tokenizer.pad_token is None:
89
+ tokenizer.pad_token = tokenizer.eos_token
90
+ ```
91
+
92
+ ### Generating Lay Summaries
93
+
94
+ ```python
95
+ def generate_lay_summary(medical_text, max_length=150):
96
+ # Prepare input
97
+ prompt = f"Summarize the following medical text for a general audience: {medical_text}"
98
+ inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=512)
99
+
100
+ # Generate summary
101
+ with torch.no_grad():
102
+ outputs = model.generate(
103
+ **inputs,
104
+ max_length=max_length,
105
+ temperature=0.7,
106
+ do_sample=True,
107
+ pad_token_id=tokenizer.eos_token_id
108
+ )
109
+
110
+ # Decode and return
111
+ summary = tokenizer.decode(outputs[0], skip_special_tokens=True)
112
+ return summary.split(":")[-1].strip() # Extract generated part
113
+
114
+ # Example usage
115
+ medical_text = """
116
+ The study investigated the efficacy of novel therapeutic interventions
117
+ in cardiovascular disease management through randomized controlled trials...
118
+ """
119
+
120
+ lay_summary = generate_lay_summary(medical_text)
121
+ print(f"Lay Summary: {lay_summary}")
122
+ ```
123
+
124
+ ## πŸ“š Training Details
125
 
126
  ### Training Data
127
+ - **eLife Dataset**: Open-access biomedical research articles with lay summaries
128
+ - **PLOS Dataset**: Public Library of Science biomedical publications
129
+ - **Data Processing**: Advanced preprocessing for optimal model performance
130
+
131
+ ### Training Configuration
132
+ - **Fine-tuning Method**: LoRA (Low-Rank Adaptation) with PEFT
133
+ - **Base Model**: microsoft/phi-2
134
+ - **Training Framework**: PyTorch + Hugging Face Transformers
135
+ - **Optimization**: Parameter-efficient approach reducing computational requirements
136
+
137
+ ### Training Advantages
138
+ - **Efficiency**: LoRA reduces trainable parameters while maintaining performance
139
+ - **Resource-Friendly**: PEFT enables high-quality fine-tuning with limited resources
140
+ - **Stability**: Advanced techniques ensure robust model behavior
141
+
142
+ ## πŸ“ˆ Comparative Analysis
143
+
144
+ ### Models Compared:
145
+ 1. **T5-Base** - Text-to-Text Transfer Transformer (Base)
146
+ 2. **T5-Large** - Text-to-Text Transfer Transformer (Large)
147
+ 3. **FlanT5-Base** - Instruction-tuned T5 model
148
+ 4. **BioGPT** - Biomedical domain-specific GPT
149
+ 5. **Phi-2** - Microsoft's efficient language model (**Winner**)
150
+ 6. **Falconsi-Medical_summarisation** - Specialized medical summarization model
151
+
152
+ ### Key Findings:
153
+ - **Phi-2 outperformed all competitors** in comprehensive evaluation
154
+ - **Domain-specific models** (BioGPT, Falconsi) showed advantages over general T5 models
155
+ - **Parameter efficiency** of Phi-2 provided superior cost-effectiveness
156
+ - **Smaller models** can achieve better performance with proper fine-tuning
157
+
158
+ ## 🎯 Use Cases
159
+
160
+ ### Healthcare Applications:
161
+ - **Patient Education**: Convert research findings into understandable format
162
+ - **Medical Communication**: Support doctor-patient conversations
163
+ - **Health Journalism**: Assist science writers and health reporters
164
+ - **Educational Materials**: Create teaching resources for health education
165
+ - **Policy Support**: Provide accessible summaries for health policy decisions
166
+
167
+ ### Target Audiences:
168
+ - Healthcare professionals seeking patient communication tools
169
+ - Patients and families researching medical conditions
170
+ - Health educators and trainers
171
+ - Medical journalists and science communicators
172
+ - Public health policy makers
173
+
174
+ ## ⚑ Performance Metrics
175
+
176
+ ### Evaluation Framework:
177
+ - **ROUGE Scores**: Overlap-based relevance assessment
178
+ - **BERTScore**: Semantic similarity evaluation
179
+ - **Readability Metrics**: FKGL and DCRS for accessibility
180
+ - **Factual Consistency**: BARTScore for accuracy verification
181
+
182
+ ### Resource Efficiency:
183
+ - **Model Size**: Compact and deployment-friendly
184
+ - **Inference Speed**: Fast generation suitable for real-time applications
185
+ - **Memory Usage**: Optimized for various computational environments
186
+ - **Cost Effectiveness**: Best performance per computational dollar
187
+
188
+ ## πŸ”§ Technical Specifications
189
+
190
+ ### Model Details:
191
+ - **Architecture**: Transformer-based with LoRA adaptation
192
+ - **Parameters**: Base Phi-2 + efficient LoRA adapters
193
+ - **Precision**: Mixed precision training for efficiency
194
+ - **Framework**: PyTorch with Hugging Face ecosystem
195
+
196
+ ### System Requirements:
197
+ - **Minimum GPU**: 4GB VRAM for inference
198
+ - **Recommended**: 8GB+ VRAM for optimal performance
199
+ - **CPU**: Compatible with CPU inference (slower)
200
+ - **Dependencies**: transformers, peft, torch
201
+
202
+ ## πŸ“– Research Impact
203
+
204
+ This model contributes to:
205
+ - **Democratizing Medical Knowledge**: Making research accessible to all
206
+ - **Advancing Healthcare NLP**: Pushing boundaries of medical text processing
207
+ - **Resource-Efficient AI**: Demonstrating effective use of LoRA and PEFT
208
+ - **Evaluation Methodology**: Comprehensive framework for summarization assessment
209
+
210
+ ## πŸ“„ License & Citation
211
+
212
+ ### License
213
+ This model is released under the **MIT License**, promoting open research and development.
214
+
215
+ ### Citation
216
+ If you use this model in your research, please cite:
217
+
218
+ ```bibtex
219
+ @misc{mane2024phi2biolaysum,
220
+ title={Phi-2 BioLaySum: Resource-Efficient Biomedical Lay Summarization using LoRA and PEFT},
221
+ author={Mane, Sanket},
222
+ year={2024},
223
+ publisher={Hugging Face},
224
+ url={https://huggingface.co/sank29mane/phi-2-biolaysum}
225
+ }
226
+ ```
227
+
228
+ ## πŸ”— Related Resources
229
+
230
+ - **GitHub Repository**: [lays-bio-summery](https://github.com/sank29mane/lays-bio-summery) - Complete training code and evaluation
231
+ - **Base Model**: [microsoft/phi-2](https://huggingface.co/microsoft/phi-2)
232
+ - **Research Paper**: [Detailed methodology and results](https://github.com/sank29mane/lays-bio-summery)
233
+
234
+ ## πŸ‘¨β€πŸ’» Author
235
 
236
+ **Sanket Mane** - [@sank29mane](https://github.com/sank29mane)
237
+ *Researcher in Biomedical NLP and Efficient Language Models*
238
+
239
+ ## πŸ“ž Contact & Support
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
 
241
+ - **GitHub Issues**: [Create an issue](https://github.com/sank29mane/lays-bio-summery/issues)
242
+ - **Model Issues**: Use the Community tab above
243
+ - **Research Collaborations**: Through GitHub profile
244
+
245
+ ## 🚨 Limitations & Considerations
246
+
247
+ ### Current Limitations:
248
+ - **Language**: Currently optimized for English biomedical text
249
+ - **Domain**: Focused on general biomedical research (not clinical notes)
250
+ - **Length**: Optimized for article-length inputs, may vary with very short/long texts
251
 
252
+ ### Recommended Use:
253
+ - Use for biomedical research article summarization
254
+ - Validate outputs for critical healthcare decisions
255
+ - Consider human review for patient-facing applications
256
 
257
+ ## πŸ”„ Model Updates
258
 
259
+ - **v1.0**: Initial release with LoRA+PEFT fine-tuning
260
+ - **Future**: Planned improvements for multi-language support and clinical text adaptation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
261
 
262
+ ---
263
 
264
+ ### Framework Versions
265
+ - **PEFT**: 0.7.2.dev0
266
+ - **Transformers**: Compatible with latest versions
267
+ - **PyTorch**: 1.12+
268
 
269
+ ⭐ **Star this model if you find it useful for your biomedical NLP research!** ⭐