Transformers
reward-model
preference
rlhf
rlaif
multilingual
european-languages

Run this model with HF Jobs

Run openeurollm/prelude-reward-models on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/openeurollm/prelude-reward-models. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/openeurollm/prelude-reward-models on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

Prelude reward models

Scalar reward models for answers in 38 European languages, trained for reinforcement learning of OpenEuroLLM Prelude 9B on openeurollm/prelude-reward-modeling. Given a conversation and one answer to its last user turn, the model returns a single scalar reward; the better answer gets the higher score.

Use gemma-4-31b-v2 for all new work. The earlier v1 branches (gemma-4-31b, qwen3.8-27b) are deprecated and kept only for reproducibility.

| Branch | Status | Base model | Format | Context (eval / serving) | Size (bf16) | |---|---|---| | gemma-4-31b-v2 | Recommended | google/gemma-4-31B-it | | gemma-4-31b | Deprecated (v1) | google/gemma-4-31B-it | | qwen3.8-27b | Deprecated (v1) | Qwen/Qwen3.8-27B |

main holds only this model card.

Evaluation

Validation is on 1,008 pairs held out from training: 200 English pairs and 17–50 for each other language, with safety and instruction-following over-represented. Labels are the judges' vote shares, as in training. For 935 of these pairs there is also a reference verdict from Claude Opus 5.5, which gave the same verdict in both presentation orders. Benchmarks are scored with their official rules (including official subset-weighted M-RewardBench); training prompts were decontaminated against all three benchmarks.

Gemma 4 31B RM v2 Gemma 4 31B RM v1 Qwen3.8-27B RM v1
Validation, 1,008 pairs, 38 languages
Accuracy against the judges' majority (even splits left out) 92.2 92.6 91.3
Agreement with Claude Opus 5.5 (935 pairs) 91.2 91.7 91.7
Benchmarks
RewardBench 2 80.4 81.2 79.2
RM-Bench, all (hard) 86.2 (79.6) 86.3 (80.5) 85.1 (78.7)
M-RewardBench, European languages* 90.1 89.8 89.2

*Official subset-weighted M-RewardBench across 12 European languages for v2 (cs, de, el, es, fr, it, nl, pl, pt, ro, tr, uk; also 90.1 on the 11 languages excluding tr) and 11 languages for v1. v2 and v1 Gemma reward differences correlate at 0.991 on the 1,008 validation pairs.

Validation per language tier, accuracy against the judges' majority:

Tier Languages Pairs Gemma 4 31B RM v2 Gemma 4 31B RM v1 Qwen3.8-27B RM v1
English en 200 88.2 87.2 83.1
Large de, es, fr, it, pt 250 91.5 91.9 92.7
Mid bg, bs, ca, cs, da, el, fi, hr, hu, lt, nb, nl, pl, ro, sk, sv, tr, uk 306 95.3 97.0 94.3
Small et, eu, ga, gl, is, ka, lv, ltg, mk, mt, nn, sl, sq, sr 252 92.2 92.2 92.7

Agreement with Claude Opus 5.5 on the 935 validation pairs where Opus gave the same verdict in both orders:

All English Large Mid Small
Pairs 935 183 235 283 234
Reward models
Gemma 4 31B RM v2 91.2 88.5 91.5 94.7 88.9
Gemma 4 31B RM v1 91.7 86.9 92.8 96.1 88.9
Qwen3.8-27B RM v1 91.7 85.2 94.9 95.1 89.3
Training labels
The judges' pooled votes (in-sample) 95.0 92.3 95.7 97.3 93.6
Judges with reasoning, whose votes made the labels
Gemma 4 31B, thinking 92.7 89.1 94.9 93.8 91.9
Qwen3.8-27B, thinking (effort xhigh) 92.5 90.2 93.4 94.2 91.2
Qwen3.5-122B-A10B, thinking 90.9 86.9 92.1 93.8 89.3
gpt-oss-120b, reasoning high 88.4 81.7 89.1 94.0 86.1
Judges without reasoning, for comparison only
Gemma 4 31B, thinking off 90.7 84.2 91.7 94.5 90.2
Qwen3.8-27B, thinking off 88.7 86.3 92.1 90.5 85.0
Qwen3.5-122B-A10B, thinking off 89.9 86.9 88.7 93.8 88.7
gpt-oss-120b, reasoning low 85.3 76.8 87.4 89.4 85.0
Jev 1.14 91.2 84.4 92.6 95.1 90.4

