Views
No views yet
Production-ready bilingual translation model optimized for English ↔ Indonesian (bidirectional) through vocabulary pruning and continual fine-tuning with GaLore memory-efficient optimization.
| Technique | Purpose | Impact |
|---|---|---|
| Leaf-Based Frequency Pruning | Remove unused vocabulary tokens | 56% vocab reduction (256K → 87K) |
| Embedding Remapping | Align embeddings with pruned vocab | Maintains token representations |
| Token Batching | Fairseq-style --max-tokens training | 2-3× GPU throughput improvement |
| GaLore Optimization | Memory-efficient fine-tuning | Full fine-tuning on 2× T4 GPUs |
| Attribute | Value |
|---|---|
| Base Architecture | M2M100 (Encoder-Decoder) |
| Base Model | facebook/nllb-200-distilled-600M |
| Vocabulary Size | 86,915 tokens (pruned from 256,204) |
| Hidden Size | 1,024 |
| Encoder/Decoder Layers | 12 / 12 |
| Attention Heads | 16 |
| FFN Dimension | 4,096 |
| Total Parameters | 441,719,808 (~442M) |
| Tied Embeddings | Yes (shared encoder/decoder/lm_head) |
| Max Sequence Length | 2,048 tokens |
| Supported Pairs | eng_Latn ↔ ind_Latn |
eng_Latn, ind_Latn)| Direction | sacreBLEU | chrF++ | Status |
|---|---|---|---|
| EN → ID | 42.71 | 66.68 | ✅ Fine-tuned |
| ID → EN | 37.87 | 63.04 | ✅ Fine-tuned |
| EN → ID (original) | 41.21 | 65.65 | Baseline |
| ID → EN (original) | 39.43 | 63.66 | Baseline |
Note: The fine-tuned model shows improvement on EN→ID (+1.5 BLEU) while maintaining competitive ID→EN performance. The slight ID→EN decrease is expected when specializing a multilingual model for a single pair.
| Metric | Original | Pruned | Improvement |
|---|---|---|---|
| Vocabulary Size | 256,204 | 86,915 | -66% |
| Embedding Parameters | ~262M | ~89M | -66% |
| Model File Size | ~2.4 GB | ~1.65 GB | -31% |
| Active Parameters | ~600M | ~442M | -26% |
| Inference Latency | Baseline | ~15% faster | +15% |
1from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
2import torch
3# Load model and tokenizer
4model_name = "ik4545/nllb-indo-bilingual"
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForSeq2SeqLM.from_pretrained(model_name)
7def translate(text: str, src_lang: str, tgt_lang: str) -> str:
8 """Translate text between English and Indonesian."""
9 tokenizer.src_lang = src_lang
10 inputs = tokenizer(text, return_tensors="pt", truncation=True, max_length=512)
11 # Get forced BOS token for target language
12 forced_bos_token_id = tokenizer.convert_tokens_to_ids(tgt_lang)
13 with torch.no_grad():
14 outputs = model.generate(
15 **inputs,
16 forced_bos_token_id=forced_bos_token_id,
17 max_length=256,
18 num_beams=4,
19 early_stopping=True,
20 length_penalty=1.0,
21 )
22 return tokenizer.decode(outputs[0], skip_special_tokens=True)
23# English → Indonesian
24en_text = "Artificial intelligence is rapidly advancing in Indonesia."
25id_translation = translate(en_text, "eng_Latn", "ind_Latn")
26print(f"EN → ID: {id_translation}")
27# Output: "Kecerdasan buatan semakin berkembang pesat di Indonesia."
28# Indonesian → English
29id_text = "Pemerintah mengumumkan kebijakan baru tentang pendidikan."
30en_translation = translate(id_text, "ind_Latn", "eng_Latn")
31print(f"ID → EN: {en_translation}")
32# Output: "The government announced new policies regarding education."1from transformers import pipeline
2# English to Indonesian
3en_to_id = pipeline(
4 "translation",
5 model="ik4545/nllb-indo-bilingual",
6 src_lang="eng_Latn",
7 tgt_lang="ind_Latn",
8 device=0 # Use GPU if available
9)
10result = en_to_id("The weather is very nice today.")
11print(result[0]["translation_text"])| Language | Code | Direction |
|---|---|---|
| English | eng_Latn | Source & Target |
| Indonesian | ind_Latn | Source & Target |
| Hyperparameter | Value |
|---|---|
| Optimizer | GaLoreAdamW (attention/FFN) + AdamW (embeddings) |
| GaLore Rank | 128 |
| Learning Rate (GaLore) | 5e-4 |
| Learning Rate (Embeddings) | 1e-4 |
| Batch Strategy | Token Batching (max 16,384 tokens/GPU) |
| Gradient Accumulation | 8 steps |
| Training Epochs | 2 |
| Label Smoothing | 0.0 |
| Hardware | 2× NVIDIA Tesla T4 (16GB VRAM) |
| Framework | PyTorch DDP + HuggingFace Transformers |
--max-tokens for optimal GPU utilizationforced_bos_token_id to be set correctly for target language. Without it, the model may generate output in an incorrect language..
├── config.json # Model configuration
├── tokenizer_config.json # Tokenizer settings
├── tokenizer.json # Fast tokenizer (BPE)
├── special_tokens_map.json # Special token mappings
├── model.safetensors # Model weights (~1.65 GB)
├── generation_config.json # Generation defaults
└── README.md # This file1@misc{nllb-indo-bilingual-2026,
2 title={NLLB-Indo-Bilingual: Efficient Bilingual Translation via Vocabulary Pruning and GaLore Fine-Tuning},
3 author={ik4545},
4 year={2026},
5 howpublished={\url{[https://huggingface.co/ik4545/nllb-indo-bilingual](https://huggingface.co/ik4545/nllb-indo-bilingual)}}
6}
7@article{nllb2022,
8 title={No Language Left Behind: Scaling Human-Centered Machine Translation},
9 author={Costa-jussà, Marta R. and Cross, James and Çelebi, Onur and Elbayad, Maha and Heafield, Kenneth and Heffernan, Kevin and Kalbassi, Elahe and Lam, Janice and Licht, Daniel and Maillard, Jean and Sun, Anna and Wang, Skyler and Wenzek, Guillaume and Youngblood, Al and Akula, Bapi and Barrault, Loïc and González, Gabriel Mejía and Hansanti, Prangthip and Hoffman, John and Jarrett, Semarley and Sadagopan, Kaushik Ram and Rowe, Dirk and Spruit, Shannon and Tran, Chau and Andrews, Pierre and Ayan, Necip Fazil and Bhosale, Shruti and Edunov, Sergey and Fan, Angela and Gao, Cynthia and Goswami, Vedanuj and Guzmán, Francisco and Koehn, Philipp and Mourachko, Alexandre and Ropers, Christophe and Saleem, Safiyyah and Schwenk, Holger and Wang, Jeff},
10 journal={arXiv preprint arXiv:2207.04672},
11 year={2022}
12}
13@article{purason2026,
14 title={Teaching Old Tokenizers New Words: Leaf-Based Vocabulary Pruning for Multilingual Models},
15 author={Purason, T. and others},
16 journal={arXiv preprint arXiv:2512.03989v2},
17 year={2026}
18}
19@article{zhao2024galore,
20 title={GaLore: Memory-Efficient LLM Training by Gradient Low-Rank Projection},
21 author={Zhao, J. and others},
22 journal={arXiv preprint arXiv:2403.03507},
23 year={2024}
24}