Downloads · 30 days
0
WompWomp1/Unified-Character-Model-DeepSeek
Unified-Character-Model-DeepSeek is a machine learning model from WompWomp1. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is a fine-tuned DeepSeek-R1-Distill-Qwen-1.5B model that can roleplay as multiple characters based on the prompt.
Downloads · 30 days
0
Access
Public
Updated Mar 30, 2025
Repo size
26.6 MB
Likes
0
Public
Click a slice to open those files.
.safetensors34.9 MB · 68%
From the Hugging Face model README
This is a fine-tuned DeepSeek-R1-Distill-Qwen-1.5B model that can roleplay as multiple characters based on the prompt.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
# Load base model with appropriate configuration
base_model = AutoModelForCausalLM.from_pretrained(
"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",
device_map="auto",
torch_dtype=torch.float16,
trust_remote_code=True
)
tokenizer = AutoTokenizer.from_pretrained("deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B")
# Load adapter weights
model = PeftModel.from_pretrained(base_model, "WompWomp1/Unified-Character-Model-DeepSeek")
# Function to generate responses for different characters
def generate_character_response(character_name, conversation, max_tokens=100):
# Format the prompt
prompt = f"""You are a roleplaying AI. Your role is to respond as {character_name}. When given a conversation, only respond with what {character_name} would say next.\n\nPrevious conversation:\n```\n{conversation}\n```\n\nIt's now {character_name}'s turn to speak. Respond in {character_name}'s voice and personality."""
# Generate response
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(
input_ids=inputs.input_ids,
max_new_tokens=max_tokens,
temperature=0.7,
do_sample=True,
top_p=0.92,
repetition_penalty=1.2,
no_repeat_ngram_size=3
)
# Extract only the generated response
full_response = tokenizer.decode(outputs[0], skip_special_tokens=True)
prompt_decoded = tokenizer.decode(inputs.input_ids[0], skip_special_tokens=True)
return full_response[len(prompt_decoded):]
# Example usage
conversation = "User: Hello! How are you doing today?"
response = generate_character_response("Ami", conversation)
print(f"Ami: {response}")
response = generate_character_response("Sensei", conversation)
print(f"Sensei: {response}")
If you notice the model repeating phrases, try these settings:
repetition_penalty (try values between 1.1 and 1.5)no_repeat_ngram_size (values between 2-4 work well)temperature slightly (0.6-0.7 range often works best)top_p (0.9-0.95) and top_k (40-50) together