Additional v2 (gemma-4-31b-v2) breakdown:

  • Validation by category (majority acc / Opus agreement): General 92.9 / 91.5 (n=618), Instruction following 92.8 / 90.8 (n=157), Safety benign 91.4 / 90.7 (n=118), Safety harmful 88.3 / 90.8 (n=115).
  • Agreement strength: 97.7% accuracy on unanimous pairs (n=710, mean |Δr| = 2.47); 77.9% on contested pairs (n=276, mean |Δr| = 0.78).
  • RewardBench 2 subsets: Factuality 85.9, Focus 88.3, Math 85.2, Precise IF 49.4, Safety 87.1, Ties 86.6.
  • RM-Bench domains: Chat 80.9, Code 81.1, Math 85.9, Safety 97.0 (Easy 90.2, Normal 88.8, Hard 79.6).
  • M-RewardBench per language: cs 88.3, de 90.2, el 88.3, es 90.7, fr 91.2, it 91.5, nl 90.6, pl 90.2, pt 91.1, ro 89.9, tr 89.9, uk 89.1.
  • Length neutrality: across pairs with length ratio ≥ 1.5×, accuracy is 92.3% when the longer answer is better and 92.0% when the shorter answer is better (1.5–2×: 52.5% vs labels 51.6%; 2–4×: 49.4% vs 47.5%; ≥ 4×: 43.9% vs 42.9%).
  • Truncation probe: a good answer beats its copy cut in half in 63.1% of cases (unreferenced probe; in many remaining cases the removed half contains a flaw).

Usage (gemma-4-31b-v2)

The model scores the conversation and the final answer only — never a reasoning trace. Build inputs exactly as in v2 training:

  1. Render the conversation with the bundled chat template (add_generation_prompt=True, enable_thinking=False), keeping template delimiters as live structural tokens while encoding every message's content as plain text (with all added/control tokens neutralized).
  2. Encode the stripped final answer as plain text (with all added/control tokens neutralized).
  3. Append the end-of-turn token <turn|> (token id 106).
  4. Apply the float32 linear head (score.weight, score.bias) to the last hidden state.

With transformers

gemma-4-31b-v2 is stored in text-only Gemma4TextConfig format (model.* backbone + score.weight / score.bias). AutoModel.from_pretrained loads the backbone directly with no key remapping (the bf16 weights take ~61 GB of GPU memory; device_map="auto" shards across GPUs).

import json
import re

import torch
from huggingface_hub import snapshot_download
from safetensors import safe_open
from tokenizers import Tokenizer
from transformers import AutoModel, AutoTokenizer

BRANCH = "gemma-4-31b-v2"
END_OF_TURN = "<turn|>"
MAX_LEN = 36864

path = snapshot_download("openeurollm/prelude-reward-models", revision=BRANCH)
tokenizer = AutoTokenizer.from_pretrained(path)

# Build a plain-text copy of the fast tokenizer with all added/control tokens removed so user text and
# model answers can never match structural tokens (<turn|>, <|channel>, <think>, <|im_end|>, etc.).
_raw_cfg = json.loads(tokenizer._tokenizer.to_str())
_raw_cfg["added_tokens"] = []
plain_tok = Tokenizer.from_str(json.dumps(_raw_cfg))
_MSG_RE = re.compile(r"(\ue000M\d+\ue001)")
END_IDS = tokenizer(END_OF_TURN, add_special_tokens=False)["input_ids"]  # [106]

# AutoModel loads the text backbone directly; the float32 reward head is read from the last shard.
backbone = AutoModel.from_pretrained(path, dtype=torch.bfloat16, device_map="auto").eval()
weight_map = json.load(open(f"{path}/model.safetensors.index.json"))["weight_map"]
with safe_open(f"{path}/{weight_map['score.weight']}", "pt") as f:
    head_weight, head_bias = f.get_tensor("score.weight"), f.get_tensor("score.bias")  # float32


def encode_plain(text: str) -> list[int]:
    return list(plain_tok.encode(text, add_special_tokens=False).ids) if text else []


