Model research
Custom model fine-tuning
End-to-end custom model work: a labeled multilingual dataset, a disciplined architecture ablation, and a multi-task fine-tuned model.
Data
A 54,000-row multilingual dataset built via translation, validated with back-translation and similarity scoring, and independently reconstructed from raw annotations.
Modeling
Compared 6 model variants in an ablation ladder, from a pooled baseline to a custom attention-gated fusion architecture. One shared encoder handles 2 prediction tasks across 3 languages.
Rigor
The baseline, the 3-branch Final and the Proposed Architecture ran on two random seeds, every run was logged in a shared experiment tracker, and a fairness metric is reported next to raw accuracy.
Result
The final architecture improved both emotion F1 and a custom cross-lingual fairness metric, consistently across seeds. The training instability it introduced is reported, not hidden.
The dataset
Emotion datasets are mostly English, and translated data usually carries its errors straight into training. The first job was a multilingual version of GoEmotions in which every translation has a measured quality score.
Official splits kept
43,410 train, 5,426 validation and 5,427 test rows per language, matching GoEmotions.
Labels carried over
The 27 emotions, the 7 Ekman groups and a coarse 3-way sentiment label are copied unchanged through translation.
Measured, not trusted
Every translation is translated back and scored with LaBSE similarity, and anything below 0.80 is flagged, so quality is a number instead of an assumption.
Independently rebuilt
The dataset and its per-category label counts were reconstructed from the raw rater-level annotations and matched exactly.
Class imbalance, openly
Joy outnumbers fear 23.4 to 1. Class-balanced loss weights are computed once from the English distribution and reused for every language.
Known limit
The text is machine-translated, not naturally written, and the similarity score favours longer sentences, so it is a triage signal and not a precise error measure.
The model
One shared multilingual encoder serves two prediction tasks across three languages. Two parallel branches look at the sentence in different ways, a fusion bridge combines them, and each task has its own head on the same shared representation.
Training setup
| Setting | Value |
|---|---|
| Encoder | XLM-RoBERTa, shared across all three languages and both tasks |
| Optimiser | AdamW, learning rate 2e-5, weight decay 0.01, cosine schedule |
| Batch and length | Batch size 16, up to 10 epochs |
| Stopping | Early stopping after 3 epochs without validation improvement, so the epoch count is an upper bound |
| Loss | Class-balanced weights from the English label distribution |
| Stability | Gradient clipping, which the proposed architecture needed: the unclipped run diverged |
| Tracking | Every run logged to Weights & Biases, with a results ledger kept alongside |
The ablation ladder
Each stage adds one component to the baseline, with everything else held fixed. A second phase then removes components from the best model one at a time.
| Stage | Emotion F1 | Sentiment F1 | English | Hindi | Spanish | Gap ratio | Params |
|---|---|---|---|---|---|---|---|
| M1 · XLM-R baseline | 0.5133 | 0.6877 | 0.5554 | 0.5135 | 0.4667 | 0.8403 | 278M |
| M2 · + BiLSTM | 0.5180 | 0.6951 | 0.5667 | 0.5133 | 0.4690 | 0.8277 | 282M |
| M3 · + token attention | 0.5190 | 0.6883 | 0.5626 | 0.5191 | 0.4718 | 0.8386 | 282M |
| M4 · + context attention | 0.4988 | 0.7007 | 0.5529 | 0.4893 | 0.4496 | 0.8132 | 285M |
| M5 · + fusion bridge | 0.5062 | 0.7138 | 0.5633 | 0.4928 | 0.4576 | 0.8123 | 291M |
| M6 · adaptive gate | 0.5087 | 0.6935 | 0.5586 | 0.5028 | 0.4608 | 0.8249 | 289M |
| Final · gate removed | 0.5203 | 0.6947 | 0.5701 | 0.5074 | 0.4818 | 0.8452 | 291M |
Per-language columns are test-set emotion F1. The gap ratio is Spanish divided by English, so higher means more consistent across languages. Inference on 500 examples took 0.82 s for the baseline and 1.06 s for the fullest variant.
What did not work
Serial attention collapsed
Context attention stacked before token attention produced near-identical representations (cosine similarity about 0.997), so two layers did the work of one. Parallel branches replaced them.
The adaptive gate collapsed
It settled into a near-constant routing policy, and a fixed-weight version did the same. It was removed.
Task-specific heads lost
Separate projection heads for each task did worse than the shared representation.
Instability, reported
The best architecture needs gradient clipping to train at all. That is stated next to the result instead of left out.
Rigour
One change at a time
Hyperparameters and evaluation are identical at every stage, so any difference comes from the component just added.
Leave-one-out confirms
Each part of the best model is removed in turn to prove it earns its place.
Seeds, not single runs
The baseline, Final and Proposed models ran on two seeds, and run-to-run variance is reported. The consistent ranking across seeds is the finding, not any single number.
A fairness metric
The gap ratio, Spanish F1 divided by English F1, is reported next to raw accuracy, so a gain that helps one language at another’s cost shows up.