This project focuses on fine-tuning a pre-trained RoBERTa model (benjamin/roberta-base-wechsel-swahili) for Named Entity Recognition (NER) in Swahili using the MasakhaNER dataset. The goal is to identify and classify named entities such as PERSON, LOCATION, ORGANIZATION, DATE, etc., in Swahili text.
# **Named Entity Recognition (NER) for Swahili using RoBERTa-Base-Wechsel**
## 📌 Table of Contents
- Overview
- Dataset
- Environment Setup
- Preprocessing
- Model Training
- Validation with Swahili Speakers
- Evaluation Metrics
- Results and Discussion
- How to Use
- Contributing
- License
- Acknowledgments
---
## 🚀 Overview
This project fine-tunes **RoBERTa-base-Wechsel-Swahili** for **Named Entity Recognition (NER) in Swahili**, using the **MasakhaNER dataset**. The goal is to identify and classify named entities such as **Persons (PER), Locations (LOC), Organizations (ORG), and Dates (DATE)** in Swahili text.
### **Key Features:**
✅ Fine-tuning **RoBERTa-base-Wechsel-Swahili** for Swahili NER.
✅ **Linguistic validation** with Swahili speakers for accuracy.
✅ **Evaluation using Precision, Recall, F1-score, and Accuracy.**
✅ **Error analysis and optimization suggestions.**
---
## 📊 Dataset
The dataset used in this project is **MasakhaNER**, which contains Swahili text annotated with named entities.
### **Dataset Statistics:**
| **Subset** | **Number of Sentences** |
|-------------|-----------------------|
| **Train** | 2,109 |
| **Validation** | 300 |
| **Test** | 604 |
Each sentence consists of:
- `id`: Unique identifier
- `tokens`: Words/tokens in the sentence
- `ner_tags`: Named entity labels (`O`, `B-PER`, `I-PER`, `B-LOC`, etc.)
### **Load the Dataset**
```python
from datasets import load_dataset
dataset = load_dataset("masakhaner", "swa", trust_remote_code=True)
Each example consists of:
- `id`: Unique identifier for the example.
- `tokens`: List of words/tokens in the sentence.
- `ner_tags`: Corresponding labels for each token (e.g., `O`, `B-PER`, `I-PER`, `B-LOC`, etc.).
```
---
## Environment Setup
To run this project, ensure you have the following dependencies installed:
### Required Libraries
```bash
pip install transformers datasets seqeval evaluate
```
### Python Version
This pr …