Instructions to use Chun121/qwen3-4B-rpg-roleplay with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Chun121/qwen3-4B-rpg-roleplay with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Chun121/qwen3-4B-rpg-roleplay") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Chun121/qwen3-4B-rpg-roleplay", dtype="auto") - llama-cpp-python
How to use Chun121/qwen3-4B-rpg-roleplay with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="Chun121/qwen3-4B-rpg-roleplay", filename="gguf_f16/unsloth.F16.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use Chun121/qwen3-4B-rpg-roleplay with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M # Run inference directly in the terminal: llama-cli -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Use Docker
docker model run hf.co/Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use Chun121/qwen3-4B-rpg-roleplay with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Chun121/qwen3-4B-rpg-roleplay" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Chun121/qwen3-4B-rpg-roleplay", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
- SGLang
How to use Chun121/qwen3-4B-rpg-roleplay with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Chun121/qwen3-4B-rpg-roleplay" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Chun121/qwen3-4B-rpg-roleplay", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Chun121/qwen3-4B-rpg-roleplay" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Chun121/qwen3-4B-rpg-roleplay", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use Chun121/qwen3-4B-rpg-roleplay with Ollama:
ollama run hf.co/Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
- Unsloth Studio new
How to use Chun121/qwen3-4B-rpg-roleplay with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Chun121/qwen3-4B-rpg-roleplay to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Chun121/qwen3-4B-rpg-roleplay to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Chun121/qwen3-4B-rpg-roleplay to start chatting
- Pi new
How to use Chun121/qwen3-4B-rpg-roleplay with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "Chun121/qwen3-4B-rpg-roleplay:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use Chun121/qwen3-4B-rpg-roleplay with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use Chun121/qwen3-4B-rpg-roleplay with Docker Model Runner:
docker model run hf.co/Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
- Lemonade
How to use Chun121/qwen3-4B-rpg-roleplay with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Chun121/qwen3-4B-rpg-roleplay:Q4_K_M
Run and chat with the model
lemonade run user.qwen3-4B-rpg-roleplay-Q4_K_M
List all available models
lemonade list
๐งโโ๏ธ Qwen3-4B Roleplay LoRA
Where Characters Come Alive in Conversation
Breathe life into your digital companions with natural, engaging dialogue
โจ Model Overview
Welcome, fellow creators! I'm Chun (@chun121), and I've fine-tuned the impressive Qwen3-4B model to excel at character-based conversations and roleplay scenarios. Whether you're crafting an immersive game, building an interactive storytelling platform, or developing character-driven AI experiences, this model will help your characters speak with personality, consistency, and depth.
This LoRA adaptation maintains the intelligence of the base model while enhancing its ability to:
- ๐ญ Maintain consistent character personas
- ๐ฌ Generate authentic dialogue that reflects character traits
- ๐ Create immersive narrative responses
- ๐ง Remember context throughout conversations
๐ Technical Specifications
| Feature | Details |
|---|---|
| Base Model | Qwen3-4B |
| Architecture | Transformer-based LLM with LoRA adaptation |
| Parameter Count | 4 Billion (Base) + LoRA parameters |
| Quantization Options | 4-bit (bnb), GGUF formats (Q8_0, F16, Q4_K_M) |
| Training Framework | Unsloth & TRL |
| Context Length | 512 tokens |
| Developer | Chun |
| License | Apache 2.0 |
๐ง Training Methodology
This LoRA was trained on a free Google Colab T4 GPU using efficient quantization techniques to maximize the limited resources:
- Dataset: PJMixers-Dev/Gryphe-Aesir-RPG-Charcards-Opus-Mixed-split
- LoRA Configuration:
- Rank: 16
- Alpha: 32
- Target Modules: Optimized for character dialogue generation
- Training Hyperparameters:
- Batch Size: 8
- Gradient Accumulation Steps: 4
- Learning Rate: 1e-4 with cosine scheduler
- Max Steps: 200
- Precision: FP16/BF16 (auto-detected)
- Packing: Enabled for efficient training
- QLoRA: 4-bit quantization via bitsandbytes
๐ Dataset Deep Dive
The Gryphe-Aesir-RPG-Charcards-Opus-Mixed-split dataset is a rich collection of character interactions featuring:
- Diverse character archetypes across different genres
- Multi-turn conversations that maintain character consistency
- Varied emotional contexts and scenarios
- Rich descriptive language and character-driven responses
This carefully curated dataset helps the model understand the nuances of character voices, maintaining consistent personalities while generating engaging responses.
๐ Getting Started
Hugging Face Transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
# Load model with 4-bit quantization for efficiency
tokenizer = AutoTokenizer.from_pretrained("chun121/qwen3-4b-roleplay-lora")
model = AutoModelForCausalLM.from_pretrained(
"chun121/qwen3-4b-roleplay-lora",
torch_dtype=torch.float16, # Use float16 for faster inference
device_map="auto" # Automatically choose best device
)
# Create a character-focused prompt
character_prompt = """
Character: Elara, an elven mage with centuries of knowledge but little patience for novices
Setting: The Grand Library of Mystral
Context: A young apprentice has asked for help with a difficult spell
User: Excuse me, I'm having trouble with the fire conjuration spell. Could you help me?
Elara:
"""
# Generate response
inputs = tokenizer(character_prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
inputs["input_ids"],
max_new_tokens=200,
temperature=0.7,
top_p=0.9,
do_sample=True
)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Using GGUF Models
If you're utilizing the GGUF exports with llama.cpp:
# Example command for Q4_K_M quantization
./llama -m chun121-qwen3-4b-roleplay-lora.Q4_K_M.gguf -p "Character: Elara, an elven mage..." -n 200
๐ก Recommended Usage
This model works best when:
- Providing character context: Include a brief description of the character's personality, background, and current situation
- Setting the scene: Give context about the environment and circumstances
- Using chat format: Structure inputs as a conversation between User/Human and Character
- Maintaining temperature: Values between 0.7-0.8 offer a good balance of creativity and coherence
๐ Limitations
- Limited to 512 token context window
- May occasionally "forget" character traits in very long conversations
- Training dataset focuses primarily on fantasy/RPG contexts
- As a LoRA fine-tune, inherits limitations of the base Qwen3-4B model
๐ Related Projects
If you enjoy this model, check out these related projects:
๐ Acknowledgements
Special thanks to:
- The Qwen team for their incredible base model
- PJMixers-Dev for the high-quality dataset
- The Unsloth team for making efficient fine-tuning accessible
- The HuggingFace community for their continued support
๐ฌ Feedback & Contact
I'd love to hear how this model works for your projects! Feel free to:
- Open an issue on the HuggingFace repo
- Connect with me on HuggingFace @chun121
- Share examples of characters you've created with this model
May your characters speak with voices that feel truly alive!
Created with โค๏ธ by Chun
- Downloads last month
- 262
4-bit
8-bit
16-bit