nllb-600M-en-grt-bidirectional
nllb-600M-en-grt-bidirectional is a fine-tuned sequence-to-sequence neural machine translation model based on facebook/nllb-200-distilled-600M. It provides bidirectional translation between English and Garo (A·chik) using custom prefix control tokens: <2gr> for English-to-Garo and <2en> for Garo-to-English.
The model was trained on an enterprise-grade hybrid dataset combining contemporary journalistic translations from Meghalaya news archives with broader multi-domain parallel text, using oversampled gold-standard transcreations and statistically induced lexical anchors.
Model Details
- Base Architecture: NLLB-200 (
M2M100ForConditionalGeneration/ 600M parameters) - Languages Supported:
- English (
eng_Latn/ target token:<2en>) - Garo / A·chik (
grt/ target token:<2gr>)
- English (
- Vocabulary Expansion: 2 custom control tokens added (
<2en>,<2gr>) initialized from pretrainedeng_Latnrepresentations; total vocabulary size: 256,206. - Precision & Compute: bfloat16 + TensorFloat-32 (TF32) with PyTorch Scaled Dot-Product Attention (SDPA).
- License: Creative Commons Attribution-NonCommercial 4.0 International (
cc-by-nc-4.0), inheriting base model restrictions.
Intended Uses & Limitations
Intended Uses
- Bidirectional sentence and paragraph translation between English and Garo.
- Regional news and governmental document translation for Meghalaya and Northeast India.
- Data augmentation and synthetic backtranslation generation for low-resource NLP pipelines.
Limitations & Biases
- Morphological Sensitivity: Garo is an agglutinative language with extensive suffixation (e.g.,
-rang,-ko,-ona,-oniko). Low-frequency inflections or colloquial spoken dialects may exhibit subword fragmentation. - Orthographic Variations: Modern written Garo uses both the middle dot (
·, U+00B7) and the bullet (•, U+2022) to denote the glottal stop (raka). Inputs should ideally be normalized to standard Unicode·before inference. - Domain Focus: Strongest performance is on regional news, administration, social reporting, and current affairs. Highly technical, legal, or archaic biblical texts may see reduced accuracy.
How to Use
Load the model using transformers and pass the target control prefix (<2gr> or <2en>) at the beginning of the input text:
import torch
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
MODEL_ID = "Bapynshngain/nllb-600M-en-grt-bidirectional"
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID)
model = AutoModelForSeq2SeqLM.from_pretrained(
MODEL_ID,
torch_dtype=torch.bfloat16,
device_map="auto"
)
model.eval()
# Retrieve the internal token ID for forced BOS generation
eng_latn_id = tokenizer.convert_tokens_to_ids("eng_Latn")
def translate(text: str, direction: str = "en2gr", max_new_tokens: int = 128) -> str:
"""
Translates text between English and Garo.
direction: 'en2gr' (English -> Garo) or 'gr2en' (Garo -> English)
"""
prefix = "<2gr>" if direction == "en2gr" else "<2en>"
prompt = f"{prefix} {text}"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
generated_ids = model.generate(
**inputs,
forced_bos_token_id=eng_latn_id,
max_new_tokens=max_new_tokens,
num_beams=4,
early_stopping=True,
)
return tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
# --- Examples ---
# 1. English to Garo
en_sentence = "Chief Minister Conrad K Sangma inaugurated the new school building in Tura on Friday."
print("English -> Garo:")
print(translate(en_sentence, direction="en2gr"))
# 2. Garo to English
gr_sentence = "Sombar salo, Meghalaya a·dokni Skotong Minister Conrad K. Sangma, Tura-o gital skul nokko nokdonggae on·angaha."
print("\nGaro -> English:")
print(translate(gr_sentence, direction="gr2en"))
## Training and Evaluation Data
The training data was built using a hybrid data strategy designed to balance high-precision human translations with broad vocabulary coverage:
1. **Gold News Parallel Corpus (`Bapynshngain/Garo-corpus`)**:
- **28,593** pristine article and paragraph pairs extracted from Hub Network news archives via semantic cross-lingual matching (image fingerprints, temporal windowing, and invariant entity anchors).
- Oversampled **2×** in the training distribution to anchor core grammatical fluency and contemporary regional vocabulary.
- **1,500 pairs (3,000 bidirectional examples)** held out strictly for validation.
2. **General Parallel Corpus (`Bapynshngain/en-grt-parallel`)**:
- **36,151** deduplicated parallel sentence pairs providing domain and syntactic variety.
3. **Statistically Induced High-Frequency Lexicon**:
- High-confidence, noise-filtered bilingual dictionary entries induced via bidirectional IBM Model 1 Expectation-Maximization and symmetrized Dice coefficients.
### Dataset Split Summary
| Split | Unidirectional Pairs | Bidirectional Examples (`<2gr>` + `<2en>`) | Primary Source |
| :--- | :---: | :---: | :--- |
| **Train** | 90,389 (with 2× gold oversampling) | 180,778 | `Garo-corpus` (2×) + `en-grt-parallel` + Lexicon |
| **Validation** | 1,500 | 3,000 | Held-out clean news from `Garo-corpus` |
---
## Training Procedure
### Training Hyperparameters
- **Base Model:** `facebook/nllb-200-distilled-600M`
- **Epochs:** 5.0 (7,065 total optimization steps)
- **Per-Device Train Batch Size:** 16
- **Per-Device Eval Batch Size:** 32
- **Gradient Accumulation Steps:** 8 (Effective Batch Size = 128)
- **Learning Rate:** 5e-5
- **Learning Rate Scheduler:** Cosine decay with 423 warmup steps (6%)
- **Optimizer:** AdamW (`adamw_torch_fused`) with $\beta_1=0.9$, $\beta_2=0.999$, $\epsilon=10^{-8}$
- **Weight Decay:** 0.01
- **Sequence Length:** 256 tokens max
- **Mixed Precision:** Native `bf16` + `tf32`
- **Attention Mechanism:** PyTorch SDPA (Scaled Dot-Product Attention)
- **Activation Checkpointing:** Enabled (`gradient_checkpointing=True`)
### Evaluation Metrics Progression
Evaluation was conducted every 500 optimization steps on the 3,000 bidirectional held-out validation examples using beam search (`num_beams=2`):
| Step | Epoch | Training Loss (Raw / Step-Norm) | Validation Loss | BLEU | chrF++ | Notes |
| :---: | :---: | :---: | :---: | :---: | :---: | :--- |
| **500** | 0.354 | 31.39 / 3.924 | 3.7079 | 6.35 | 22.91 | Warmup phase |
| **1000** | 0.708 | 28.11 / 3.514 | 3.3572 | 8.08 | 24.93 | Rapid alignment convergence |
| **1500** | 1.062 | 27.28 / 3.410 | 3.2654 | 8.42 | 25.49 | |
| **2000** | 1.416 | 27.09 / 3.386 | 3.2271 | 8.63 | 25.72 | |
| **2500** | 1.770 | 27.14 / 3.393 | 3.2109 | 8.58 | 25.68 | |
| **3000** | 2.123 | 26.75 / 3.344 | 3.2036 | 8.70 | 25.83 | |
| **3500** | 2.477 | 27.00 / 3.375 | 3.2007 | 8.64 | 25.91 | |
| **4000** | 2.831 | 27.07 / 3.384 | 3.1994 | 8.70 | 25.87 | Loss plateau reached |
| **4500** | 3.185 | 26.84 / 3.355 | 3.1989 | 8.70 | 25.80 | |
| **5000** | 3.539 | 26.83 / 3.354 | 3.1988 | 8.72 | 25.93 | |
| **5500** | 3.893 | 26.70 / 3.337 | 3.1988 | **8.77** | **25.98** | **Best Checkpoint Selected** |
| **6000** | 4.246 | 26.81 / 3.351 | 3.1987 | 8.82 | 25.92 | Peak BLEU |
| **6500** | 4.600 | 26.81 / 3.351 | 3.1987 | 8.74 | 25.91 | |
| **7000** | 4.954 | 26.84 / 3.355 | 3.1987 | 8.73 | 25.95 | |
| **7065** | 5.000 | 26.87 / 3.359 | 3.1987 | 8.73 | 25.94 | Final step |
> **Note on Loss Values:** In `transformers` v5+, multi-step gradient accumulation logs the summed unscaled loss across accumulation cycles ($8 \times \text{per-batch loss}$). Normalized per-batch training loss settled at $\sim 3.35$, matching validation loss closely.
---
## Environmental & Compute Impact
- **Hardware:** 1× NVIDIA RTX A40 / RTX 6000 Ada (48GB VRAM)
- **Training Time:** ~2 hours 40 minutes (9,620 seconds)
- **Throughput:** ~93.96 samples/second (0.734 steps/second)
---
## Framework Versions
- **Python:** 3.12+
- **PyTorch:** 2.8.0+cu128
- **Transformers:** 5.22.1
- **Datasets:** 5.1.0
- **Tokenizers:** 0.23.3
- **SacreBLEU:** 2.5.1