Comparing LLM-based Augmentation vs Back-Translation for Hausa and Fongbe
This project investigates whether synthetic data augmentation improves NLP model performance for low-resource African languages. We compare two augmentation strategies across three tasks: Named Entity Recognition (NER), Part-of-Speech (POS) tagging, and Sentiment Analysis.
| Language | ISO Code | Translation Quality* | Expected Outcome |
|---|---|---|---|
| Hausa | hau | High (4.46/5) | Augmentation should help |
| Fongbe | fon | Low (2.20/5) | Augmentation may hurt or be neutral |
*Based on prior SIGIR paper findings on LLM translation quality for African languages.
Key Hypothesis: High translation quality → augmentation helps; Low quality → may introduce noise.
| Task | Dataset | Metric | Train Size (Hausa/Fongbe) |
|---|---|---|---|
| NER | MasakhaNER 2.0 | F1 Score | 5,716 / 4,343 |
| POS | MasakhaPOS | Accuracy | 753 / 810 |
| Sentiment | AfriSenti | F1 Weighted | 14,172 (Hausa only) |
O, B-PER, I-PER, B-ORG, I-ORG, B-LOC, I-LOC, B-DATE, I-DATE
NOUN, VERB, ADJ, ADV, PROPN, PRON, DET, ADP, NUM, CONJ, PUNCT, ...
positive, negative, neutral
| Condition | Description | Training Data |
|---|---|---|
| Baseline | Original data only | MasakhaNER/POS/AfriSenti |
| LLM | Original + LLM-generated | + Gemini synthetic examples |
| BackTrans | Original + back-translated | + NLLB-200 paraphrases |
| Combined | Original + parallel corpus | + External parallel data |
augmentation_tasks_fon_ha/
│
├── configs/
│ └── experiment_config.yaml # Model settings, API config
│
├── data/
│ ├── raw/ # Downloaded benchmark datasets
│ │ ├── masakhaner2_hau/ # Hausa NER (train/val/test.jsonl)
│ │ ├── masakhaner2_fon/ # Fongbe NER
│ │ ├── masakhane_pos_hau/ # Hausa POS
│ │ └── masakhane_pos_fon/ # Fongbe POS
│ │
│ ├── original/
│ │ └── sentiment/hausa/ # AfriSenti sentiment data
│ │
│ └── synthetic/ # Generated augmented data
│ ├── llm/ # LLM-generated (hausa_ner.jsonl, etc.)
│ └── backtrans/ # Back-translated examples
│
├── scripts/
│ ├── download_datasets.py # Download NER + POS data
│ └── download_snt_dataset.py # Download sentiment data
│
├── src/
│ ├── utils.py # Gemini setup, data loading, helpers
│ ├── augment_llm.py # LLM-based augmentation (Gemini API)
│ ├── augment_backtrans.py # Back-translation (NLLB-200)
│ ├── train_ner.py # NER model training
│ ├── train_pos.py # POS model training
│ ├── train_sentiment.py # Sentiment model training
│ ├── evaluate.py # Aggregate results & statistics
│ └── analyze_comparative.py # Generate tables/plots
│
├── experiments/
│ ├── run_all.sh # Full experiment pipeline
│ ├── run_augmentation.sh # Generate all synthetic data
│ ├── run_ner.sh # NER experiments (16 runs + cleanup)
│ ├── run_pos.sh # POS experiments (16 runs + cleanup)
│ └── run_senti.sh # Sentiment experiments (8 runs + cleanup)
│
├── results/ # Experiment outputs
│ ├── ner/{lang}_{condition}_seed{N}/
│ ├── pos/
│ ├── sentiment/
│ └── analysis/ # Aggregated tables & plots
│
├── tests/
│ └── test_pipeline.py # Validation tests (16 tests)
│
├── requirements.txt # Python dependencies
├── .env # API keys (GEMINI_API_KEY, HF_TOKEN)
└── README.md
# Navigate to project
cd augmentation_tasks_fon_ha
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
Create a .env file with your API keys:
# Get a free Gemini API key at: https://aistudio.google.com/
GEMINI_API_KEY=your_gemini_api_key_here
# Optional: HuggingFace token for faster downloads
HF_TOKEN=your_hf_token_here
# Download NER and POS data (MasakhaNER + MasakhaPOS)
python scripts/download_datasets.py
# Download sentiment data (AfriSenti - Hausa only)
python scripts/download_snt_dataset.py
# Run tests (should show 16/16 passed)
python tests/test_pipeline.py
# LLM-based augmentation (uses Gemini API)
python src/augment_llm.py -l hau -t ner -n 500 # Hausa NER
python src/augment_llm.py -l fon -t ner -n 500 # Fongbe NER
python src/augment_llm.py -l hau -t pos -n 500 # Hausa POS
python src/augment_llm.py -l fon -t pos -n 500 # Fongbe POS
python src/augment_llm.py -l hau -t sentiment -n 500 # Hausa Sentiment
# Back-translation (uses NLLB-200, slower ~1 sec/example)
python src/augment_backtrans.py -l hau -t ner -n 500
python src/augment_backtrans.py -l fon -t ner -n 500
# Baseline (no augmentation)
python src/train_ner.py --language hau --condition baseline --seed 42
# With LLM augmentation
python src/train_ner.py --language hau --condition llm --seed 42
# With back-translation
python src/train_ner.py --language hau --condition backtrans --seed 42
python src/evaluate.py
# Results saved to: results/analysis/
| Task | Languages | Conditions | Seeds | Total Runs |
|---|---|---|---|---|
| NER | hau, fon | baseline, llm, backtrans, combined | 42, 123 | 16 |
| POS | hau, fon | baseline, llm, backtrans, combined | 42, 123 | 16 |
| Sentiment | hau | baseline, llm, backtrans, combined | 42, 123 | 8 |
| Total | 40 |
Each script runs all experiments for a task and automatically cleans up checkpoints to save disk space:
# Run NER experiments (16 runs, ~5 hours on GPU)
bash experiments/run_ner.sh
# Run POS experiments (16 runs, ~5 hours on GPU)
bash experiments/run_pos.sh
# Run Sentiment experiments (8 runs, ~3 hours on GPU)
bash experiments/run_senti.sh
# Generate final analysis
python src/evaluate.py
If disk space is limited (<100GB free), run experiments in phases:
# Phase 1: NER (~51GB, auto-cleanup after)
bash experiments/run_ner.sh
# Phase 2: POS (~51GB, auto-cleanup after)
bash experiments/run_pos.sh
# Phase 3: Sentiment (~26GB, auto-cleanup after)
bash experiments/run_senti.sh
# Final: Generate analysis
python src/evaluate.py
| Task | Experiments | GPU Time | Disk (Peak) |
|---|---|---|---|
| NER | 16 | ~5 hours | 51 GB |
| POS | 16 | ~5 hours | 51 GB |
| Sentiment | 8 | ~3 hours | 26 GB |
| Total | 40 | ~13 hours | 52 GB (phased) |
Note: Scripts automatically clean up model checkpoints after completion, keeping only test_results.json files.
LLM Augmentation (augment_llm.py)
Original Examples → Few-shot Prompt → Gemini API → NEW Synthetic Examples
Back-Translation (augment_backtrans.py)
Original Sentence → NLLB (→English) → NLLB (→Hausa/Fongbe) → Paraphrased Sentence
All tasks use AfroXLMR-base (Davlan/afro-xlmr-base):
Training flow:
data/raw/ or data/original/data/synthetic/evaluate.py collects all test_results.json files and:
| Parameter | Default | Fast | Quality |
|---|---|---|---|
--epochs | 10 | 3-5 | 10 |
--batch_size | 32 | 16 | 32 |
--lr | 2e-5 | 2e-5 | 2e-5 |
--seed | 42 | 42 | 42, 123 |
| Condition | Hausa | Fongbe |
|---|---|---|
| Baseline | ~0.78 | ~0.75 |
| +LLM Aug | ~0.80-0.82 (+2-4%) | ~0.74-0.76 (±1%) |
| +BackTrans | ~0.79-0.80 (+1-2%) | ~0.75-0.76 (±1%) |
"LLM-based augmentation significantly improves NER performance for Hausa (+3% F1), but shows no benefit for Fongbe, likely due to lower translation quality for this language."
After running experiments:
results/
├── ner/
│ ├── hausa_baseline_seed42/test_results.json
│ ├── hausa_llm_seed42/test_results.json
│ └── ...
├── pos/
│ └── ...
├── sentiment/
│ └── ...
└── analysis/
├── summary_table.csv # Copy-paste to Excel/Sheets
├── summary_table.tex # LaTeX for paper
├── significance_tests.csv # p-values for comparisons
└── plots/
├── ner_comparison.pdf
└── pos_comparison.pdf
# Option 1: Export directly
export GEMINI_API_KEY="your-key-here"
# Option 2: Create .env file
echo 'GEMINI_API_KEY=your-key' > .env
pip install google-genai
This is fixed in the latest version. If you encounter it:
pip install --upgrade transformers
# Reduce batch size
python src/train_ner.py --batch_size 8 ...
The sentiment download script has been updated to use direct file downloads. Pull the latest version.
--num 100 for quick testing# Upgrade dependencies
pip install --upgrade huggingface_hub transformers datasets google-genai
@inproceedings{yourname2026augmentation,
title={When Does Synthetic Data Help? Comparing Augmentation Methods
for Low-Resource African NLP},
author={Your Name},
booktitle={Proceedings of KDD},
year={2026}
}
@inproceedings{adelani2022masakhaner,
title={MasakhaNER 2.0: Africa-centric Transfer Learning for Named Entity Recognition},
author={Adelani, David Ifeoluwa and others},
booktitle={EMNLP},
year={2022}
}
@inproceedings{dione2023masakhapos,
title={MasakhaPOS: Part-of-Speech Tagging for Typologically Diverse African Languages},
author={Dione, Cheikh M Bamba and others},
booktitle={ACL},
year={2023}
}
@inproceedings{muhammad2023afrisenti,
title={AfriSenti: A Twitter Sentiment Analysis Benchmark for African Languages},
author={Muhammad, Shamsuddeen Hassan and others},
booktitle={EMNLP},
year={2023}
}
MIT License
18 commits
Python
92.5%
Shell
7.5%
Comparing LLM-based Augmentation vs Back-Translation for Hausa and Fongbe
This project investigates whether synthetic data augmentation improves NLP model performance for low-resource African languages. We compare two augmentation strategies across three tasks: Named Entity Recognition (NER), Part-of-Speech (POS) tagging, and Sentiment Analysis.
| Language | ISO Code | Translation Quality* | Expected Outcome |
|---|---|---|---|
| Hausa | hau | High (4.46/5) | Augmentation should help |
| Fongbe | fon | Low (2.20/5) | Augmentation may hurt or be neutral |
*Based on prior SIGIR paper findings on LLM translation quality for African languages.
Key Hypothesis: High translation quality → augmentation helps; Low quality → may introduce noise.
| Task | Dataset | Metric | Train Size (Hausa/Fongbe) |
|---|---|---|---|
| NER | MasakhaNER 2.0 | F1 Score | 5,716 / 4,343 |
| POS | MasakhaPOS | Accuracy | 753 / 810 |
| Sentiment | AfriSenti | F1 Weighted | 14,172 (Hausa only) |
O, B-PER, I-PER, B-ORG, I-ORG, B-LOC, I-LOC, B-DATE, I-DATE
NOUN, VERB, ADJ, ADV, PROPN, PRON, DET, ADP, NUM, CONJ, PUNCT, ...
positive, negative, neutral
| Condition | Description | Training Data |
|---|---|---|
| Baseline | Original data only | MasakhaNER/POS/AfriSenti |
| LLM | Original + LLM-generated | + Gemini synthetic examples |
| BackTrans | Original + back-translated | + NLLB-200 paraphrases |
| Combined | Original + parallel corpus | + External parallel data |
augmentation_tasks_fon_ha/
│
├── configs/
│ └── experiment_config.yaml # Model settings, API config
│
├── data/
│ ├── raw/ # Downloaded benchmark datasets
│ │ ├── masakhaner2_hau/ # Hausa NER (train/val/test.jsonl)
│ │ ├── masakhaner2_fon/ # Fongbe NER
│ │ ├── masakhane_pos_hau/ # Hausa POS
│ │ └── masakhane_pos_fon/ # Fongbe POS
│ │
│ ├── original/
│ │ └── sentiment/hausa/ # AfriSenti sentiment data
│ │
│ └── synthetic/ # Generated augmented data
│ ├── llm/ # LLM-generated (hausa_ner.jsonl, etc.)
│ └── backtrans/ # Back-translated examples
│
├── scripts/
│ ├── download_datasets.py # Download NER + POS data
│ └── download_snt_dataset.py # Download sentiment data
│
├── src/
│ ├── utils.py # Gemini setup, data loading, helpers
│ ├── augment_llm.py # LLM-based augmentation (Gemini API)
│ ├── augment_backtrans.py # Back-translation (NLLB-200)
│ ├── train_ner.py # NER model training
│ ├── train_pos.py # POS model training
│ ├── train_sentiment.py # Sentiment model training
│ ├── evaluate.py # Aggregate results & statistics
│ └── analyze_comparative.py # Generate tables/plots
│
├── experiments/
│ ├── run_all.sh # Full experiment pipeline
│ ├── run_augmentation.sh # Generate all synthetic data
│ ├── run_ner.sh # NER experiments (16 runs + cleanup)
│ ├── run_pos.sh # POS experiments (16 runs + cleanup)
│ └── run_senti.sh # Sentiment experiments (8 runs + cleanup)
│
├── results/ # Experiment outputs
│ ├── ner/{lang}_{condition}_seed{N}/
│ ├── pos/
│ ├── sentiment/
│ └── analysis/ # Aggregated tables & plots
│
├── tests/
│ └── test_pipeline.py # Validation tests (16 tests)
│
├── requirements.txt # Python dependencies
├── .env # API keys (GEMINI_API_KEY, HF_TOKEN)
└── README.md
# Navigate to project
cd augmentation_tasks_fon_ha
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txt
Create a .env file with your API keys:
# Get a free Gemini API key at: https://aistudio.google.com/
GEMINI_API_KEY=your_gemini_api_key_here
# Optional: HuggingFace token for faster downloads
HF_TOKEN=your_hf_token_here
# Download NER and POS data (MasakhaNER + MasakhaPOS)
python scripts/download_datasets.py
# Download sentiment data (AfriSenti - Hausa only)
python scripts/download_snt_dataset.py
# Run tests (should show 16/16 passed)
python tests/test_pipeline.py
# LLM-based augmentation (uses Gemini API)
python src/augment_llm.py -l hau -t ner -n 500 # Hausa NER
python src/augment_llm.py -l fon -t ner -n 500 # Fongbe NER
python src/augment_llm.py -l hau -t pos -n 500 # Hausa POS
python src/augment_llm.py -l fon -t pos -n 500 # Fongbe POS
python src/augment_llm.py -l hau -t sentiment -n 500 # Hausa Sentiment
# Back-translation (uses NLLB-200, slower ~1 sec/example)
python src/augment_backtrans.py -l hau -t ner -n 500
python src/augment_backtrans.py -l fon -t ner -n 500
# Baseline (no augmentation)
python src/train_ner.py --language hau --condition baseline --seed 42
# With LLM augmentation
python src/train_ner.py --language hau --condition llm --seed 42
# With back-translation
python src/train_ner.py --language hau --condition backtrans --seed 42
python src/evaluate.py
# Results saved to: results/analysis/
| Task | Languages | Conditions | Seeds | Total Runs |
|---|---|---|---|---|
| NER | hau, fon | baseline, llm, backtrans, combined | 42, 123 | 16 |
| POS | hau, fon | baseline, llm, backtrans, combined | 42, 123 | 16 |
| Sentiment | hau | baseline, llm, backtrans, combined | 42, 123 | 8 |
| Total | 40 |
Each script runs all experiments for a task and automatically cleans up checkpoints to save disk space:
# Run NER experiments (16 runs, ~5 hours on GPU)
bash experiments/run_ner.sh
# Run POS experiments (16 runs, ~5 hours on GPU)
bash experiments/run_pos.sh
# Run Sentiment experiments (8 runs, ~3 hours on GPU)
bash experiments/run_senti.sh
# Generate final analysis
python src/evaluate.py
If disk space is limited (<100GB free), run experiments in phases:
# Phase 1: NER (~51GB, auto-cleanup after)
bash experiments/run_ner.sh
# Phase 2: POS (~51GB, auto-cleanup after)
bash experiments/run_pos.sh
# Phase 3: Sentiment (~26GB, auto-cleanup after)
bash experiments/run_senti.sh
# Final: Generate analysis
python src/evaluate.py
| Task | Experiments | GPU Time | Disk (Peak) |
|---|---|---|---|
| NER | 16 | ~5 hours | 51 GB |
| POS | 16 | ~5 hours | 51 GB |
| Sentiment | 8 | ~3 hours | 26 GB |
| Total | 40 | ~13 hours | 52 GB (phased) |
Note: Scripts automatically clean up model checkpoints after completion, keeping only test_results.json files.
LLM Augmentation (augment_llm.py)
Original Examples → Few-shot Prompt → Gemini API → NEW Synthetic Examples
Back-Translation (augment_backtrans.py)
Original Sentence → NLLB (→English) → NLLB (→Hausa/Fongbe) → Paraphrased Sentence
All tasks use AfroXLMR-base (Davlan/afro-xlmr-base):
Training flow:
data/raw/ or data/original/data/synthetic/evaluate.py collects all test_results.json files and:
| Parameter | Default | Fast | Quality |
|---|---|---|---|
--epochs | 10 | 3-5 | 10 |
--batch_size | 32 | 16 | 32 |
--lr | 2e-5 | 2e-5 | 2e-5 |
--seed | 42 | 42 | 42, 123 |
| Condition | Hausa | Fongbe |
|---|---|---|
| Baseline | ~0.78 | ~0.75 |
| +LLM Aug | ~0.80-0.82 (+2-4%) | ~0.74-0.76 (±1%) |
| +BackTrans | ~0.79-0.80 (+1-2%) | ~0.75-0.76 (±1%) |
"LLM-based augmentation significantly improves NER performance for Hausa (+3% F1), but shows no benefit for Fongbe, likely due to lower translation quality for this language."
After running experiments:
results/
├── ner/
│ ├── hausa_baseline_seed42/test_results.json
│ ├── hausa_llm_seed42/test_results.json
│ └── ...
├── pos/
│ └── ...
├── sentiment/
│ └── ...
└── analysis/
├── summary_table.csv # Copy-paste to Excel/Sheets
├── summary_table.tex # LaTeX for paper
├── significance_tests.csv # p-values for comparisons
└── plots/
├── ner_comparison.pdf
└── pos_comparison.pdf
# Option 1: Export directly
export GEMINI_API_KEY="your-key-here"
# Option 2: Create .env file
echo 'GEMINI_API_KEY=your-key' > .env
pip install google-genai
This is fixed in the latest version. If you encounter it:
pip install --upgrade transformers
# Reduce batch size
python src/train_ner.py --batch_size 8 ...
The sentiment download script has been updated to use direct file downloads. Pull the latest version.
--num 100 for quick testing# Upgrade dependencies
pip install --upgrade huggingface_hub transformers datasets google-genai
@inproceedings{yourname2026augmentation,
title={When Does Synthetic Data Help? Comparing Augmentation Methods
for Low-Resource African NLP},
author={Your Name},
booktitle={Proceedings of KDD},
year={2026}
}
@inproceedings{adelani2022masakhaner,
title={MasakhaNER 2.0: Africa-centric Transfer Learning for Named Entity Recognition},
author={Adelani, David Ifeoluwa and others},
booktitle={EMNLP},
year={2022}
}
@inproceedings{dione2023masakhapos,
title={MasakhaPOS: Part-of-Speech Tagging for Typologically Diverse African Languages},
author={Dione, Cheikh M Bamba and others},
booktitle={ACL},
year={2023}
}
@inproceedings{muhammad2023afrisenti,
title={AfriSenti: A Twitter Sentiment Analysis Benchmark for African Languages},
author={Muhammad, Shamsuddeen Hassan and others},
booktitle={EMNLP},
year={2023}
}
MIT License
18 commits
Python
92.5%
Shell
7.5%