Use
One user turn with this prompt, where {text} is the English source (there are two empty lines before it):
Translate the following English text into natural, idiomatic Dutch, as a native speaker would write it, not word for word. Translate everything: leave nothing out and add nothing; keep every name, number, detail and nuance, and the tone. Be as concise as the original. Keep the paragraphs, line breaks and formatting. Output only the translation, without explanation or commentary. {text}
Use the base model's chat template with thinking off (its default). Works with greedy decoding (temperature 0) and also
produces more diverse candidates than the base model when sampling (e.g. temperature 1.0 for best-of-N reranking).
With transformers and peft (bf16 needs ~62 GB of accelerator or CPU memory):
import torchfrom peft import PeftModelfrom transformers import AutoModelForCausalLM, AutoTokenizer base_id = "google/gemma-4-31B-it"adapter_id = "yhavinga/gemma-4-31b-it-en-nl-grpo-lora" tokenizer = AutoTokenizer.from_pretrained(base_id)model = AutoModelForCausalLM.from_pretrained(base_id, dtype=torch.bfloat16, device_map="auto")model = PeftModel.from_pretrained(model, adapter_id)model.eval() PROMPT = ( "Translate the following English text into natural, idiomatic Dutch, as a native speaker would write " "it, not word for word. Translate everything: leave nothing out and add nothing; keep every name, " "number, detail and nuance, and the tone. Be as concise as the original. Keep the paragraphs, line " "breaks and formatting. Output only the translation, without explanation or commentary.\n\n\n{text}") def translate(text, max_new_tokens=1024): messages = [{"role": "user", "content": PROMPT.format(text=text.strip())}] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, return_tensors="pt", return_dict=True ).to(model.device) with torch.no_grad(): output = model.generate(**inputs, max_new_tokens=max_new_tokens, do_sample=False) return tokenizer.decode(output[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True).strip() print(translate("The weather was so nice that we decided to have lunch outside."))
For faster inference, merge the adapter (model = model.merge_and_unload()) or use the GGUF repository above.
Training
- Method: Online GRPO (Dr. GRPO group advantage without std division) starting from
google/gemma-4-31B-it.
Every iteration sampled 8 translations per source (temperature 1.0) on 512 English sources.
- Sources: English passages of 20–256 tokens drawn without overlap across iterations from the five datasets in the
Dutch originals with English translations, Gemma 4
collection (
fineweb-2-nl-en-gemma4,
handelingen-tweede-kamer-nl-en-gemma4,
openraadsinformatie-nl-en-gemma4,
rijksoverheid-websites-nl-en-gemma4,
rechtspraak-nl-en-gemma4) and English prompts
from yhavinga/flan-nl. Only the English column from these
datasets was used as prompts; training updated on the model's own sampled Dutch rollouts rather than the datasets'
original Dutch (nl) column.
- Reward (C2): Clipped logit (±12) of C2, a Dutch ModernBERT 230M classifier
(yhavinga/dmbert-230m-fineweb2-optout) fine-tuned to
distinguish original Dutch from Gemma 4 31B-it round-trip Dutch (
nl vs. nl_back) on the five datasets in the
Gemma 4 dataset collection,
minus penalties for MetricX-24-QE regressions above the base model's greedy anchor and length deviations outside
[0.85, 1.15] of the anchor; hard failures (truncation, loops, English remaining, QE > 10) received −30.
- Adapter: LoRA rank 32, alpha 16 (scale 0.5) on the attention (
q_proj, k_proj, v_proj, o_proj) and MLP
(gate_proj, up_proj, down_proj) projections of all 60 layers of the text decoder; the 10 global-attention
layers have no v_proj (their values come from k_proj), so 410 modules and 244.9M parameters, stored in float32.
Embeddings frozen, dropout 0.
- Optimisation: AdamW, constant LR 5e-5, KL penalty (k2, β=0.04), ~27 optimizer steps per iteration.
Training stopped after iteration 17 on a validation QE stop rule; this release is iteration 15 (410 optimizer
steps), selected on a search split before the held-out evaluation below.
- Trained with MaxText and converted to PEFT; the conversion was checked teacher-forced in
transformers against the
greedy output of the trained model.
Why not SFT on the original Dutch?
Earlier runs trained directly on (en → nl) back-translation pairs using the datasets' original Dutch (nl) column as
targets. Held-out loss on original Dutch dropped sharply (e.g. 1.85 → 0.55 on back-translation validation, chrF
+4.1 to +5.5), but loss on the base model's own greedy translations only rose from 0.075 → 0.339—leaving the old
phrasing as the greedy argmax. A single temperature (T∗=2.05) explained 62–67% of the loss drop: off-policy SFT
mainly flattened calibration and fit source-domain style while barely moving C1 on WMT24++ + FLAN (+0.4 to +1.0 pp)
and slightly regressing MetricX-24 QE on all benchmarks. Sampling at T=1 showed that better, more natural
translations were already in Gemma 4's distribution, so training on-policy—either via online GRPO rollouts (this model)
or judge-filtered best-of-8 SFT—shifted the greedy output without hurting QE.
Evaluation
Held-out decision splits (not used for training or for choosing the checkpoint). MetricX-24 QE (lower is better) and
COMET-22, against the base model with the same prompt and greedy decoding:
Table with columns: set, n, QE adapter, QE base, QE human reference, COMET-22 adapter, COMET-22 base| set | n | QE adapter | QE base | QE human reference | COMET-22 adapter | COMET-22 base |
|---|
| WMT24++ en-nl | 480 | 2.249 | 2.276 | 2.463 | 0.8512 | 0.8502 |
| FLORES-200 en-nl | 504 | 1.116 | 1.115 | 1.493 | 0.8889 | 0.8895 |
| NTREX-128 en-nl | 999 | 1.520 | 1.547 | 1.874 | 0.8813 | 0.8820 |
Original-vs-translated Dutch classifiers (C1 and C2, WMT24++ 480 + FLAN 500):
Two separate Dutch ModernBERT 230M classifiers were used so optimization could be checked for reward hacking:
- C2 (reward classifier):
yhavinga/dmbert-230m-fineweb2-optout fine-tuned on original Dutch vs. Gemma 4 31B-it
round-trips from the Gemma 4 dataset collection; used inside the GRPO reward. On held-out WMT24++ + FLAN, C2 rates
20.1% of this adapter's greedy outputs as original Dutch vs 16.5% for the base model (+3.6 pp; WMT24++
28.5% vs 25.0%, FLAN 12.0% vs 8.4%).
- C1 (independent evaluation classifier): a separate Dutch ModernBERT 230M encoder (an earlier 1-epoch predecessor
of yhavinga/dmbert-230m-culturax) fine-tuned on original Dutch
vs. TranslateGemma 27B round-trips (95.8% test accuracy), kept strictly out of the RL reward and stop rules. On the
same held-out texts, C1 rates 34.2% of this adapter's greedy outputs as original Dutch vs 30.0% for the base
model (+4.2 pp; WMT24++ 52.9% vs 48.5%, FLAN 16.2% vs 12.2%) — confirming that gains transfer from C2 to an
independent classifier rather than exploiting C2 alone.
Other evaluations:
- Blind pairwise evaluation (greedy, 100 evaluation passages, Claude blind reviewer): 20 / 23 / 57 (adapter better
/ base better / equal, meaning errors 15 / 12) — no clear preference over the base model under greedy decoding.
Against TranslateGemma 27B: 60 / 16 / 24 (errors 17 / 48).
- Sampling diversity (T=1, best-of-8): In reranking experiments on a held-out search split, judge-selected
best-of-8 samples from this adapter beat the base model's greedy output 50 / 15 / 35 (77% of non-ties, blind) vs
38 / 19 / 43 (67%) for best-of-8 from the base model itself.
Limitations
- Under greedy decoding, blind LLM review showed no overall preference over the base model (20 / 23 / 57), and this
checkpoint has not been evaluated in a dedicated human blind sample.
- The reward classifier (C2) measures statistical distance from machine-translated Dutch rather than human translation
preference directly; continuing RL past iteration 15 caused quality degradation (stopped at iteration 17).
- Evaluated on English→Dutch only, with the prompt above; other prompts and directions are untested.
Acknowledgements
Research supported with Cloud TPUs from Google's TPU Research Cloud (TRC).