This project focuses on developing machine learning models to replicate clinical reasoning in Kenyan healthcare settings. The challenge involves predicting clinicians' responses to complex medical vignettes, simulating real-world decision-making in rural and resource-constrained environments.
**Clinical Reasoning with T5 Transformer**
**Zindi Competition: Kenya Clinical Reasoning Challenge**
*Notebook Link:* Open in Colab
---
## **📌 Overview**
This notebook implements a **fine-tuned T5 Transformer model** for clinical text classification, submitted to the Kenya Clinical Reasoning Challenge on Zindi. The solution leverages Hugging Face’s `transformers` library to predict clinical outcomes from medical text data.
**🔗 Share this notebook:**
---
**Certificate Verification**:
Validate competition participation and ranking via the official Zindi certificate.
---
## **🚀 Key Features**
1. **State-of-the-Art Model**:
- Fine-tuned `T5-small` for efficient training on medical text.
- Optimized for Colab’s free-tier GPU (FP16, gradient accumulation).
2. **End-to-End Pipeline**:
- Data loading → Preprocessing → Training → Submission.
- Includes Zindi submission validation (`validate_submission()`).
3. **Competition-Ready**:
- Logs metrics (accuracy, F1-score).
- Saves predictions in Zindi’s required CSV format.
---
## **🛠️ Technical Setup**
### **Dependencies**
```bash
pip install transformers datasets evaluate accelerate pandas numpy
```
### **Model Architecture**
```python
from transformers import T5ForConditionalGeneration, TrainingArguments
model = T5ForConditionalGeneration.from_pretrained("t5-small")
training_args = TrainingArguments(
output_dir="./results",
per_device_train_batch_size=4,
fp16=True, # GPU acceleration
num_train_epochs=3
)
```
---
## **📊 Data Preprocessing**
- **Input Format**: Clinical text (e.g., `"Patient with fever and cough"`).
- **Tokenization**:
```python
tokenizer = T5Tokenizer.from_pretrained("t5-small")
inputs = tokenizer("clinical text: " + text, truncation=True, padding="max_length")
```
---
## **⚙️ Training**
**Hyperparameters**:
| Parameter | Value |
|--------------------|-----------|
| Learning Rate | `3e-5` |
| Batch Size | `4` |
| Epochs | `3` |
| FP16 …