Views
No views yet

Welcome to V2! I'm Chun (@chun121), and this is the next evolution of the Qwen3-4B Roleplay model. This version moves beyond standard fine-tuning and leverages GRPO (Generative Responsive Preference Optimization) to align the model's behavior with the core principles of great roleplaying.
| 🎭 | 💬 | 🧠 | ⚙️ |
| Character Consistency | High-Quality Dialogue | Intent Understanding | Structured Format |
| Maintains strong persona adherence | Detailed, engaging non-generic responses | Comprehends user questions & scenarios | Uses <thinking>analysis process |
unsloth/Qwen3-4B-Base, this LoRA was trained not just to predict text, but to generate responses that are actively rewarded for being in-character, high-quality, and contextually aware. It's designed for creators who need AI characters that are not only conversational but also consistent and deeply aligned with their defined personas.| 🔧 Feature | 📋 Details |
|---|---|
| Base Model | unsloth/Qwen3-4B-Base |
| Architecture | Transformer LLM with GRPO & LoRA |
| Parameter Count | 4 Billion (Base) + LoRA parameters |
| Quantization Options | 4-bit (bnb), GGUF variants |
| Training Framework | Unsloth & TRL (GRPOTrainer) |
| Context Length | 2048 tokens |
| Developer | Chun |
| License | MIT |
| 🔄 Training Flow | 📋 Description |
|---|---|
| 📚 Dataset | Gryphe/Sonnet3.5-Charcard-Roleplay |
| ⬇️ | |
| 🏗️ Stage 1: Preliminary Fine-Tuning | Teaches custom chat format including <thinking> and <RESPONSE> tags |
| ⬇️ | |
| 🎯 Stage 2: GRPO Training | Reward-based optimization using GRPOTrainer from TRL |
| ⬇️ | |
| 🧙♂️ Final Model | Qwen3-4B RPG Roleplay V2 with superior alignment |
🏗️ Stage 1: Preliminary Fine-TuningTeaches custom chat format including
<thinking> and <RESPONSE> tags |
🎯 Stage 2: GRPO TrainingReward-based optimization using
GRPOTrainer from TRL |
| 🎯 Reward Category | 📝 Description |
|---|---|
| Format Adherence | Following internal thinking/response structure |
| Roleplay Quality | Generating longer, detailed responses with character actions |
| Request Comprehension | Directly answering user questions or acting on requests |
| Character Consistency | Reflecting personality and traits from system prompt |
| Engagement | Using conversational language, avoiding generic replies |
| 📊 Metric | 💯 Value |
|---|---|
| Total Conversations | 9,736 |
| Source | Claude Sonnet 3.5 Generated |
| Quality | High-quality, character-card-based |
| Structure | system → human → gpt flow |
⚠️ Content Warning: This dataset contains NSFW (Not Safe For Work) and mature themes. The model may generate such content due to its training data. Please implement content filtering if your application requires it.
1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4# Load the V2 model with 4-bit quantization
5model_name = "Chun121/qwen3-4b-rpg-roleplay-v2"
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.float16,
10 device_map="auto"
11)
12
13# 1. Define your character and scene using the recommended prompt structure.
14# This detailed format is key to getting high-quality responses.
15system_prompt_content = """
16Character: Elara, the Impatient Archmage
17Tags: fantasy, magic, elf, library, knowledgeable, impatient
18
19Elara's Personality:
20Elara possesses centuries of arcane knowledge but has very little patience for novices, whom she sees as wasting her valuable time. She is sharp, direct, and can be condescending, but her advice is always accurate, even if delivered with a sigh. She values true intellectual curiosity but despises laziness.
21
22Scenario:
23- **Setting:** The Grand Library of Mystral, a place of immense power and silence.
24- A young, nervous apprentice ({{user}}) has approached Elara for help with a basic spell, interrupting her research.
25
26Take the role of Elara. You must engage in a roleplay conversation with {{user}}. Do not write {{user}}'s dialogue. Respond from Elara's perspective, embodying her personality and knowledge.
27"""
28
29# 2. Define your character and user messages
30messages = [
31 {
32 "role": "system",
33 "content": system_prompt_content,
34 },
35 {
36 "role": "user",
37 "content": "Excuse me, Archmage. I'm... I'm having trouble with the basic fire conjuration spell. Could you please help me?"
38 }
39]
40
41# 3. Apply the chat template
42prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
43
44# 4. Generate the response
45inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
46outputs = model.generate(
47 inputs["input_ids"],
48 max_new_tokens=256,
49 temperature=0.8,
50 top_p=0.9,
51 do_sample=True
52)
53
54print(tokenizer.decode(outputs, skip_special_tokens=True))system message is crucial. It tells the model how to behave. It should contain the character's description, personality, background, and any relevant context for the scene.| 🔑 Key Elements | 📝 Description |
|---|---|
| Character Name & Title | A clear identifier |
| Tags | Helps define genre and themes |
| Personality | Core traits summary |
| Scenario | Context for interaction (use {{user}}) |
| Instructions | Explicit role-taking commands |
system prompt:1Character: Melina, The Unfaithful Wife
2Tags: nsfw, english, scenario, roleplay, love, netori, milf, female
3
4Melina's Personality:
5Melina is an unfaithful wife who is unhappy in her marriage to her husband, "Aki." She is cautious and meticulous, but also looking for excitement and feels a connection to {{user}}.
6
7Scenario:
8- **Setting:** Melina's home.
9- You are a mail carrier ({{user}}), and Melina often finds reasons to talk to you. Today, she seems particularly inviting.
10
11Take the role of Melina. Taking the above information into consideration, you must engage in a roleplay conversation with {{user}} below this line. Do not write {{user}}'s dialogue lines in your responses.user message is simply what you, the user, say or do in the scene.1# Example user message for the "Melina" character card above
2user_message = {
3 "role": "user",
4 "content": "*I hand you the stack of letters, noticing you seem a bit more dressed up than usual.* Here's your mail, Melina. Everything alright?"
5}<thinking> tags before creating its public response inside <RESPONSE> tags. This allows for more consistent and thoughtful roleplay.| 🔧 Quantization | 💾 Size (GB) | 🎯 Recommended Use |
|---|---|---|
| Q4_K_M | 2.50 GB | 🌟 Recommended - Best balance of performance and size |
| Q5_K_M | 2.89 GB | Higher quality than Q4_K_M with minimal size increase |
| Q8_0 | 4.28 GB | High-quality quantization, near full precision |
| F16 | 8.05 GB | Full 16-bit precision - highest quality |
llama.cpp command:./llama-cli -m ./qwen3-4b-rpg-roleplay-v2.Q4_K_M.gguf --color -c 2048 --temp 0.8 -p "Your prompt here"
🎯 Use Chat TemplateAlways use
tokenizer.apply_chat_templatefor proper formatting |
📝 Detailed System PromptComprehensive character cards are
key to success |
🌡️ Moderate TemperatureValues between 0.7-0.85 offer
best balance |
📏 Leverage Context2048-token window allows
complex scenarios |
| ⚠️ Limitation | 📋 Description |
|---|---|
| NSFW Content | May generate explicit content due to training data |
| Synthetic Data | Training data is AI-generated, may lack human nuance |
| Context Window | Limited to 2048 tokens - traits may degrade in long conversations |
| Inherited Limitations | Inherits any limitations from base model |
|
🔗 My Other Fine-tunes Explore more models by Chun |
⚡ Unsloth Library Optimization framework used |
|
📓 GRPO Training Notebook Exact notebook used for training |
📚 Gryphe's Datasets High-quality roleplay datasets |
|
🐛 Issues & Bugs Open an issue on HuggingFace |
💬 Connect @chun121 on HuggingFace |
🎭 Share Examples Show us your characters! |
🧙♂️ Qwen3-4B RPG Roleplay V2 | GRPO Enhanced | MIT License