Update README.md
Browse files
README.md
CHANGED
|
@@ -1,67 +1,137 @@
|
|
| 1 |
---
|
| 2 |
-
|
|
|
|
|
|
|
|
|
|
| 3 |
license: apache-2.0
|
| 4 |
-
base_model: google/mt5-base
|
| 5 |
tags:
|
| 6 |
-
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
metrics:
|
| 8 |
- rouge
|
|
|
|
| 9 |
model-index:
|
| 10 |
- name: mt5-base-squad-transfer
|
| 11 |
-
results:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
-
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
- Loss: 0.3712
|
| 22 |
-
- Rouge1: 83.1882
|
| 23 |
-
- Rouge2: 44.8183
|
| 24 |
-
- Rougel: 83.2252
|
| 25 |
-
- Rougelsum: 83.2484
|
| 26 |
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
|
|
|
| 32 |
|
| 33 |
-
|
|
|
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
-
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
## Training
|
| 40 |
|
| 41 |
-
|
| 42 |
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
- train_batch_size: 8
|
| 46 |
-
- eval_batch_size: 8
|
| 47 |
-
- seed: 42
|
| 48 |
-
- gradient_accumulation_steps: 2
|
| 49 |
-
- total_train_batch_size: 16
|
| 50 |
-
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 51 |
-
- lr_scheduler_type: linear
|
| 52 |
-
- num_epochs: 2
|
| 53 |
|
| 54 |
-
##
|
| 55 |
|
| 56 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|:-------------:|:-----:|:-----:|:---------------:|:-------:|:-------:|:-------:|:---------:|
|
| 58 |
| 0.2473 | 1.0 | 5427 | 0.4609 | 81.6473 | 43.3537 | 81.665 | 81.7141 |
|
| 59 |
| 0.3451 | 2.0 | 10854 | 0.3712 | 83.1882 | 44.8183 | 83.2252 | 83.2484 |
|
| 60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
-
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
-
|
| 65 |
-
- Pytorch 2.9.0+cu126
|
| 66 |
-
- Datasets 4.0.0
|
| 67 |
-
- Tokenizers 0.22.1
|
|
|
|
| 1 |
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
- sw
|
| 5 |
+
- multilingual
|
| 6 |
license: apache-2.0
|
|
|
|
| 7 |
tags:
|
| 8 |
+
- question-answering
|
| 9 |
+
- seq2seq
|
| 10 |
+
- curriculum-learning
|
| 11 |
+
- mt5
|
| 12 |
+
- low-resource-nlp
|
| 13 |
+
datasets:
|
| 14 |
+
- rajpurkar/squad_v2
|
| 15 |
metrics:
|
| 16 |
- rouge
|
| 17 |
+
base_model: google/mt5-base
|
| 18 |
model-index:
|
| 19 |
- name: mt5-base-squad-transfer
|
| 20 |
+
results:
|
| 21 |
+
- task:
|
| 22 |
+
type: question-answering
|
| 23 |
+
name: Question Answering
|
| 24 |
+
dataset:
|
| 25 |
+
name: SQuAD v2
|
| 26 |
+
type: rajpurkar/squad_v2
|
| 27 |
+
metrics:
|
| 28 |
+
- name: ROUGE-L
|
| 29 |
+
type: rouge
|
| 30 |
+
value: 83.22
|
| 31 |
---
|
| 32 |
|
| 33 |
+
# Model Card for mT5-Base SQuAD Transfer (Stage 1)
|
| 34 |
+
|
| 35 |
+
## Model Summary
|
| 36 |
+
|
| 37 |
+
This model is an **intermediate research checkpoint** developed as part of the **KenSwQuAD** project (Hierarchical Curriculum Learning for Swahili QA).
|
| 38 |
+
|
| 39 |
+
It consists of a `google/mt5-base` model that has been fine-tuned on the **English SQuAD v2 dataset**. The purpose of this model is to serve as a "Structure-Aware" baseline. By learning the mechanics of Question Answering (identifying query-response relationships) in a high-resource language (English), this model effectively learns the *task* of QA before being adapted to the *language* of Swahili in subsequent training stages.
|
| 40 |
+
|
| 41 |
+
**This is Stage 1 of a 3-Stage Pipeline:**
|
| 42 |
+
1. **Stage 1 (Current):** Structural Transfer (English SQuAD) -> *Learns "How to Answer"*
|
| 43 |
+
2. **Stage 2:** Morphological Alignment (Extractive KenSwQuAD) -> *Learns Swahili Syntax*
|
| 44 |
+
3. **Stage 3:** Generative Refinement (Full KenSwQuAD + Scaffolding) -> *Learns Reasoning*
|
| 45 |
+
|
| 46 |
+
## Model Details
|
| 47 |
+
|
| 48 |
+
- **Developed by:** Benjamin Kikwai
|
| 49 |
+
- **Model Type:** Multilingual Sequence-to-Sequence (Encoder-Decoder)
|
| 50 |
+
- **Base Model:** [google/mt5-base](https://huggingface.co/google/mt5-base)
|
| 51 |
+
- **Language(s):** Pre-trained on 101 languages (mC4); Fine-tuned on English.
|
| 52 |
+
- **Task:** Generative Question Answering (Text-to-Text).
|
| 53 |
+
- **License:** Apache 2.0
|
| 54 |
+
|
| 55 |
+
## Intended Use
|
| 56 |
|
| 57 |
+
This model is primarily intended for **Transfer Learning** experiments. It serves as a better initialization point for Multilingual QA tasks than the raw `mt5-base` checkpoint.
|
| 58 |
|
| 59 |
+
### How to Use
|
| 60 |
+
The model accepts input in the format: `question: <question_text> context: <context_text>`
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
+
```python
|
| 63 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
| 64 |
|
| 65 |
+
model_name = "kikwaib/mt5-base-squad-transfer"
|
| 66 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 67 |
+
model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
|
| 68 |
|
| 69 |
+
context = "The Normans (Norman: Nourmands; French: Normands; Latin: Normanni) were the people who in the 10th and 11th centuries gave their name to Normandy, a region in France."
|
| 70 |
+
question = "When were the Normans in Normandy?"
|
| 71 |
|
| 72 |
+
input_text = f"question: {question} context: {context}"
|
| 73 |
+
inputs = tokenizer(input_text, return_tensors="pt")
|
| 74 |
|
| 75 |
+
outputs = model.generate(**inputs, max_length=32)
|
| 76 |
+
answer = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 77 |
|
| 78 |
+
print(answer)
|
| 79 |
+
# Expected Output: "10th and 11th centuries"
|
| 80 |
+
```
|
| 81 |
|
| 82 |
+
## Training Data
|
| 83 |
|
| 84 |
+
The model was fine-tuned on **SQuAD v2 (Stanford Question Answering Dataset)**.
|
| 85 |
|
| 86 |
+
**Preprocessing Note:**
|
| 87 |
+
To align with the KenSwQuAD dataset (which contains only answerable questions), this model was trained **only on the answerable subset** of SQuAD v2. Unanswerable questions (where the answer list is empty) were filtered out during preprocessing to prevent the model from learning to generate empty strings or "unanswerable" tokens.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 88 |
|
| 89 |
+
## Training Procedure
|
| 90 |
|
| 91 |
+
The training was conducted in a Google Colab environment using Hugging Face Transformers.
|
| 92 |
+
|
| 93 |
+
### Hyperparameters
|
| 94 |
+
- **Learning Rate:** 1e-4
|
| 95 |
+
- **Train Batch Size:** 8
|
| 96 |
+
- **Eval Batch Size:** 8
|
| 97 |
+
- **Gradient Accumulation Steps:** 2
|
| 98 |
+
- **Effective Batch Size:** 16
|
| 99 |
+
- **Num Epochs:** 2
|
| 100 |
+
- **Optimizer:** AdamW (fused) with betas=(0.9, 0.999) and epsilon=1e-08
|
| 101 |
+
- **LR Scheduler:** Linear
|
| 102 |
+
- **Seed:** 42
|
| 103 |
+
- **Max Input Length:** 512 tokens
|
| 104 |
+
|
| 105 |
+
### Training Results
|
| 106 |
+
|
| 107 |
+
| Training Loss | Epoch | Step | Validation Loss | Rouge1 | Rouge2 | RougeL | RougeLsum |
|
| 108 |
|:-------------:|:-----:|:-----:|:---------------:|:-------:|:-------:|:-------:|:---------:|
|
| 109 |
| 0.2473 | 1.0 | 5427 | 0.4609 | 81.6473 | 43.3537 | 81.665 | 81.7141 |
|
| 110 |
| 0.3451 | 2.0 | 10854 | 0.3712 | 83.1882 | 44.8183 | 83.2252 | 83.2484 |
|
| 111 |
|
| 112 |
+
### Environmental Impact
|
| 113 |
+
- **Hardware:** NVIDIA T4 GPU
|
| 114 |
+
- **Compute Time:** ~3 hours
|
| 115 |
+
|
| 116 |
+
## Evaluation Results
|
| 117 |
+
|
| 118 |
+
The model was evaluated on the SQuAD v2 validation set (answerable subset).
|
| 119 |
+
|
| 120 |
+
| Metric | Score | Interpretation |
|
| 121 |
+
| :--- | :--- | :--- |
|
| 122 |
+
| **ROUGE-L** | **83.23** | High structural overlap with ground truth. |
|
| 123 |
+
| **ROUGE-1** | 83.19 | Excellent keyword retention. |
|
| 124 |
+
| **ROUGE-2** | 44.82 | Strong bigram overlap. |
|
| 125 |
+
| **ROUGE-Lsum** | 83.25 | Consistent summary-level performance. |
|
| 126 |
+
| **Validation Loss**| 0.37 | Strong convergence without overfitting. |
|
| 127 |
+
|
| 128 |
+
These scores indicate that the model has successfully learned to extract and generate spans of text relevant to questions, verifying its readiness for cross-lingual transfer to Swahili.
|
| 129 |
+
|
| 130 |
+
## Framework Versions
|
| 131 |
|
| 132 |
+
- **Transformers:** 4.57.3
|
| 133 |
+
- **PyTorch:** 2.9.0+cu126
|
| 134 |
+
- **Datasets:** 4.0.0
|
| 135 |
+
- **Tokenizers:** 0.22.1
|
| 136 |
|
| 137 |
+
## Citation
|
|
|
|
|
|
|
|
|