Configuration Parsing Warning:In config.json: "num_experts" must be a number

UserLM-Gemma4-12B

UserLM-Gemma4-12B plays the user in a conversation with an AI assistant. It reads a private brief that describes a person (what they want, who they are, what they have at hand, their temperament and how they write) and writes that person's side of the chat: the opening message, a response to each reply the assistant gives, and the decision to leave. It is built for testing and training assistants against realistic multi-turn users and for generating multi-turn conversation data.

The model is a full fine-tune of the pretrained Gemma 4 12B base. Supervised training on the user side of real human-assistant chats was followed by 365 steps of reinforcement learning against open assistant models from 1.7B to 12B parameters, which rewarded the simulated user for pursuing the brief's goals, for reacting to what each reply actually said (pushing back on a wrong or partial answer instead of thanking it) and for writing the way real users write.

Property Value
Weights 12B parameters, bf16, 23.8 GB
Revision main, the same weights as rl21-step70
Conversation length in training up to 30 user messages; the trainer read the first 32,000 tokens
Tested with vLLM 0.33.0; transformers 5.20.2 with PyTorch 2.14
License Apache 2.0; one supervised dataset is non-commercial (see License)

Quick start

Serve the model with vLLM

vllm serve whab13/userlm-gemma4-12b --served-model-name userlm \
  --hf-overrides '{"architectures": ["Gemma4ForCausalLM"]}' --max-model-len 32768 --port 8000

The checkpoint's config.json names the transformers class Gemma4UnifiedForCausalLM, which vLLM 0.33 does not register. The override loads the same weights through vLLM's Gemma4ForCausalLM, the implementation that sampled every training conversation. The weights take 23.8 GB of GPU memory, and the rest of --gpu-memory-utilization holds the KV cache.

Run conversations

harness.py in this repository holds the prompt format and the conversation loop. Its server backend needs only the Python standard library.

hf download whab13/userlm-gemma4-12b harness.py --local-dir .
from openai import OpenAI
from harness import converse, served

brief = (
    "You want a polished list of answers for a job interview. You are a small-town pastor applying for a regional "
    "administrative role at the diocesan office. This is your first chance to move out of your current parish and "
    "secure a steady salary for your family. You have a printed job description and your current resume. You want "
    "the specific talking points that will make you look like an efficient manager rather than just a preacher. The "
    "answers must fit the formal tone of the bishop's office. You are persistent and will push for concrete examples "
    "if the responses are too vague. You leave once you have your talking points.\n"
    "How they write: short commands, lowercase, abrupt tone"
)

client = OpenAI(base_url="http://localhost:8001/v1", api_key="EMPTY")  # the assistant under test


def assistant(messages):
    reply = client.chat.completions.create(model="assistant", messages=messages, max_tokens=2048)
    return reply.choices[0].message.content


turns = converse(brief, served("http://localhost:8000/v1"), assistant)
for turn in turns:
    print(f"{turn['role']}: {turn['content']}\n")

converse returns the conversation as OpenAI-style chat messages. The assistant function receives those messages and returns the reply text, so it can wrap any model or system. A conversation ends when the simulated person leaves, silently or after a last message that then gets no reply, or after 30 messages from the person, the cap used in training. Because the server batches concurrent requests, run many conversations at once from a thread pool: with the model on one H200 and the assistant served on another GPU, 12 concurrent conversations finished in 59 s.

Run without a server

import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from harness import converse, local

tokenizer = AutoTokenizer.from_pretrained("whab13/userlm-gemma4-12b")
model = AutoModelForCausalLM.from_pretrained("whab13/userlm-gemma4-12b", dtype=torch.bfloat16).to("cuda")
turns = converse(brief, local(model, tokenizer), assistant)

The transformers backend writes one message at a time without batching: a conversation with six messages from the person took 52 s on an H200, assistant replies included, so prefer vLLM for more than a handful of conversations.

Example

A conversation from testing the commands above, with the pastor brief and Gemma-4-12B-it as the assistant (no system prompt). The person's pasted documents and the assistant's replies are shortened here; the person's words are otherwise verbatim.

User: look at this job decription and make list of answer for interview questions : Job Responsibilities

  1. Manage day-to-day operations of regional offices, ensuring efficient functioning and adherence to diocesan policies. (six more numbered duties)

