Swahili-English Translation Model (General Domain Expansion v2)
This model is a fine-tuned version of openchs/sw-en-opus-mt-mul-en-v1 designed to excel at both general Swahili-English translation and specialized helpline/crisis support conversations. It uses a domain-aware training approach with explicit domain tags to maintain high performance across different contexts.
Model Details
Basic Information
Model Type: MarianMT Neural Machine Translation
Base Model: openchs/sw-en-opus-mt-mul-en-v1 (Helsinki-NLP/opus-mt architecture)
Language Pair: Swahili (sw) → English (en)
Version: 2.0 (General Domain Expansion)
Training Approach: Domain-aware fine-tuning with knowledge distillation
Key Features
Domain-Aware Architecture: Uses <HELPLINE> and <GENERAL> tags for context-specific translation
Dual-Domain Optimization: Maintains specialized helpline performance while expanding general capabilities
Knowledge Distillation: Learned from a teacher model specialized in helpline translations
Production-Ready: Meets greater than 96% helpline retention and greater than 120% general improvement thresholds
The model uses CPU-offloaded knowledge distillation to learn from a specialized helpline model:
Total Loss = (1 - α) × Standard Loss + α × Distillation Loss
Parameters:
Distillation Alpha (α): 0.3-0.5
Temperature (T): 2.0
Method: KL divergence with soft targets
Teacher Location: CPU (moved to GPU only during forward pass)
Memory Savings:
Approximately 3.5GB GPU memory saved through CPU offloading
30-40% memory reduction with gradient checkpointing
Domain-Aware Training
Each training sample is tagged with its domain:
python
1# Helpline domain2Input:"<HELPLINE> Ninahitaji msaada wa haraka"3Output:"I need urgent help"45# General domain6Input:"<GENERAL> Habari za asubuhi"7Output:"Good morning"
Domain Tag Benefits:
Explicit context signaling
Prevents catastrophic forgetting
Enables domain-specific optimization
Evaluation Strategy
Dual-Domain Evaluation (every 2000 steps):
Test Set
Samples
Metrics
Helpline Domain
500
BLEU, chrF, Keyword Preservation
General Domain
2000
BLEU, chrF
Evaluation Metrics:
BLEU Score: Primary translation quality metric
chrF Score: Character-level evaluation
Keyword Preservation: Critical term accuracy (helpline only)
Domain Retention Rate: Helpline performance vs. baseline
Domain Improvement Rate: General performance vs. baseline
Performance
Baseline vs. Final Results
Domain
Baseline BLEU
Final BLEU
Change
Helpline
X.XXXX
X.XXXX
+X.X% (XX.X% retention)
General
X.XXXX
X.XXXX
+XX.X% (XXX.X% improvement)
Replace with actual metrics from your training run
Production Readiness Criteria
Production Status: READY
Helpline Retention: Greater than or equal to 96% of baseline
General Improvement: Greater than or equal to 120% of baseline
Sample Translations
General Domain:
SW: Habari za asubuhi, ninatumaini uko vizuri
EN: Good morning, I hope you are well
SW: Nina furaha kukuona tena
EN: I'm happy to see you again
Helpline Domain:
SW: Ninahitaji msaada wa haraka
EN: I need urgent help
SW: Mtoto wangu yupo hatarini
EN: My child is in danger
Usage
Basic Translation
python
1from transformers import MarianMTModel, MarianTokenizer
23# Load model and tokenizer4model_name ="brendaogutu/sw-en-opus-mt-general-expanded"5tokenizer = MarianTokenizer.from_pretrained(model_name)6model = MarianMTModel.from_pretrained(model_name)78# For general translations9text ="<GENERAL> Habari za asubuhi"10inputs = tokenizer(text, return_tensors="pt", padding=True)11outputs = model.generate(**inputs, max_length=512, num_beams=4)12translation = tokenizer.decode(outputs[0], skip_special_tokens=True)13print(translation)# "Good morning"1415# For helpline/crisis translations16text ="<HELPLINE> Ninahitaji msaada wa haraka"17inputs = tokenizer(text, return_tensors="pt", padding=True)18outputs = model.generate(**inputs, max_length=512, num_beams=4)19translation = tokenizer.decode(outputs[0], skip_special_tokens=True)20print(translation)# "I need urgent help"
1# The model will default to GENERAL behavior if no tag is provided2text ="Habari za asubuhi"3inputs = tokenizer(text, return_tensors="pt", padding=True)4outputs = model.generate(**inputs, max_length=512, num_beams=4)5translation = tokenizer.decode(outputs[0], skip_special_tokens=True)
Training Infrastructure
Compute Requirements
Hardware Used: Single NVIDIA A100 40GB / V100 32GB GPU with CPU support
Training Time: Approximately 22 hours (6 epochs on ~240k samples)
Peak Memory Usage: ~35GB GPU + 16GB CPU (with optimizations)
Storage Required: ~50GB (datasets and checkpoints)
General translation needs in Swahili-speaking regions
Potential Risks
Translation Errors: May produce incorrect translations; human review recommended for critical applications
Bias: May reflect biases present in training data
Crisis Situations: Should not replace trained human operators in life-threatening emergencies
Privacy: Ensure compliance with data protection regulations when processing sensitive content
Responsible Use Guidelines
Always have human oversight for crisis/emergency translations
Do not rely solely on automated translation for legal or medical decisions
Be aware of cultural context that may not be captured in direct translation
Regularly evaluate performance on your specific use case
Implement appropriate safeguards for sensitive content
Training Pipeline Details
Dataset Preparation Flow
Raw Data → Token Filtering → Deduplication → Domain Tagging →
Tokenization → Train/Val Split → Training
Training Flow
Load Base Model → Add Domain Tags → Load Datasets →
Apply Filtering → Baseline Evaluation → Training Loop →
Domain Evaluation (every 2000 steps) → Final Evaluation →
Save and Register Model
Quality Filters Applied
Minimum length: 3 tokens
Maximum length: 512 tokens
Maximum length ratio: 3.5:1
Duplicate removal
Encoding validation
Reproducibility
Experiment Tracking
All training runs tracked with:
MLflow experiment tracking
Versioned configuration files
Dataset composition statistics
Training metrics logging
Model checkpoints and metadata
Random Seeds
Data shuffling seed: 42
Train/test split seed: 42
Deterministic training where possible
Configuration
Complete training configuration available in repository:
configs/swahili_v1.json: Full hyperparameters
Training scripts with all optimization flags
Dataset preparation pipeline
Citation
If you use this model in your research or applications, please cite:
bibtex
1@misc{ogutu2025swahili-en-general-expanded,
2 author = {Ogutu, Brenda},
3 title = {Swahili-English General Domain Translation Model with Helpline Specialization},
4 year = {2025},
5 publisher = {HuggingFace},
6 journal = {HuggingFace Model Hub},
7 howpublished = {\url{https://huggingface.co/brendaogutu/sw-en-opus-mt-general-expanded}},
8 note = {Fine-tuned with domain-aware training and knowledge distillation}
9}
License
This model inherits the Apache 2.0 license from Helsinki-NLP/opus-mt-mul-en.
Acknowledgments
Base Model: Helsinki-NLP for the opus-mt architecture
Training Data: CCAligned corpus for general translations