transformer_18_18 architecture (18 encoder + 18 decoder layers) trained with fairseq and converted to the HuggingFace MBart format.⚠️ Tokenization Warning: OneNMT v3b uses a custom fairseq dictionary (fairseq_dict.json) for token ID mapping. UsingAutoTokenizeror any standard MBart tokenizer will produce wrong IDs and garbled output. Always use the providedhf_inference.pyor thetranslate_onemt()wrapper.
| Property | Value |
|---|---|
| Architecture | transformer_18_18 (MBartForConditionalGeneration wrapper) |
| Encoder / Decoder layers | 18 + 18 |
| Hidden size | 1024 |
| Attention heads | 16 |
| Parameters | ~1.1B |
| Positional embeddings | Sinusoidal (not learned), max 256 positions |
| Normalization | Pre-norm (normalize_before=True) |
| Vocabulary | 65,400 tokens (fairseq dictionary ordering) |
| Language tag format | ###src_flores-to-tgt_flores### {text} |
| Decoder start token | EOS (id=2) — fairseq convention |
| Short Code | Language | Script | FLORES-200 Code |
|---|---|---|---|
eng | English | Latin | eng_Latn |
hin | Hindi | Devanagari | hin_Deva |
tel | Telugu | Telugu | tel_Telu |
tam | Tamil | Tamil | tam_Taml |
mal | Malayalam | Malayalam | mal_Mlym |
kan | Kannada | Kannada | kan_Knda |
ben | Bengali | Bengali | ben_Beng |
guj | Gujarati | Gujarati | guj_Gujr |
mar | Marathi | Devanagari | mar_Deva |
pan | Punjabi | Gurmukhi | pan_Guru |
urd | Urdu | Arabic | urd_Arab |
asm | Assamese | Bengali | asm_Beng |
npi | Nepali | Devanagari | npi_Deva |
ory | Odia | Odia | ory_Orya |
san | Sanskrit | Devanagari | san_Deva |
mai | Maithili | Devanagari | mai_Deva |
brx | Bodo | Devanagari | brx_Deva |
doi | Dogri | Devanagari | doi_Deva |
gom | Konkani | Devanagari | gom_Deva |
mni | Meitei | Bengali | mni_Beng |
sat | Santali | Ol Chiki | sat_Olck |
kas | Kashmiri | Arabic | kas_Arab |
snd | Sindhi | Arabic | snd_Arab |
pip install -r requirements.txt1from hf_inference import translate_onemt, translate_batch
2
3# Single sentence — English → Telugu
4print(translate_onemt("Hello, how are you?", "eng", "tel"))
5# హలో, మీరు ఎలా ఉన్నారు?
6
7# Code-mixed Hindi → Telugu
8print(translate_onemt("मुझे meeting attend करनी है।", "hin", "tel"))
9# నాకు మీటింగ్కు హాజరు కావాలి.
10
11# Telugu → English
12print(translate_onemt("నమస్కారం, మీరు ఎలా ఉన్నారు?", "tel", "eng"))
13# Hello, how are you?
14
15# Tamil → Hindi
16print(translate_onemt("இன்று வானிலை நன்றாக உள்ளது.", "tam", "hin"))
17# आज मौसम अच्छा है।
18
19# Batch translation
20sentences = ["Good morning.", "Thank you.", "See you tomorrow."]
21results = translate_batch(sentences, sl="eng", tl="hin", batch_size=32)
22for src, tgt in zip(sentences, results):
23 print(f"{src} → {tgt}")source text
→ prepend language tag: ###eng_Latn-to-tel_Telu### {text}
→ SentencePiece encoding → subword pieces
→ fairseq dict lookup → integer IDs ← NOT SPM-native IDs
→ MBart encoderT is ID 29 in the fairseq dict but ID 35376 via the HF tokenizer. Wrong IDs → wrong embeddings → garbled output.hf_inference.py script handles this correctly using onemtv3b_spm.model for segmentation and fairseq_dict.json for ID lookup.| File | Description |
|---|---|
model.safetensors | Model weights |
config.json | HF model architecture config |
generation_config.json | Default generation parameters |
fairseq_dict.json | Required — fairseq vocab ID mapping (piece → ID) |
onemtv3b_spm.model | Required — SentencePiece model for subword segmentation |
hf_inference.py | Ready-to-use inference script |
tokenizer.json,tokenizer_config.json,special_tokens_map.jsonare present for HF Hub format compliance but must not be used for inference — they produce incorrect token IDs due to the SPM vs fairseq ordering mismatch described above.
| Parameter | Value | Notes |
|---|---|---|
decoder_start_token_id | 2 | EOS token — fairseq convention (not BOS) |
forced_bos_token_id | None | No forced BOS |
num_beams | 5 | Beam search |
max_new_tokens | 256 | Matches model's trained max position |
no_repeat_ngram_size | 3 | Reduces repetition |
repetition_penalty | 1.3 | Additional repetition control |
1@misc{mujadia2025bhashaversetranslationecosystem,
2 title={BhashaVerse : Translation Ecosystem for Indian Subcontinent Languages},
3 author={Vandan Mujadia and Dipti Misra Sharma},
4 year={2025},
5 eprint={2412.04351},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2412.04351},
9}