Assistant: To prepare for an interview based on this job description, you need to position yourself as a bridge-builder, a reliable administrator, and a supportive leader. (reply shortened)

User: more concrete example pls

Assistant: To give you concrete examples, I have drafted three "STAR" method responses (Situation, Task, Action, Result). (reply shortened)

User: ok now resume : EDUCATION
Bachelor of Arts in Theology - University of Santo Tomas (2008) (the rest of a full resume)

Assistant: This is a very strong profile for the role. (reply shortened)

The person leaves without another message.

Writing briefs

Write the brief in the second person, as a private description the person carries into the chat. Training briefs ran about 110 words and opened with what the person wants. Two examples written that way:

You want a weekly meal plan you can actually stick to on a night-shift schedule. You are a nurse working four 12-hour nights a week, and you eat your main meal around 3 a.m. on break, with only a microwave and a mini fridge at work and one burner at home. You budget $60 a week for groceries, you can't stand mushrooms, and your doctor told you last month that your iron is low. You have tried meal-prep plans before, and they all assumed a normal day. You are skeptical of advice that sounds generic, and you question numbers you are given. You leave once you have a plan that fits your week.
How they write: lowercase, short messages, typos, no punctuation at the end

You want an email to your landlord that finally gets the broken dishwasher fixed before your in-laws arrive on the 14th. You are a high school chemistry teacher who has reported it twice by phone, on the 2nd and the 6th, and each time the property manager, Dana, said a technician was being scheduled. You have a photo of the error code, E24, and a lease that says repairs are handled within a reasonable time. You want the email to stay polite while making clear that you expect a repair date in writing, and you change your mind about the tone partway through. Once the email is done, you also want a dinner for six that you can make the day before.
How they write: full sentences, proper punctuation, friendly but to the point

In five test conversations each against Gemma-4-12B-it, the nurse wrote in lowercase fragments, brought up the schedule, equipment and budget, questioned the assistant's numbers in two of them ("any number wrong here ? seems alot lower then before ?") and raised the low iron in all five. The teacher handed over the call dates, Dana's name, the error code and the lease clause, asked for a different tone in every conversation and then moved on to the dinner. Each part of a brief does a job:

  • The aim. 81% of training briefs give one aim plus the particulars an answer has to fit; the rest list two to four separate needs. Training rewarded pursuing every goal the brief names and checking the replies against them.
  • The person and their material. Give the background and the facts, drafts or numbers the person holds; the model draws on them when the assistant asks or gets a detail wrong.
  • Temperament. 36% of training briefs set one: persistent, argumentative, short-tempered, skeptical, indecisive or matter-of-fact.
  • When they leave. Training briefs ended the chat once the aim was met (40%), added unrelated requests the person moves on to (35%) or let the conversation wander (24%).
  • How they write. A closing How they write: line sets length, casing, punctuation and tone.

About 30% of training briefs used another format: a single line, labeled fields, third person, a persona alone, terse notes, or the brief written in Spanish, French, German, Portuguese or Italian. A one-line brief such as "You want to know if a lease amendment makes you legally responsible for the previous tenant's unpaid utilities." therefore works, and in testing it produced one or two focused questions before the person left. Keep the brief away from the assistant under test: it belongs to the simulator alone.

Prompt format

Call the model in this layout to use it without harness.py:

