CoolFace
Modelpublic

kikwaib/mt5-base-kenswquad-extractive

sourceHugging Faceapache-2.0updated 9mo agoView on Hugging Face
0likes21downloads
Model Card

mT5-Base KenSwQuAD Extractive (Stage 2)

Model Summary

This model is an intermediate research checkpoint developed as part of the KenSwQuAD Hierarchical Curriculum Learning project for Swahili Question Answering.

It is a google/mt5-base model that has undergone two stages of curriculum training:

  1. 1.Stage 1: Fine-tuned on English SQuAD v2 to learn QA task structure
  2. 2.Stage 2 (Current): Fine-tuned on extractive KenSwQuAD to learn Swahili morphology and syntax

The model learns to extract answer spans from Swahili text contexts given a question.

This is Stage 2 of a 3-Stage Pipeline:

  1. 1.✅ Stage 1: Structural Transfer (English SQuAD) → Learned "How to Answer"
  2. 2.✅ Stage 2 (Current): Morphological Alignment (Extractive KenSwQuAD) → Learned Swahili Syntax
  3. 3.⏳ Stage 3: Generative Refinement (Abstractive KenSwQuAD) → Will Learn Reasoning

Model Details

PropertyValue
Developed byBenjamin Kikwai (kikwaib)
Model TypeMultilingual Sequence-to-Sequence (Encoder-Decoder)
Base Modelkikwaib/mt5-base-squad-transfer
Original Basegoogle/mt5-base
Language(s)Swahili (sw), English (en), Multilingual
TaskExtractive Question Answering (Text-to-Text)
LicenseApache 2.0
Parameters582.4M
Vocabulary Size250,100

Intended Use

Primary Use Cases

  • —Swahili Question Answering: Extract answers from Swahili text given a question
  • —Transfer Learning: Serve as initialization for Swahili NLP tasks
  • —Research: Baseline for low-resource language QA experiments

How to Use

The model accepts input in the format: question: <question_text> context: <context_text>

python
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM

model_name = "kikwaib/mt5-base-kenswquad-extractive"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)

context = "Kenya ni nchi ya Afrika Mashariki. Nairobi ni mji mkuu wa Kenya. Kenya ina wakazi zaidi ya milioni 50."
question = "Mji mkuu wa Kenya ni upi?"

input_text = f"question: {question} context: {context}"
inputs = tokenizer(input_text, return_tensors="pt", max_length=1024, truncation=True)

outputs = model.generate(**inputs, max_length=128)
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)

print(answer)
# Expected Output: "Nairobi"

Limitations

  • —Optimized for extractive QA where the answer is a substring of the context
  • —May struggle with abstractive questions requiring reasoning or inference
  • —Performance may vary on domains outside the KenSwQuAD training data (primarily news and Wikipedia)

Training Data

Dataset: KenSwQuAD

The model was fine-tuned on the extractive subset of KenSwQuAD (Kenya Swahili Question Answering Dataset).

StatisticValue
Total QA Pairs Parsed7,497
Extractive Pairs (Stage 2)5,069 (67.6%)
Abstractive Pairs (Stage 3)2,428 (32.4%)
Training Samples4,562
Test Samples507
Train/Test Split90/10

Partitioning Logic

QA pairs were classified as extractive if the answer text appears as an exact substring (case-insensitive) of the context. Otherwise, they were classified as abstractive and reserved for Stage 3 training.

Training Procedure

Hardware

ComponentSpecification
GPUNVIDIA A100-SXM4-40GB
GPU Memory42.5 GB
PlatformGoogle Colab

Hyperparameters

ParameterValue
Learning Rate1e-4
Train Batch Size8
Eval Batch Size8
Epochs10
OptimizerAdamW (fused)
LR SchedulerLinear
Weight Decay0.01
Max Gradient Norm1.0
Max Input Length1024 tokens
Max Target Length128 tokens
FP16Disabled (T5 stability)
Seed75

Training Results

EpochTraining LossValidation LossBLEU Score
11.25120.734442.59
20.84880.756041.75
30.69450.763240.43
40.54140.735745.84
50.46040.783445.95
60.37300.813646.45
70.32490.807947.10
80.24730.851848.99 ★
90.22330.898946.53
100.20030.890546.82

★ Best checkpoint (selected based on highest BLEU score)

Training Dynamics

  • —Total Training Time: 69.9 minutes (1h 8m 23s)
  • —Total Steps: 5,710
  • —Final Training Loss: 0.4857

Key Observations:

  1. 1.Initial Adaptation (Epochs 1-3): BLEU dipped as model transitioned from English to Swahili patterns
  2. 2.Rapid Improvement (Epochs 4-8): Strong gains as Swahili morphology was learned
  3. 3.Best Performance: Epoch 8 achieved peak BLEU of 48.99
  4. 4.Slight Overfitting (Epochs 9-10): Validation loss increased while training loss continued decreasing

Evaluation Results

MetricScore
Best BLEU48.99
Final BLEU46.82
Best Validation Loss0.7344 (Epoch 1)
Final Validation Loss0.8905

Framework Versions

LibraryVersion
Transformers4.57.3
PyTorch2.9.0+cu126
Datasets4.0.0
Tokenizers0.22.1

Citation

comming soon

Related Models

StageModelDescription
0google/mt5-baseOriginal pretrained model
1kikwaib/mt5-base-squad-transferEnglish SQuAD fine-tuned
2kikwaib/mt5-base-kenswquad-extractive (Current)Swahili extractive QA
3Coming SoonSwahili abstractive QA

Training Date: December 20, 2025