Update model description with comprehensive details from GitHub research project
Browse files
README.md
CHANGED
@@ -1,204 +1,269 @@
|
|
1 |
---
|
2 |
library_name: peft
|
3 |
base_model: microsoft/phi-2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
---
|
5 |
|
6 |
-
#
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
- **
|
25 |
-
- **
|
26 |
-
- **
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
-
|
33 |
-
- **
|
34 |
-
- **
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
### Training Data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
-
###
|
|
|
|
|
|
|
108 |
|
109 |
-
|
110 |
|
111 |
-
|
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
|
|
|
|
|
|
|
203 |
|
204 |
-
|
|
|
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!** β
|