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
- 43
Model tree for ClaudBarbara/Open_Access_Khmer
Base model
facebook/nllb-200-distilled-600M