AshenFdo's picture
Update README file
d6010cd verified
|
Raw
History Blame Contribute Delete
8.5 kB
---
language:
- en
license: apache-2.0
tags:
- text-classification
- blood-donation
- emergency-detection
- medical
- healthcare
- sri-lanka
- distilbert
- fine-tuned
datasets:
- AshenFdo/synthetic_blood_request_urgency_dataset
base_model: distilbert/distilbert-base-uncased
pipeline_tag: text-classification
metrics:
- accuracy
model-index:
- name: emergency_blood_request_classifier
results:
- task:
type: text-classification
dataset:
name: synthetic_blood_request_urgency_dataset
type: AshenFdo/synthetic_blood_request_urgency_dataset
metrics:
- type: accuracy
value: 1.0
---
# 🩸 Emergency Blood Request Classifier
A fine-tuned **DistilBERT** model for **binary text classification** that automatically determines whether a blood donation request is an **emergency** or **not an emergency**.
This model is part of my personal project to build an AI-powered blood donation mobile application for Sri Lanka β€” designed to prioritize life-critical requests and alert nearby donors faster.
---
## πŸ“Œ Model Summary
| Property | Details |
|---|---|
| **Base Model** | [distilbert/distilbert-base-uncased](https://huggingface.co/distilbert/distilbert-base-uncased) |
| **Task** | Binary Text Classification |
| **Labels** | `emergency`, `not_emergency` |
| **Training Dataset** | [AshenFdo/synthetic_blood_request_urgency_dataset](https://huggingface.co/datasets/AshenFdo/synthetic_blood_request_urgency_dataset) |
| **Evaluation Accuracy** | **100%** (eval set) |
| **Training Epochs** | 10 |
| **Language** | English |
| **Domain** | Healthcare / Blood Donation (Sri Lanka) |
| **License** | Apache 2.0 |
---
## 🎯 Intended Use
### Primary Use
This model is designed to be integrated into a **Sri Lanka blood donation mobile application**. When a user posts a blood request, the model reads the description and classifies it as:
- 🚨 `emergency` β†’ triggers immediate alerts to nearby donors
- πŸ“‹ `not_emergency` β†’ listed normally in the donor feed
### How It Fits the Bigger Picture
```
Blood Donation App (Sri Lanka)
β”‚
β–Ό
User posts a blood request
β”‚
β–Ό
πŸ€– This Model (Emergency Classifier)
─────────────────────────────────────
Reads the request description
β”‚
β”œβ”€β”€β–Ά emergency β†’ 🚨 Immediately alert nearby donors
β”‚
└──▢ not_emergency β†’ πŸ“‹ List normally in the donor feed
```
### Other Potential Uses
- Urgency triage in healthcare communication platforms
- Benchmarking lightweight NLP models on medical emergency detection
- Research on urgency language patterns in South Asian healthcare contexts
---
## ⚠️ Limitations
- **Synthetic training data** β€” The model was trained on AI-generated data. Real-world requests may use different phrasing, slang, abbreviations, or informal language not well-represented in training.
- **English only** β€” Sri Lankan blood requests often appear in Sinhala or Tamil. This model does not support those languages.
- **Sri Lanka context** β€” The dataset references Sri Lankan hospitals and cities. Performance on requests from other regions may vary.
- **Not for clinical use** β€” This model must not be used as a substitute for medical triage or clinical decision-making. It is an assistive tool for a donor coordination platform only.
---
## πŸš€ Quick Start
### Using the Pipeline (Recommended)
```python
from transformers import pipeline
classifier = pipeline("text-classification", model="AshenFdo/emergency_blood_request_classifier")
result = classifier("O negative blood required urgently at Karapitiya Hospital. We are out of time.")
print(result)
# [{'label': 'emergency', 'score': 0.999...}]
result = classifier("Organizing AB+ blood for an upcoming planned operation at Kandy National Hospital.")
print(result)
# [{'label': 'not_emergency', 'score': 0.999...}]
```
### Loading Model Directly
```python
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained("AshenFdo/emergency_blood_request_classifier")
model = AutoModelForSequenceClassification.from_pretrained("AshenFdo/emergency_blood_request_classifier")
text = "EMERGENCY: Kandy National Hospital ICU urgently needs A- blood. Patient is critical."
inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
with torch.no_grad():
logits = model(**inputs).logits
predicted_class_id = logits.argmax().item()
label = model.config.id2label[predicted_class_id]
print(f"Prediction: {label}")
# Prediction: emergency
```
### Batch Inference
```python
from transformers import pipeline
classifier = pipeline("text-classification", model="AshenFdo/emergency_blood_request_classifier")
requests = [
"Need O- blood for a routine hospital visit at Negombo Hospital.",
"My sister is in Kandy Hospital ICU with organ failure. We desperately need B+ blood. Pls help!",
"Community blood donation drive at Colombo town hall this Saturday.",
"URGENT: Karapitiya hospital needs AB- blood. Bus accident, multiple casualties.",
]
results = classifier(requests)
for req, res in zip(requests, results):
print(f"[{res['label']}] {req[:60]}...")
```
---
## πŸ“Š Training Details
### Dataset
- **2,500** synthetic blood request descriptions
- **Balanced** β€” 1,250 `emergency` and 1,250 `not_emergency`
- Sri Lanka-specific hospital names and geographic references
- See the full dataset: [AshenFdo/synthetic_blood_request_urgency_dataset](https://huggingface.co/datasets/AshenFdo/synthetic_blood_request_urgency_dataset)
### Label Definitions
| Label | Description |
|---|---|
| `emergency` | Patient is in a critical or life-threatening condition requiring blood immediately. Typically includes keywords like "urgent", "critical", "out of time", "severe hemorrhage", ICU references, or accident/trauma scenarios. |
| `not_emergency` | Routine, planned, or replacement donation requests. Includes scheduled surgeries, chronic condition support, community blood drives, and replacement donor programs. |
### Hyperparameters
| Parameter | Value |
|---|---|
| Learning Rate | `1e-4` |
| Train Batch Size | `32` |
| Eval Batch Size | `32` |
| Epochs | `10` |
| Optimizer | AdamW (fused) |
| LR Scheduler | Linear |
| Seed | `42` |
### Training Results
| Epoch | Training Loss | Validation Loss | Accuracy |
|---|---|---|---|
| 1 | 0.0954 | 0.0107 | 0.998 |
| 2 | 0.0041 | 0.0010 | 1.000 |
| 3 | 0.0109 | 0.0017 | 0.998 |
| 4 | 0.0001 | 0.0001 | 1.000 |
| 5–10 | ~0.0000 | ~0.0000 | 1.000 |
### Framework Versions
- Transformers: 5.10.1
- PyTorch: 2.11.0+cu128
- Datasets: 5.0.0
- Tokenizers: 0.22.2
- Training Environment: Google Colab (GPU)
---
## πŸ—‚οΈ Example Predictions
| Description | Expected Label |
|---|---|
| *"HOSPITAL EMERGENCY: Ratnapura Hospital urgently requires AB- blood for a critical patient."* | `emergency` |
| *"O negative blood required urgently at Karapitiya Hospital. We are out of time."* | `emergency` |
| *"Need O+ blood ASAP. Friend is in Ragama hospital surgical ICU with a burst spleen."* | `emergency` |
| *"Organizing AB+ blood for an upcoming planned operation at Kandy National Hospital."* | `not_emergency` |
| *"Blood donation campaign at the Ratnapura clock tower organized by the local association."* | `not_emergency` |
| *"Advance donor support for an elective surgery at Ratnapura Hospital. A- needed."* | `not_emergency` |
---
## πŸ”— Related Resources
- πŸ“ **Full Project on GitHub:** [AshenFdo/Blood-Request-Emergency-Classification-Model](https://github.com/AshenFdo/Blood-Request-Emergency-Classification-Model)
- πŸ—ƒοΈ **Training Dataset:** [AshenFdo/synthetic_blood_request_urgency_dataset](https://huggingface.co/datasets/AshenFdo/synthetic_blood_request_urgency_dataset)
- πŸ€— **Base Model:** [distilbert/distilbert-base-uncased](https://huggingface.co/distilbert/distilbert-base-uncased)
---
## πŸ“œ Citation
If you use this model in your research or project, please cite it as:
```bibtex
@model{AshenFdo_emergency_blood_request_classifier_2025,
author = {AshenFdo},
title = {Emergency Blood Request Classifier},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/AshenFdo/emergency_blood_request_classifier}
}
```
---
*Built with the goal of saving lives β€” one donation at a time. 🩸*