microsoft/UserRepGen-4B
Captured source
source ↗UserRepGen-4B
UserRepGen-4B is a fine-tuned Qwen3.5-4B language model that generates a structured, natural-language user representation from a multi-turn user-assistant conversation. Each representation contains a task description and a behavior description for a user, and is intended to condition a separate LLM-based user simulator.
Unlike UserLM-8b and UserLM-2.0, which generate user utterances, UserRepGen-4B generates representations, not simulated user turns. It does not itself execute the user's task or serve as the simulator.
The model was trained with online supervised fine-tuning through hindsight distillation, using feedback obtained by comparing simulated and original user behavior. At inference time, it generates a representation directly from the source conversation without requiring simulation rollouts or hindsight feedback.
Model details
| Property | Description | |---|---| | Developed by | Microsoft Corporation | | Model type | User-representation generator, 4B-class language model | | Backbone | Qwen3.5-4B | | Adaptation | Rank-64 LoRA with online supervised fine-tuning | | Language | English | | Inputs | Text-only, multi-turn user-assistant conversations | | Outputs | Text formatted as JSON with task and user_behavior fields | | Training sequence length | 9,216 tokens: up to 8,192 prompt tokens and 1,024 completion tokens | | Training dates | July-August 2026 | | License | MIT | | Repository | microsoft/UserRepGen-4B |
Key capabilities
- Generates structured task and user-behavior descriptions from multi-turn
user-assistant conversations.
- Captures conversational behavior including communication style, request
formulation, incremental constraint disclosure, response patterns, feedback, context provision, engagement, and termination behavior.
- Produces representations that improve conversation-reconstruction fidelity
when used with an unseen LLM-based simulation environment.
- Captures some user-specific behavioral patterns that transfer across
conversations and unseen tasks.
- Produces representations that can help simulated populations better preserve
the behavioral diversity of source conversations.
- Produces behavior descriptions that improve same-user conversation matching
in the accompanying research's re-identification evaluation. This capability also presents a privacy risk; representations are not anonymized data.
How to use
The intended workflow is:
1. Select a conversation that you are authorized to process, minimizing or removing identifying and sensitive information. 2. Format the conversation using the model's inference prompt and chat template. 3. Generate a representation and validate it as JSON containing task and user_behavior fields. 4. Review the descriptions for unsupported inferences, sensitive information, and task-specific leakage. 5. Pass the reviewed representation to a separate LLM-based user simulator.
Quickstart
The following example uses Hugging Face Transformers. The conversation is a newly written, simplified example inspired by an Excel-help conversation in WildChat; it is not an original user transcript.
import json
from pathlib import Path
import torch
from huggingface_hub import hf_hub_download
from transformers import AutoModelForImageTextToText, AutoTokenizer
model_id = "microsoft/UserRepGen-4B"
device = "cuda" if torch.cuda.is_available() else "cpu"
if device == "cpu":
torch.set_num_threads(8)
conversation = [
{"role": "user", "content": "I need an Excel formula to count dates in A2:A100 before today plus B1."},
{"role": "assistant", "content": 'Try =COUNTIF(A2:A100,"0").'},
]
template = Path(
hf_hub_download(model_id, "representation_prompt.txt")
).read_text(encoding="utf-8").strip()
history = "\n".join(f"[{m['role']}]: {m['content']}" for m in conversation)
prompt = template.format(conversation_history=history)
tokenizer = AutoTokenizer.from_pretrained(model_id)
inputs = tokenizer.apply_chat_template(
[{"role": "user", "content": prompt}],
tokenize=True,
add_generation_prompt=True,
enable_thinking=False,
return_tensors="pt",
return_dict=True,
)
prompt_length = inputs["input_ids"].shape[1]
if prompt_length > 8192:
raise ValueError("The formatted prompt exceeds the 8,192-token limit.")
model = AutoModelForImageTextToText.from_pretrained(
model_id,
dtype=torch.float32 if device == "cpu" else torch.bfloat16,
device_map=device,
).eval()
with torch.inference_mode():
output = model.generate(
**inputs.to(device),
max_new_tokens=1024,
do_sample=False,
temperature=None,
top_p=None,
top_k=None,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id,
)
text = tokenizer.decode(output[0, prompt_length:], skip_special_tokens=True).strip()
representation = json.loads(text)
if (
not isinstance(representation, dict)
or set(representation) != {"task", "user_behavior"}
or not all(isinstance(value, str) and value.strip() for value in representation.values())
):
raise ValueError("Expected nonempty task and user_behavior strings.")
print(json.dumps(representation, indent=2))The [standalone example script](./example.py) runs the same conversation and also accepts a JSON list of role/content messages:
hf download microsoft/UserRepGen-4B example.py --local-dir userrepgen-example python userrepgen-example/example.py --device cuda # To use your own authorized conversation: python userrepgen-example/example.py --device cuda --conversation conversation.json
Use --device cpu when a suitable GPU is not available. The script accepts --model /path/to/local/model for an already downloaded model directory. While the repository is private, authenticate with hf auth login using an account with read access.
The example uses greedy decoding for a simple smoke test, not the sampling settings used for the paper's evaluations. Invalid JSON or missing/empty fields raise an error rather than silently repairing the model's output.
Example output
The following is the actual output from the standalone example above, run on CPU using the published Hugging Face checkpoint. The prompt contained 481 tokens and generation produced 274 tokens, including the end-of-sequence token. Outputs may vary with runtime, hardware, or generation settings.
Show generated task and...
Excerpt shown — open the source for the full document.
Notability
notability 7.0/10Notable model release from Microsoft.