<bos><|turn>system
You are a person chatting with an AI assistant. Play this person: write only their messages.
Their goal: {brief}<turn|>
<|turn>user
{the person's message}<turn|>
<|turn>model
{the assistant's reply}<turn|>
<|turn>user
  • Generate after the final <|turn>user\n and stop at <turn|>. The person's messages take Gemma's user role and the assistant's replies take the model role, so the model writes the user turns.
  • <unused0> (token id 6) ends the conversation. Text before it is the person's last message, and an output that begins with it means the person leaves without writing anything. The tokenizer does not register <unused0> as a special token, so it survives decoding and can be matched as a string.
  • Sample at temperature 1.0, top-p 0.95 and top-k 64 (the shipped generation_config.json), with up to 4,096 new tokens per message.
  • Show an assistant reply longer than 3,000 characters as its first 2,000 and last 1,000 characters joined by \n[...]\n, the view the model had in training.
  • With vLLM's completions endpoint, send "add_special_tokens": false, because the prompt already begins with <bos>.
  • Do not use tokenizer.apply_chat_template. The tokenizer ships no chat template, and a standard Gemma template would open a model turn, which asks for the assistant's reply instead of the person's message.

Training

Stage Steps
Supervised fine-tuning 240
Reinforcement learning on goal statements 75
Reinforcement learning on briefs, from the goal stage's step 50 315, in nine rounds

Supervised fine-tuning

  • Data: 167,872 English, non-toxic WildChat-4.8M conversations, split by user so that no person appears in both training and held-out data, plus 26,631 Tulu 3 conversations (the human-written OpenAssistant and No Robots subsets and 10,000 synthetic conversations).
  • Conditioning: a goal statement and a note on how the user writes for every conversation, both written from the conversation by Ornith-1.5-35B-A3B.
  • Loss: the user's turns and the end-of-conversation token. The assistant's turns are context only.
  • Recipe: full fine-tune of the text weights of google/gemma-4-12B on 8,192-token conversations, AdamW at 2e-5 with warmup and cosine decay, about 0.5M tokens per step for 240 steps (about half an epoch). Held-out user NLL fell from 1.600 to 1.230 nats per token.

Reinforcement learning

Every round used GRPO, with advantages standardized within each group of conversations that share a brief or goal statement (eight per group in the brief stage). The policy was sampled as served (temperature 1.0, top-p 0.95, top-k 64) for up to 30 user messages per conversation, and the assistants answered with no system prompt and with any reasoning hidden from the person. The goal-statement stage started from the supervised model, and its step-50 checkpoint became both the starting point of the brief stage and the KL reference of every later round. A Qwen model wrote the briefs and served as judge in the first five brief rounds; the last four rounds (220 steps) used Gemma-4-31B-it for both and dropped the Qwen assistants.

The final round, rl21, ran 70 steps:

  • Briefs: 4,800, written by Gemma-4-31B-it in equal parts from invented people and errands, ThoughtTrace task summaries and PRISM conversation openings.

  • Assistants: Gemma-4-12B-it, Gemma-4-E4B-it, Gemma-4-E2B-it, Phi-4-mini-instruct, SmolLM3-3B and SmolLM2-1.7B-Instruct. In 40% of the groups, one of the first three replies was a planted failure, the same for all eight conversations of the group: Gemma-4-12B-it, under a hidden instruction, misread the request, refused something harmless, answered half of it, asked a needless clarifying question, gave a generic answer or got a stated detail wrong.

  • Reward: quality × (coverage + 2 × naturalness + 2 × acting + reacting + termination + length) − 0.1 × worst move, where

    • coverage is the share of the brief's goals that the replies met or that the person pressed for again before letting go for a reason;
    • naturalness is the probability that the person's messages come from a real user, from a LiquidAI d1-2B classifier fine-tuned on real and simulated users and frozen during training;
    • acting is one minus the mean probability, over the person's messages, that a message is not what this person would write after the reply it answers: taking a bad reply as good, ignoring what was said, unearned or reflexive thanks and pleasantries, acting against the brief, or confusing the roles;
    • reacting is the mean probability, from a ModernBERT-large classifier, that a real person would make each of the person's moves after the reply before it;
    • termination is +0.2 when the person leaves with every goal covered and −0.2 when they leave earlier;
    • length holds message lengths to real users': per message, the log ratio of how often real users and the policy write a message of that length at that position (opening or later), clipped to ±2;
    • quality is the judge's probability that the conversation contains no degenerate output, times one minus the highest probability that a message reads the brief aloud;
    • worst move is the highest per-message probability from the acting judge.

    Gemma-4-31B-it (FP8) judged coverage, acting, quality and recital.

  • Optimization: 64 briefs × 8 conversations per step, learning rate 1e-6, KL coefficient 1e-3 to the goal stage's step-50 checkpoint.

Evaluation

The validation set holds 99 briefs (33 per source) that training never used, with two conversations each against the training assistants. These scores come from the reward's own judges, so they track what training optimized rather than an independent assessment; no study with human raters has been run.

Measure main Real users
Acting: 1 − mean P(the message is a bad move) 0.923 0.936
Coverage: goals met, or pressed for and let go 0.903 0.881
Naturalness: P(real user) 0.970 not measured
User messages per conversation 5.0 4.7 (median 3)

The real-user figures are references rather than matched comparisons: acting comes from 60 WildChat conversations scored by the same judge, coverage from 200 held-out WildChat conversations scored against briefs that Gemma-4-31B-it wrote from them, and message counts from 9,234 held-out WildChat conversations of two or more user messages. In the last ten training steps, 0.7% of the person's responses to a planted failure thanked the assistant, against 74% at the start of the round that introduced the acting judge.

Against UserLM-2.0

Both simulators played the same 200 briefs, each written by Gemma-4-31B-it from a held-out WildChat conversation that neither model trained on, with two conversations per brief against Gemma-4-26B-A4B-it, an assistant neither model trained with. UserLM-2.0 took the brief as its system message and sampled at temperature 1.0 and top-p 0.8, as its model card specifies. It ran under two harnesses: the one used for this model, where a message that reaches the token cap (1,024 tokens for UserLM-2.0, 4,096 for this model) ends the conversation, and the one in UserLM-2.0's model card example, where every message stops at 128 tokens and the conversation goes on. The real-user column scores the 200 conversations the briefs came from.

Measure This model UserLM-2.0 UserLM-2.0, card harness Real users
Coverage: goals met, or pressed for and let go 0.94 ± 0.01 0.62 ± 0.02 0.88 ± 0.01 0.88 ± 0.02
Acting: 1 − mean P(bad move) 0.93 ± 0.01 0.69 ± 0.02 0.78 ± 0.01 0.93 ± 0.01
Reads the brief out: highest P per conversation 0.003 0.36 0.32 0.02
Naturalness under detectors training never used (d1 H / d1 F / ModernBERT) 0.86 / 0.82 / 0.78 0.18 / 0.15 / 0.29 0.17 / 0.17 / 0.23 0.90 / 0.89 / 0.77
First message, median words 19 134 82 18.5
Words per message, median 14 84 77 15
User messages per conversation, mean (median) 4.8 (4) 4.8 (2) 12.7 (7) 10.4 (7.5)
Conversations the person ended 99.8% 43% 72% 100%

Under this model's harness, 52% of UserLM-2.0's conversations ended on a message that ran to the 1,024-token cap (those inspected were loops, one numbering 77 near-identical survey questions), and this model never reached its cap. Under the card harness, UserLM-2.0's conversations run about as long as real ones, but 73% of its messages were cut at 128 tokens, and 28% of its conversations repeat a message word for word, against 15% of real conversations and 3% of this model's. Coverage, acting and recital come from the judges this model's reward used, which favors this model; the naturalness detectors and the word and message counts involve no such judge.

Limitations

  • A person whom the brief calls persistent sometimes gives up after one push.
  • The model works each goal for about two messages, where real users take 5.6, so problems resolve faster than in real chats, and briefs that ask the person to keep chatting still produce short conversations.
  • Some phrasings recur across conversations, "one last question" above all.
  • Documents the person invents, such as a pasted resume, occasionally contain WildChat's anonymization placeholders (for example <PRESIDIO_ANONYMIZED_PERSON>).
  • Simulated users can be blunt, rude or profane, because real users are and training allowed it.
  • Training used text-only assistants without tools or retrieval; behavior against agents and tool calls is untested.
  • 95% of the final round's briefs were in English, and the supervised data was English WildChat plus multilingual OpenAssistant.

Revisions

main and rl21-step70 hold the same files.

License

The weights are released under Apache 2.0, the license of the Gemma 4 base model. The supervised data includes WildChat-4.8M (ODC-BY), OpenAssistant (Apache 2.0), the Tulu 3 SFT mixture (ODC-BY, with per-subset licenses) and No Robots (CC BY-NC 4.0), and the reinforcement-learning briefs drew on ThoughtTrace (CC BY 4.0) and the human-written text of PRISM (CC BY 4.0). Because No Robots allows non-commercial use only, use the model for research unless the dataset licenses have been cleared for another purpose.

Related work

  • UserLM-8b: "Flipping the Dialogue: Training and Evaluating User Language Models", arXiv:2510.06552. This model follows its recipe of training a base model on the user side of real chats with a learned end-of-conversation token.
  • UserLM-2.0 (microsoft/UserLM-2.0), whose reinforcement-learning reward the reward above extends.
  • GRPO: "DeepSeekMath: Pushing the Limits of Mathematical Reasoning in Open Language Models", arXiv:2402.03300.
Downloads last month
56
Safetensors
Model size
12B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for whab13/userlm-gemma4-12b

Finetuned
(103)
this model

Papers for whab13/userlm-gemma4-12b