def input_ids(messages: list[dict], answer: str) -> list[int]:
    """Build v2 RM input IDs: live chat-template delimiters around plain-text message contents,
    stripped plain-text final answer, closing <turn|>, and head+tail fallback truncation at MAX_LEN."""
    ph = [{"role": m["role"], "content": f"\ue000M{k}\ue001"} for k, m in enumerate(messages)]
    tmpl = tokenizer.apply_chat_template(
        ph, tokenize=False, add_generation_prompt=True, enable_thinking=False
    )
    p: list[int] = []
    for part in _MSG_RE.split(tmpl):
        if not part:
            continue
        if part.startswith("\ue000M") and part.endswith("\ue001"):
            p.extend(encode_plain(messages[int(part[2:-1])]["content"].strip()))
        else:
            p.extend(tokenizer(part, add_special_tokens=False)["input_ids"])
    a = encode_plain(answer.strip())
    budget = MAX_LEN - len(END_IDS)
    if len(p) + len(a) > budget:
        cap = max(budget // 2, budget - len(a))
        if len(p) > cap:
            head = min(16, cap // 2)
            p = p[:head] + p[len(p) - (cap - head):]
        rem = budget - len(p)
        if len(a) > rem:
            rh = rem // 2
            rt = rem - rh
            a = a[:rh] + a[len(a) - rt:] if rt else a[:rh]
    return p + a + END_IDS


@torch.no_grad()
def reward(messages: list[dict], answer: str) -> float:
    ids = torch.tensor([input_ids(messages, answer)], device=backbone.device)
    h = backbone(input_ids=ids).last_hidden_state[0, -1].float()
    return (h @ head_weight.to(h.device).T + head_bias.to(h.device)).item()


messages = [{"role": "user", "content": "Mikä on Suomen pääkaupunki? Vastaa yhdellä lauseella."}]
answers = ["Suomen pääkaupunki on Helsinki.", "Suomen pääkaupunki on Turku."]
r = [reward(messages, a) for a in answers]
print("rewards =", r)
print("P(first answer is better) =", torch.sigmoid(torch.tensor(r[0] - r[1])).item())

With vLLM (high-throughput RL serving)

gemma-4-31b-v2 loads directly in vLLM's pooling runner (--runner pooling --convert classify) without renaming weights. Pass max_model_len = 36865 (MAX_LEN + 1) so chunked prefill scores full 36,864-token sequences cleanly:

from vllm import LLM, PoolingParams
from vllm.inputs import TokensPrompt

llm = LLM(
    model="openeurollm/prelude-reward-models",
    revision="gemma-4-31b-v2",
    runner="pooling",
    convert="classify",
    tensor_parallel_size=2,
    max_model_len=36865,
    enable_prefix_caching=True,
)
params = PoolingParams(task="classify", use_activation=False)

prompts = [TokensPrompt(prompt_token_ids=input_ids(messages, a)) for a in answers]
outputs = llm.encode(prompts, pooling_params=params)
scores = [float(out.outputs.data.reshape(-1)[0]) for out in outputs]

Notes on inputs and rewards:

  • messages is a list of {"role", "content"} turns ending with the user turn to answer (earlier system/assistant turns are context). Do not inject a default system prompt the user did not write.
  • Only differences within a prompt are meaningful: rewards are Bradley–Terry logits where sigmoid(r_a - r_b) estimates the probability that answer a is preferred over answer b.
  • Scale: across the 2,016 validation answers, v2 rewards have mean −0.12, std 1.77, and range −3.86 to +3.39. Per-language means span −0.77 (sk) to +0.92 (lv), so do not compare raw scores across different prompts or languages.
  • Serving parity: verified live with vLLM pooling (TP=2, bf16) against the FP32-residual training checkpoint across all 2,016 validation sequences: Pearson correlation 0.999973 (reward differences 0.999974), mean absolute difference 0.0085, 1 / 1,008 winner flips (0 above 0.1 margin).

Training (gemma-4-31b-v2)

  • Data: 124,939 uncut training pairs (out of 126,919; 1,980 pairs exceeding 16,384 tokens dropped) from openeurollm/prelude-reward-modeling. The remaining 1,008 pairs of the 127,927-pair dataset form the validation split (evaluated uncut up to 36,864 tokens).
  • Prompts and answers: 38 European languages, two answers per prompt from a pool of 17 models spanning Prelude checkpoints through older 7B baselines.
  • Labels: soft vote shares across six judge calls (three open LLM judges in both presentation orders: Gemma 4 31B, Qwen3.8-27B, and gpt-oss-120b, with a substitute whenever a judge would score its own family), plus a 105-pair fallback rule for degenerate loops/word salad too long for any judge.
  • Judging criteria (in priority order): harm, usability, language, correctness, instruction following, helpfulness, and concision.
  • Objective: Bradley–Terry cross-entropy against soft vote shares, with reward centering (0.01).
  • Model & precision: full fine-tuning of Gemma 4 31B's text decoder (30.7B parameters) plus a float32 linear head on the last hidden state of <turn|>, with FP32 embeddings (embed_scale), RMSNorms, layer scalars, and residual stream.
  • Schedule: 1 epoch (976 steps × 128 pairs, ~285M tokens); AdamW (β₁=0.9, β₂=0.95, weight decay 0.0); backbone LR 2e-6, head LR 1e-4, 3% linear warmup, cosine decay to 10%; gradient clipping 1.0.
  • Hardware: 4 nodes (32 AMD MI250X GCDs) on LUMI.
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for openeurollm/prelude-reward-models

Finetuned
(440)
this model

Dataset used to train openeurollm/prelude-reward-models