marian-finetuned-kde4-en-to-fr
MarianMT English→French model fine-tuned on the KDE4 software localization corpus.
Model description
This model is a fine-tuned version of Helsinki-NLP/opus-mt-en-fr on the KDE4 English–French parallel corpus.
The KDE4 dataset consists of localization files from KDE applications, which makes it a strong fit for software localization and technical translation tasks. Fine-tuning on this data teaches the model the formal, standardized French terminology conventions that the KDE community enforces — for example, translating "plugin" as module d'extension rather than keeping the anglicism.
Intended uses & limitations
Intended uses
- Translating English software UI strings, error messages, and documentation into French.
- Technical translation where consistent, formal terminology is preferred.
- Baseline for further fine-tuning on other software localization corpora.
Limitations
- Trained specifically on the KDE4 domain. It may over-normalize informal or conversational English toward formal French.
- May not generalize well to non-technical text (literature, marketing, etc.).
- Like all Marian models, it does not use a task prefix and expects plain English input.
Training procedure
Training data
The full KDE4 en-fr parallel corpus (~210k sentence pairs) was split 90/10:
| Split | Examples |
|---|---|
| Train | ~189,000 |
| Validation | ~21,000 |
Training hyperparameters
- Base model:
Helsinki-NLP/opus-mt-en-fr - Epochs: 3
- Batch size: 32 (train) / 64 (eval)
- Learning rate: 2e-5
- Weight decay: 0.01
- Max sequence length: 128
- Mixed precision: fp16
- Optimizer: AdamW
Evaluation strategy
Evaluation during training was disabled (eval_strategy="no") to keep training
time reasonable on the large training set. The model was evaluated once before
fine-tuning (baseline) and once after, on the full validation split.
Training and evaluation loss
| Metric | Value |
|---|---|
| Training loss (final) | 0.8132 |
| Evaluation loss | 0.8553 |
Loss decreased from ~1.4 to ~0.81 over 3 epochs. The training value is the last logged snapshot; the evaluation loss was computed once on the full KDE4 validation split (~21k examples) after training. No separate test set was held out for this run.
Results
| Stage | BLEU (KDE4 validation) | Validation Loss |
|---|---|---|
| Baseline (opus-mt) | 39.3 | 1.6963 |
| Fine-tuned | 53.0 | 0.8553 |
Fine-tuning yields a +13.7 BLEU improvement and cuts validation loss roughly in half, reflecting the model's adaptation to KDE4's formal terminology and style.
How to use
Direct usage with transformers
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
import torch
import re
model_checkpoint = "AlexStamp/marian-finetuned-kde4-en-to-fr"
tokenizer = AutoTokenizer.from_pretrained(model_checkpoint)
model = AutoModelForSeq2SeqLM.from_pretrained(model_checkpoint)
def translator(text):
"""
Translate English text to French.
Accepts either a single string or a list of strings.
Returns a string for a single input, or a list of strings for multiple inputs.
"""
single = isinstance(text, str)
if single:
text = [text]
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
translated_tokens = model.generate(**inputs)
outputs = tokenizer.batch_decode(translated_tokens, skip_special_tokens=True)
# Clean up KDE4's HTML entity   and the resulting double spaces
outputs = [re.sub(r"&\s*#160;", " ", out) for out in outputs] # entity → space
outputs = [re.sub(r"\s+", " ", out).strip() for out in outputs] # collapse double space to single space
return outputs[0] if single else outputs
# Single sentence
translator("Default to expanded threads")
# → "Par défaut, développer les fils de discussion"
# Multiple sentences
translator([
"Unable to import %1 using the OFX importer plugin. This file is not the correct format.",
"Could not load the plugin. Please check your installation.",
"The file has been modified. Do you want to save your changes?",
"All details are mentioned in the email I sent."
])
# → ["Impossible d'importer %1 en utilisant le module externe d'importation OFX. Ce fichier n'est pas le bon format.",
# 'Impossible de charger le module externe. Veuillez vérifier votre installation.',
# 'Le fichier a été modifié. Voulez -vous enregistrer vos modifications ?',
# "Tous les détails sont mentionnés dans le courrier électronique que j'ai envoyé."]
Because KDE4 is an HTML-based corpus, the model may output HTML entities (like
 for non-breaking spaces) or double spaces before French punctuation (?,!,:,;). Thetranslator()function above includes a light post-processing step that normalizes these.
Expected behavior
Unlike the base opus-mt-en-fr model, this fine-tuned version is expected to
output formal French terminology for technical terms. For example:
| English | Base model | Fine-tuned model |
|---|---|---|
| plugin | plugin | module d'extension |
| threads | threads | fils de discussion |
Framework versions
- Transformers 5.16.1
- Pytorch 2.11.0+cu128
- Datasets 3.6.0
- Tokenizers 0.23.1
Acknowledgements
Fine-tuned as part of the Hugging Face LLM Course translation tutorial.