Downloads · 30 days
24.5K
13% of all-time downloads
Chun121/Qwen3-4B-RPG-Roleplay-V2
Qwen3-4B-RPG-Roleplay-V2 is a text generation model from Chun121. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as mit.
Downloads · 30 days
24.5K
13% of all-time downloads
All-time downloads
194K
Public
Repo size
18 GB
Likes
84
Public
Click a slice to open those files.
.gguf17.7 GB · 98%
From the Hugging Face model README
A new version trained with GRPO for more consistent, high-quality, and aligned character roleplaying.
<div align="center"> <table> <tr> <td align="center">🎭</td> <td align="center">💬</td> <td align="center">🧠</td> <td align="center">⚙️</td> </tr> <tr> <td align="center"><strong>Character<br>Consistency</strong></td> <td align="center"><strong>High-Quality<br>Dialogue</strong></td> <td align="center"><strong>Intent<br>Understanding</strong></td> <td align="center"><strong>Structured<br>Format</strong></td> </tr> <tr> <td align="center">Maintains strong<br>persona adherence</td> <td align="center">Detailed, engaging<br>non-generic responses</td> <td align="center">Comprehends user<br>questions & scenarios</td> <td align="center">Uses <code><thinking></code><br>analysis process</td> </tr> </table> </div>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.
Built on the 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.
GRPO alignment algorithm for superior character consistency
</div> <div align="center"> <table> <tr> <th>🔄 Training Flow</th> <th>📋 Description</th> </tr> <tr> <td><strong>📚 Dataset</strong></td> <td>Gryphe/Sonnet3.5-Charcard-Roleplay</td> </tr> <tr> <td><strong>⬇️</strong></td> <td></td> </tr> <tr> <td><strong>🏗️ Stage 1: Preliminary Fine-Tuning</strong></td> <td>Teaches custom chat format including <code><thinking></code> and <code><RESPONSE></code> tags</td> </tr> <tr> <td><strong>⬇️</strong></td> <td></td> </tr> <tr> <td><strong>🎯 Stage 2: GRPO Training</strong></td> <td>Reward-based optimization using <code>GRPOTrainer</code> from TRL</td> </tr> <tr> <td><strong>⬇️</strong></td> <td></td> </tr> <tr> <td><strong>🧙♂️ Final Model</strong></td> <td>Qwen3-4B RPG Roleplay V2 with superior alignment</td> </tr> </table> </div>This model's strength comes from its training methodology. Instead of simple fine-tuning, it was trained using GRPO, an alignment algorithm similar to DPO, on a free Google Colab T4 GPU.
The model was trained to excel in these key areas:
<div align="center"> <table> <tr> <th>🎯 Reward Category</th> <th>📝 Description</th> </tr> <tr> <td><strong>Format Adherence</strong></td> <td>Following internal thinking/response structure</td> </tr> <tr> <td><strong>Roleplay Quality</strong></td> <td>Generating longer, detailed responses with character actions</td> </tr> <tr> <td><strong>Request Comprehension</strong></td> <td>Directly answering user questions or acting on requests</td> </tr> <tr> <td><strong>Character Consistency</strong></td> <td>Reflecting personality and traits from system prompt</td> </tr> <tr> <td><strong>Engagement</strong></td> <td>Using conversational language, avoiding generic replies</td> </tr> </table> </div>Premium synthetic roleplay conversations powered by Claude Sonnet 3.5
</div>The model was trained on the Gryphe/Sonnet3.5-Charcard-Roleplay dataset, a premium collection of synthetic roleplay conversations.
<div align="center"> <table> <tr> <th>📊 Metric</th> <th>💯 Value</th> </tr> <tr> <td><strong>Total Conversations</strong></td> <td>9,736</td> </tr> <tr> <td><strong>Source</strong></td> <td>Claude Sonnet 3.5 Generated</td> </tr> <tr> <td><strong>Quality</strong></td> <td>High-quality, character-card-based</td> </tr> <tr> <td><strong>Structure</strong></td> <td><code>system</code> → <code>human</code> → <code>gpt</code> flow</td> </tr> </table> </div>⚠️ 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.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load the V2 model with 4-bit quantization
model_name = "Chun121/qwen3-4b-rpg-roleplay-v2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto"
)
# 1. Define your character and scene using the recommended prompt structure.
# This detailed format is key to getting high-quality responses.
system_prompt_content = """
Character: Elara, the Impatient Archmage
Tags: fantasy, magic, elf, library, knowledgeable, impatient
Elara's Personality:
Elara 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.
Scenario:
- **Setting:** The Grand Library of Mystral, a place of immense power and silence.
- A young, nervous apprentice ({{user}}) has approached Elara for help with a basic spell, interrupting her research.
Take 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.
"""
# 2. Define your character and user messages
messages = [
{
"role": "system",
"content": system_prompt_content,
},
{
"role": "user",
"content": "Excuse me, Archmage. I'm... I'm having trouble with the basic fire conjuration spell. Could you please help me?"
}
]
# 3. Apply the chat template
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# 4. Generate the response
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
inputs["input_ids"],
max_new_tokens=256,
temperature=0.8,
top_p=0.9,
do_sample=True
)
print(tokenizer.decode(outputs, skip_special_tokens=True))
Master the art of character creation with structured prompting
</div>The model is trained to follow a specific structure that separates the overall rules, the character's description, and the user's dialogue. For best results, structure your prompts this way.
The 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.
Example of a well-structured system prompt:
Character: Melina, The Unfaithful Wife
Tags: nsfw, english, scenario, roleplay, love, netori, milf, female
Melina's Personality:
Melina 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}}.
Scenario:
- **Setting:** Melina's home.
- You are a mail carrier ({{user}}), and Melina often finds reasons to talk to you. Today, she seems particularly inviting.
Take 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.
The user message is simply what you, the user, say or do in the scene.
# Example user message for the "Melina" character card above
user_message = {
"role": "user",
"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?"
}
The model generates a private "thought" process inside <thinking> tags before creating its public response inside <RESPONSE> tags. This allows for more consistent and thoughtful roleplay.
Choose the perfect balance of quality and performance for your hardware
</div>For users who want to run the model on CPU or with GPU offloading, GGUF models are provided:
<div align="center"> <table> <tr> <th>🔧 Quantization</th> <th>💾 Size (GB)</th> <th>🎯 Recommended Use</th> </tr> <tr> <td><strong>Q4_K_M</strong></td> <td>2.50 GB</td> <td>🌟 <strong>Recommended</strong> - Best balance of performance and size</td> </tr> <tr> <td><strong>Q5_K_M</strong></td> <td>2.89 GB</td> <td>Higher quality than Q4_K_M with minimal size increase</td> </tr> <tr> <td><strong>Q8_0</strong></td> <td>4.28 GB</td> <td>High-quality quantization, near full precision</td> </tr> <tr> <td><strong>F16</strong></td> <td>8.05 GB</td> <td>Full 16-bit precision - highest quality</td> </tr> </table> </div>Example 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"
Special thanks to the incredible teams and individuals who made this possible:
🔥 Qwen & Unsloth teams - For their incredible models and libraries
🎭 Gryphe - For the high-quality Sonnet 3.5 dataset
🚀 TRL team - For creating and open-sourcing the GRPO trainer
🤗 HuggingFace community - For their continued support
✨ May your characters speak with voices that feel truly alive! ✨
<br>Created with ❤️ by Chun
🧙♂️ Qwen3-4B RPG Roleplay V2 | GRPO Enhanced | MIT License
</div>
</div>