File size: 7,546 Bytes
e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 e88a90a 9291173 cfd5aaa 9291173 cfd5aaa 50fab05 9291173 e88a90a 9291173 e88a90a 9291173 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | ---
language:
- multilingual
- tr
- fi
- ko
- ja
- az
- kk
- et
- mn
- ka
- ta
- te
- ml
- sw
- xh
- ru
- pl
- cs
- uk
- en
- vi
- zh
- id
- fr
- es
- de
tags:
- mbart-50
- morphbart
- morphology
- agglutinative
- seq2seq
- machine-translation
- coling2027
pipeline_tag: translation
license: mit
---
# MorphBART-Base: Intra-Word Structural Biases for Agglutinative Neural Machine Translation
MorphBART-Base is a sequence-to-sequence foundation checkpoint designed to mitigate subword fragmentation and morphological hallucination in Neural Machine Translation (NMT). It introduces vocabulary-preserving morphological inductive biases directly into the pretrained encoder of [facebook/mbart-large-50-many-to-many-mmt](https://huggingface.co/facebook/mbart-large-50-many-to-many-mmt).
Standard multilingual Transformers process statistical subwords via uniform self-attention, ignoring orthographic word boundaries and morphological composition. MorphBART enforces intra-word structural cohesion and boundary-aware representation learning in the early encoder layers without altering the underlying SentencePiece vocabulary or pretrained weights.
---
## Intended Use and Typological Scope
MorphBART is engineered primarily for translation scenarios from **morphologically rich and agglutinative source languages ($X$)** into **isolating or analytic target languages ($Y$)**:
$$\text{Agglutinative / Synthetic } (X) \longrightarrow \text{Isolating / Analytic } (Y)$$
### Recommended Source Languages ($X$)
The model's architectural priors provide the highest utility on languages characterized by productive affixation, synthetic inflection, and high morpheme-per-word ratios:
- **Turkic Family:** Turkish (`tr_TR`), Azerbaijani (`az_AZ`), Kazakh (`kk_KZ`)
- **Uralic Family:** Finnish (`fi_FI`), Estonian (`et_EE`)
- **Koreanic and Japonic:** Korean (`ko_KR`), Japanese (`ja_XX`)
- **Dravidian Family:** Tamil (`ta_IN`), Telugu (`te_IN`), Malayalam (`ml_IN`)
- **Mongolic and Kartvelian:** Mongolian (`mn_MN`), Georgian (`ka_GE`)
- **Bantu Family:** Swahili (`sw_KE`), Xhosa (`xh_ZA`)
- **Synthetic Slavic / Baltic:** Russian (`ru_RU`), Polish (`pl_PL`), Czech (`cs_CZ`), Ukrainian (`uk_UA`)
### Recommended Target Languages ($Y$)
- **Analytic / Isolating:** English (`en_XX`), Vietnamese (`vi_VN`), Chinese (`zh_CN`), Indonesian (`id_ID`), French (`fr_XX`), Spanish (`es_XX`), German (`de_DE`).
**Linguistic Rationale:** In agglutinative languages, grammatical markers (tense, aspect, modality, voice, negation, and case) are concatenated sequentially onto stems. When tokenizers split these words into arbitrary fragments, standard attention often decouples affixes from roots. MorphBART constrains early representations to preserve morphemic envelopes, preventing grammatical inversion and inflectional omissions in the translated output.
---
## Architectural Specification
MorphBART adds an exact parameter overhead of only **$+0.34\%$** ($+2.11\text{M}$ parameters over the $611\text{M}$ backbone) with negligible inference overhead:
1. **Fast GPU BMES Boundary Extractor:** Directly processes SentencePiece token indices on GPU via vectorized prefix scans to derive Begin ($\text{B}$), Middle ($\text{M}$), End ($\text{E}$), and Single ($\text{S}$) morpheme states in $O(\log T)$ parallel step depth.
2. **Adaptive Boundary-Token Fusion:** Learns continuous boundary representations ($E_{\text{bmes}} \in \mathbb{R}^{6 \times 1024}$) and dynamically injects them into subword embeddings through a conservative gated residual projection ($\beta_g = -2.5$).
3. **Intra-Word Morphological Attention (IWMA):** Modulates scaled dot-product attention logits with a structural reward ($\alpha = 0.5$) strictly within early encoder layers ($1\text{--}2$):
$$S_{ij} = \frac{Q_i K_j^T}{\sqrt{d_k}} + \alpha \cdot M_{ij}$$
where $M_{ij} \in \{0, 1\}$ indicates whether tokens $i$ and $j$ belong to the same orthographic word envelope.
---
## Usage
### Loading Checkpoint and Inference
The checkpoint can be initialized using the wrapper implementation from the official repository:
```python
import torch
from transformers import AutoTokenizer
from src.models.morph_bart import MorphBARTForConditionalGeneration
model_id = "NIRVLab/MorphBART-base"
device = "cuda" if torch.cuda.is_available() else "cpu"
dtype = torch.bfloat16 if (torch.cuda.is_available() and torch.cuda.is_bf16_supported()) else torch.float32
# Load tokenizer and backbone wrapper
tokenizer = AutoTokenizer.from_pretrained(model_id, src_lang="tr_TR", tgt_lang="en_XX")
model = MorphBARTForConditionalGeneration.from_pretrained(
model_id,
tokenizer=tokenizer,
torch_dtype=dtype
).to(device)
# Example: Turkish to English
input_text = "Bu yöntem morfolojik yapıları daha başarılı bir şekilde öğrenir."
inputs = tokenizer(input_text, return_tensors="pt").to(device)
with torch.no_grad():
generated_ids = model.generate(
inputs.input_ids,
forced_bos_token_id=tokenizer.convert_tokens_to_ids("en_XX"),
max_length=64,
num_beams=4
)
translation = tokenizer.decode(generated_ids[0], skip_special_tokens=True)
print(translation)
```
---
## Downstream Fine-Tuning
### To adapt this base checkpoint to specific agglutinative-to-analytic language pairs, use the standard Hugging Face Seq2SeqTrainer:
```python
import torch
from transformers import Seq2SeqTrainer, Seq2SeqTrainingArguments, DataCollatorForSeq2Seq
training_args = Seq2SeqTrainingArguments(
output_dir="./checkpoints/morphbart-finetuned",
num_train_epochs=5,
per_device_train_batch_size=32,
gradient_accumulation_steps=8,
learning_rate=2e-5,
warmup_ratio=0.06,
weight_decay=0.01,
label_smoothing_factor=0.1,
bf16=torch.cuda.is_available() and torch.cuda.is_bf16_supported(),
save_strategy="epoch",
evaluation_strategy="epoch",
save_total_limit=1,
predict_with_generate=True,
report_to="none"
)
trainer = Seq2SeqTrainer(
model=model,
args=training_args,
train_dataset=tokenized_train,
eval_dataset=tokenized_eval,
processing_class=tokenizer,
data_collator=DataCollatorForSeq2Seq(tokenizer, model=model.model, pad_to_multiple_of=8)
)
trainer.train()
trainer.save_model("./checkpoints/morphbart-finetuned")
```
---
## Benchmark Results
Fine-tuning results on established academic benchmarks demonstrate consistent, statistically significant improvements (p < 0.001) over standard mBART-50 fine-tuning:
| Language Pair | Benchmark | Domain | Baseline (BLEU / chrF++) | MorphBART (BLEU / chrF++) | Absolute Gain (Delta) |
|:---|:---|:---|---:|---:|---:|
| Turkish → English | OPUS-100 | Web Crawl | 23.05 / 41.83 | **24.13 / 43.06** | **+1.08 / +1.23** |
| Turkish → English | FLORES-200 | News / Wiki | 29.98 / 55.22 | **30.43 / 56.01** | **+0.45 / +0.79** |
| Turkish → English | Tatoeba | Conversational | 44.17 / 60.58 | **45.37 / 61.76** | **+1.20 / +1.18** |
| Finnish → English | OPUS-100 | Web Crawl | 22.14 / 42.05 | **23.11 / 43.12** | **+0.97 / +1.07** |
| Finnish → English | FLORES-200 | News / Wiki | 26.85 / 54.12 | **27.32 / 54.78** | **+0.47 / +0.66** |
---
## Citation
```bibtex
@article{tang2020multilingual,
title = {Multilingual Translation with Extensible Multilingual Pretraining and Finetuning},
author = {Tang, Yuqing and Tran, Chau and Li, Xian and Chen, Peng-Jen and Goyal, Naman and Chaudhary, Vishrav and Gu, Jiatao and Fan, Angela},
journal = {arXiv preprint arXiv:2008.00401},
year = {2020}
}
```
|