license: cc-by-nc-4.0 language: - en - km base_model: facebook/nllb-200-distilled-600M pipeline_tag: translation tags: - legal - khmer - translation - nllb - refugee - humanitarian - denoising
Khmer Legal Bridge - NLLB Fine-tuned for Legal Translation
English-Khmer Bidirectional Translation Model for legal and humanitarian Documents
Model Description
This model is a fine-tuned version of facebook/nllb-200-distilled-600M optimized for legal document translation between English and Khmer. It was developed to support Cambodian refugees, asylum seekers, and legal professionals who need accurate translations of legal materials.
Intended Use
- Translation of legal documents (court documents, asylum applications, legal handbooks)
- Refugee and immigration documentation
- Juvenile justice materials
- Human rights reports and policy documents
Languages
- English (eng_Latn)
- Khmer (khm_Khmr)
Evaluation Results
| Direction | chrF | BLEU |
|---|---|---|
| EN to KM | 53.28 | 29.38 |
| KM to EN | 59.68 | 34.78 |
Comparison with Base Model
| Direction | Metric | Base NLLB | Fine-tuned | Change |
|---|---|---|---|---|
| KM to EN | chrF | 55.98 | 59.68 | +3.70 |
| KM to EN | BLEU | 28.35 | 34.78 | +6.43 |
| EN to KM | chrF | 54.48 | 53.28 | -1.20 |
Key Results
- Balanced bidirectional performance: Both directions now perform well
- KM to EN significantly improved: +3.7 chrF, +6.4 BLEU
- EN to KM chrF slightly lower: Small trade-off for better overall balance
Training Pipeline
Phase 1.5: Denoising Pre-training
Before translation fine-tuning, we strengthened the model's Khmer understanding using a denoising autoencoder task on 88,000+ monolingual Khmer examples:
| Dataset | Size | Source | Content |
|---|---|---|---|
| khPOS | ~12,000 | Khmer POS Corpus | News, politics, economics - professionally segmented with POS tags |
| Khmer Dictionary 44K | ~44,700 | Royal Academy of Cambodia (2022) | Curated definitions, formal register |
Denoising Task:
- Input: Corrupted Khmer text (15% noise: masking, deletion, token shuffling)
- Output: Clean original text
- Both encoder AND decoder trained
Phase 1: Bidirectional Translation Fine-tuning
Using the denoising-pretrained model, we fine-tuned on ~389,000 parallel examples (bidirectional):
| Dataset | Pairs | Bidirectional Examples |
|---|---|---|
| ALT Corpus | 18,088 | 36,176 |
| OPUS-100 | ~112,000 | ~224,000 |
| ParaCrawl | ~65,000 | ~130,000 |
Training Results:
| Phase | Metric | Start | End | Improvement |
|---|---|---|---|---|
| 1.5 Denoising | Val Loss | ~4.9 | ~2.5 | -49% |
| 1 Translation | Val Loss | 3.804 | 2.586 | -32% |
Training Configuration:
- Epochs: 3
- Batch size: 32 effective
- Learning rate: 2e-5
- Training time: ~13.5 hours on Google Colab (A100)
Usage
from transformers import AutoModelForSeq2SeqLM, NllbTokenizerFast
import torch
# Load model and tokenizer
model_id = "ClaudBarbara/Open_Access_Khmer"
model = AutoModelForSeq2SeqLM.from_pretrained(model_id)
tokenizer = NllbTokenizerFast.from_pretrained(model_id)
def translate(text, src_lang, tgt_lang):
tokenizer.src_lang = src_lang
inputs = tokenizer(text, return_tensors="pt", max_length=512, truncation=True)
with torch.no_grad():
outputs = model.generate(
**inputs,
forced_bos_token_id=tokenizer.convert_tokens_to_ids(tgt_lang),
max_length=512,
num_beams=4
)
return tokenizer.decode(outputs[0], skip_special_tokens=True)
# English to Khmer
result = translate("The court finds the defendant guilty.", "eng_Latn", "khm_Khmr")
# Khmer to English
result = translate("<your_khmer_text>", "khm_Khmr", "eng_Latn")
TRANSLATION EXAMPLES
ENGLISH → KHMER TESTS
🇬🇧 EN: The court finds the defendant guilty.
🇰🇭 KM: តុលាការ បាន រក ឃើញ ថា ជន ជាប់ ចោទ មាន កំហុស ។
Backwards: The court found the accused guilty.
🇬🇧 EN: In addition, authorities, especially provincial authorities, are not aware of the law and apply outdated provisions to restrict NGO meetings and peaceful community demonstrations.
🇰🇭 KM: លើស ពី នេះ ទៅ ទៀត អាជ្ញាធរ ជា ពិសេស អាជ្ញាធរ ខេត្ត មិន បាន ដឹង ពី ច្បាប់ នេះ ទេ និង អនុវត្ត សេចក្តី ព្រាង ចាស់ ៗ ដើម្បី ដាក់ កម្រិត កិច្ច ប្រជុំ របស់ អង្គ ការ មិនមែន រដ្ឋាភិបាល និង ការ ធ្វើ បាតុកម្ម ដោយ សន្តិវិធី របស់ សហគមន៍ ។
Backwards: In addition, authorities, especially provincial authorities, are unaware of the law and apply the old regulations to restrict meetings of non-governmental organizations and peaceful demonstrations of communities.
🇬🇧 EN: Human rights are protected by law.
🇰🇭 KM: សិទ្ធិ មនុស្ស ត្រូវ បាន ការពារ ដោយ ច្បាប់ ។
Backwards: Human rights are protected by law.
🇬🇧 EN: The refugee seeks asylum in Australia.
🇰🇭 KM: ជនភៀសខ្លួននេះបានស្វែងរកសិទ្ធិជ្រកកោននៅប្រទេសអូស្ត្រាលី។
Backwards: The refugee sought asylum in Australia.
🇬🇧 EN: Lesson 8: Ensuring that children receive information and guidance, hygiene and sanitation, nutrition, care for children, providing food and drinks, receiving vaccines, maintaining personal hygiene, learning from experiences, fostering social interactions, observing surroundings, participating in community activities, protecting children from danger and harm, and handling various situations.
🇰🇭 KM: Lesson 8: ការធានាថាកុមារទទួលបានព័ត៌មាននិងការណែនាំ, អនាម័យនិងអនាម័យ, អាហារូបត្ថម្ភ, ការថែទាំកុមារ, ការផ្តល់អាហារនិងភេសជ្ជៈ, ការទទួលវ៉ាក់សាំង, ការថែទាំអនាម័យផ្ទាល់ខ្លួន, ការរៀនពីបទពិសោធន៍, ការលើកកម្ពស់ទំនាក់ទំនងសង្គម, ការសង្កេតមើលបរិស្ថាន, ការចូលរួមនៅក្នុងសកម្មភាពសហគមន៍, ការការពារកុមារពីគ្រោះថ្នាក់និងការប៉ះពាល់, និងការដោះស្រាយស្ថានភាពផ្សេងៗ
Backwards: Lesson 8: Ensuring children receive information and guidance, sanitation and hygiene, nutrition, childcare, food and beverage provision, vaccination, personal hygiene, learning from experience, social communication promotion, environmental observation, participation in community activities, protecting children from harm and exposure, and addressing various situations
KHMER → ENGLISH TESTS
🇰🇭 KM: អនីតិជនដែលប្រព្រឹត្តបទល្មើសត្រូវទទួលបានការការពារពីមេធាវី និងត្រូវបានជំនុំជម្រះក្នុងតុលាការអនីតិជន។
🇬🇧 EN: A minor who commits a crime is protected by a lawyer and is tried in a juvenile court.
Backwards: យុវជន ដែល ប្រព្រឹត្ត បទ ឧក្រិដ្ឋ ត្រូវ បាន ការពារ ដោយ មេធាវី ហើយ ត្រូវ បាន កាត់ ទោស នៅ តុលាការ យុវជន ។
🇰🇭 KM: ជនភៀសខ្លួនដែលមានការភ័យខ្លាចដែលមានមូលដ្ឋានត្រឹមត្រូវអំពីការធ្វើទុក្ខបុកម្នេញមានសិទ្ធិស្នើសុំសិទ្ធិជ្រកកោន។
🇬🇧 EN: Refugee with a well-founded fear of torture is eligible for asylum.
Backwardsk: ជនភៀសខ្លួនដែលមានការភ័យខ្លាចនៃការធ្វើទារុណកម្មដែលមានមូលដ្ឋានល្អមានសិទ្ធិទទួលសិទ្ធិជ្រកកោន។
🇰🇭 KM: ជនជាប់ចោទមានសិទ្ធិមិនទទួលស្គាល់កំហុស និងមានសិទ្ធិទទួលបានការជំនុំជម្រះយុត្តិធម៌។
🇬🇧 EN: Defendants have the right not to plead guilty and the right to a fair trial.
Backwards: ជន ជាប់ ចោទ មាន សិទ្ធិ មិន ទទួល ខុស ត្រូវ និង សិទ្ធិ ទទួល បាន ការ កាត់ ទោស ដោយ យុត្តិធម៌ ។
🇰🇭 KM: គោលការណ៍មិនបញ្ជូនត្រឡប់ទៅវិញហាមឃាត់រដ្ឋមិនឱ្យបណ្តេញបុគ្គលទៅប្រទេសដែលពួកគេអាចប្រឈមនឹងការធ្វើទារុណកម្ម។
🇬🇧 EN: The non-refoulement policy prohibits states from deporting individuals to countries where they may face torture.
Backwards: គោល នយោបាយ មិន ត្រឡប់ មក វិញ នេះ ហាម ឃាត់ រដ្ឋ មិន ឲ្យ បណ្តេញ បុគ្គល ទៅ កាន់ ប្រទេស ដែល ពួក គេ អាច ប្រឈម មុខ នឹង ការ ធ្វើ ទារុណ កម្ម ។
🇰🇭 KM: គ្រប់សេចក្តីសម្រេចដែលប៉ះពាល់ដល់កុមារត្រូវគិតគូរពីអត្ថប្រយោជន៍កុមារល្អបំផុតជាចម្បង។
🇬🇧 EN: Any decision that affects children must be based on the best interests of the child.
Backwards: ការ សម្រេច ចិត្ត ណា មួយ ដែល ប៉ះ ពាល់ ដល់ កុមារ ត្រូវ តែ ផ្អែក លើ ផល ប្រយោជន៍ ល្អ បំផុត របស់ កុមារ ។
🇰🇭 KM: ការឃុំខ្លួនមុនការជំនុំជម្រះត្រូវប្រើជាវិធានការចុងក្រោយសម្រាប់អនីតិជន។
🇬🇧 EN: Pre-trial detention shall be used as a last resort for minors.
Backwards: ការ ឃុំ ខ្លួន មុន ពេល កាត់ ក្តី នឹង ត្រូវ បាន ប្រើប្រាស់ ជា ដំណោះ ស្រាយ ចុង ក្រោយ សម្រាប់ អនីតិជន ។
🇰🇭 KM: តុលាការត្រូវពិចារណាភស្តុតាងទាំងអស់មុនពេលសម្រេចចិត្ត ហើយត្រូវផ្តល់ហេតុផលច្បាស់លាស់សម្រាប់សាលក្រម។
🇬🇧 EN: The court must consider all the evidence before making a decision and must give a clear reason for the verdict.
Backwards: តុលាការ ត្រូវ តែ ពិចារណា លើ ភស្តុតាង ទាំង អស់ មុន ពេល ធ្វើ ការ សម្រេច ចិត្ត និង ត្រូវ តែ ផ្តល់ ហេតុ ផល ច្បាស់លាស់ សំរាប់ ការ កាត់ ក្តី ។
🇰🇭 KM: ក្រសួងយុត្តិធម៌ត្រូវធានាថាអ្នកជាប់ឃុំទាំងអស់មានលទ្ធភាពទទួលបានជំនួយផ្លូវច្បាប់។
🇬🇧 EN: The Justice Department must ensure that all detainees have access to legal aid.
Backwards: ក្រសួង យុត្តិធម៌ ត្រូវ តែ ធានា ថា អ្នក ជាប់ ឃុំ ទាំង អស់ មាន សិទ្ធិ ទទួល បាន ជំនួយ ផ្លូវ ច្បាប់ ។
## Known Limitations
1. **Temporal bias**: The model tends to add past-tense markers in Khmer when translating present-tense English. This is being addressed in future training phases.
2. **Domain specificity**: Best results on legal and formal documents.
3. **Length**: Optimized for sentence-level translation (max 512 tokens).
## Ethical Considerations
This model is intended for humanitarian purposes. It should NOT replace certified human translators in official legal proceedings.
**Privacy**: Stateless processing - no input text is stored or logged.
## Roadmap
- [x] Phase 1.5: Denoising pre-training on 88K Khmer examples
- [x] Phase 1: Bidirectional translation fine-tuning on 389K examples
- [ ] Phase 2: LoRA fine-tuning on legal glossary (~5000 pairs and 450 terms that could work as hard constraints)
- [ ] Phase 3: Tense augmentation to address temporal bias
## Technical References
**Datasets:**
- khPOS: Ye Kyaw Thu et al., "Comparison of Six POS Tagging Methods on 12K Sentences Khmer Language POS Tagged Corpus" (ONA 2017)
- Khmer Dictionary 44K: Royal Academy of Cambodia, 2022
- ALT Corpus: Asian Language Treebank
**Model:**
- NLLB-200: Costa-jussa et al., "No Language Left Behind" (2022)
**Methodology:**
- Denoising: Lewis et al., "BART: Denoising Sequence-to-Sequence Pre-training" (2019)
## Citation
```bibtex
@misc{khmer-legal-bridge-2024,
title={Khmer Legal Bridge: Fine-tuned NLLB for Legal Translation},
author={ClaudBarbara},
year={2024},
publisher={HuggingFace},
url={https://huggingface.co/ClaudBarbara/Open_Access_Khmer}
}
Acknowledgments
Buoy, R., Taing, N., & Kor, S. (2021). Joint Khmer Word Segmentation and Part-of-Speech Tagging Using Deep Learning. Retrieved from https://arxiv.org/abs/2103.16801 Loem, M. (2021, May 4). Joint Khmer Word Segmentation and POS tagging. Medium. Retrieved from https://towardsdatascience.com/joint-khmer-word-segmentation-and-pos-tagging-cad650e78d30 Ye, K. T., Vichet, C., & Yoshinori, S. (2017). Comparison of Six POS Tagging Methods on 12K Sentences Khmer Language POS Tagged Corpus. First Regional Conference on Optical character recognition and Natural language processing technologies for ASEAN languages (ONA 2017). Retrieved from https://github.com/ye-kyaw-thu/khPOS/blob/master/khpos.pdf
License
CC-BY-NC-4.0
Khmer Legal Bridge - Open Source Legal Translation for Refugee Communities
- Downloads last month
- 10
Model tree for ClaudBarbara/Open_Access_Khmer
Base model
facebook/nllb-200-distilled-600M