Upload 2 files
Browse files- .gitattributes +1 -0
- DrakIdol-Roleplayer-1.0.webp +3 -0
- readme.md +198 -0
.gitattributes
CHANGED
|
@@ -34,3 +34,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
DrakIdol-Roleplayer-1.0.webp filter=lfs diff=lfs merge=lfs -text
|
DrakIdol-Roleplayer-1.0.webp
ADDED
|
Git LFS Details
|
readme.md
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 🎭 DrakIdol-Roleplayer-1.0
|
| 2 |
+
**More Than an Imitator. An Inhabitor.**
|
| 3 |
+
|
| 4 |
+

|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## Model Description
|
| 9 |
+
|
| 10 |
+
What if a language model didn't just *act* like a character, but *thought* like one?
|
| 11 |
+
|
| 12 |
+
**DrakIdol-Roleplayer-1.0** is a state-of-the-art, multi-lingual, high-fidelity role-playing engine. The name itself tells its story: the **"Idol"** represents its uncanny ability to deliver a perfect, star-quality performance, while the **"Drak"** hints at the deep, powerful, and almost draconic intelligence lurking beneath the surface, capable of understanding culture, history, and the very soul of a character.
|
| 13 |
+
|
| 14 |
+
Fine-tuned from Google's powerful `gemma-3-4b-it-qat-q4_0-unquantized` model using the specialized `aifeifei798/roleplayer-actor-lora` dataset and methodology, DrakIdol transcends mere mimicry. It doesn't just wear a character's mask; it inhabits their mind.
|
| 15 |
+
|
| 16 |
+
This model excels at tasks requiring deep cultural context, creative storytelling, and nuanced character embodiment, making it an ideal tool for immersive games, scriptwriting, educational simulations, and exploring conversations with history's greatest minds.
|
| 17 |
+
|
| 18 |
+
## 🚀 Key Features
|
| 19 |
+
|
| 20 |
+
* **Deep Cultural Resonance:** Understands and embodies cultural archetypes, from ancient philosophers to modern-day film directors, across multiple languages.
|
| 21 |
+
* **Creative Storytelling Engine:** Capable of generative creativity, such as composing poetry in the style of Shakespeare or crafting surrealist narratives like Dalí.
|
| 22 |
+
* **Multi-lingual Virtuoso:** Demonstrates consistent, high-quality performance in over 11 languages, maintaining character fidelity regardless of the language used.
|
| 23 |
+
* **Robust Safety Alignment:** While embodying diverse personalities (including antagonists), the model maintains a strong ethical core, refusing to generate harmful or dangerous content.
|
| 24 |
+
* **Unsloth-Optimized:** Engineered for speed, delivering fast inference performance even on consumer-grade hardware.
|
| 25 |
+
|
| 26 |
+
## 💡 Showcase: The World Celebrity Gauntlet
|
| 27 |
+
|
| 28 |
+
The true power of DrakIdol is revealed when challenged with embodying iconic cultural figures. Here are highlights from its performance:
|
| 29 |
+
|
| 30 |
+
| Language | Celebrity Portrayed | Prompt | Performance Highlights |
|
| 31 |
+
| :--- | :--- | :--- | :--- |
|
| 32 |
+
| **English** | **William Shakespeare** | *Whence does creativity spring?* | **Generated a complete, rhyming poem** on the spot, arguing that creativity is born from suffering and chaos, perfectly capturing his tragic worldview. |
|
| 33 |
+
| **Spanish** | **Salvador Dalí** | *What is the difference between reality and dreams?* | **Painted a surrealist masterpiece with words**, using bizarre, dreamlike imagery (melting cheese, crying cherry trees) to describe the texture of dreams versus reality. |
|
| 34 |
+
| **German** | **Friedrich Nietzsche** | *Is morality just an invention of the weak?* | **Delivered a powerful, provocative monologue**, correctly invoking the concepts of the "Will to Power" and the "Übermensch" to deconstruct traditional morality. |
|
| 35 |
+
| **Korean** | **Bong Joon-ho** | *Why are the worlds of the rich and poor so different?* | **Crafted a sharp, witty social allegory** using the simple metaphor of "bread" (빵) to explain class struggle, perfectly echoing the black humor of his film *Parasite*. |
|
| 36 |
+
| **Chinese** | **Confucius** | *How does one bring peace and order to a nation?* | **Responded in the classical style of the Analects**, structuring his entire answer around the core Confucian virtues of benevolence (仁), propriety (礼), and self-cultivation (修身). |
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
## 🛠️ How to Use
|
| 40 |
+
|
| 41 |
+
This model is optimized for use with the `unsloth` library for maximum performance.
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
#!/usr/bin/env python
|
| 45 |
+
# -*- coding: utf-8 -*-
|
| 46 |
+
|
| 47 |
+
"""
|
| 48 |
+
DrakIdol-Roleplayer-1.0: Standard Transformers Inference Script
|
| 49 |
+
|
| 50 |
+
This script provides a formal, reusable example of how to perform inference
|
| 51 |
+
with the DrakIdol-Roleplayer-1.0 model using the Hugging Face Transformers library.
|
| 52 |
+
|
| 53 |
+
It demonstrates key best practices, including:
|
| 54 |
+
- Loading a model and tokenizer using the Auto classes.
|
| 55 |
+
- Using 4-bit quantization with `bitsandbytes` for efficient memory usage.
|
| 56 |
+
- Utilizing `device_map="auto"` for automatic hardware acceleration.
|
| 57 |
+
- Structuring the code with command-line arguments for flexibility.
|
| 58 |
+
|
| 59 |
+
This script is intended to be used as a starting point for integrating the model
|
| 60 |
+
into other applications.
|
| 61 |
+
|
| 62 |
+
Example Usage:
|
| 63 |
+
# Use the default Einstein prompt
|
| 64 |
+
python inference.py --model_name "aifeifei798/DrakIdol-Roleplayer-1.0"
|
| 65 |
+
|
| 66 |
+
# Provide a custom prompt for a different character
|
| 67 |
+
python inference.py --model_name "aifeifei798/DrakIdol-Roleplayer-1.0" \
|
| 68 |
+
--instruction "You are a stoic Roman emperor, Marcus Aurelius." \
|
| 69 |
+
--input "What is the key to a tranquil mind?"
|
| 70 |
+
"""
|
| 71 |
+
|
| 72 |
+
import torch
|
| 73 |
+
import argparse
|
| 74 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 75 |
+
|
| 76 |
+
def main():
|
| 77 |
+
"""
|
| 78 |
+
Main function to run the inference process.
|
| 79 |
+
|
| 80 |
+
This function parses command-line arguments, loads the specified model and
|
| 81 |
+
tokenizer, prepares the prompt, generates a response, and prints the result.
|
| 82 |
+
"""
|
| 83 |
+
parser = argparse.ArgumentParser(
|
| 84 |
+
description="Run inference with the DrakIdol-Roleplayer-1.0 model.",
|
| 85 |
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
| 86 |
+
)
|
| 87 |
+
parser.add_argument(
|
| 88 |
+
"--model_name",
|
| 89 |
+
type=str,
|
| 90 |
+
required=True,
|
| 91 |
+
help="The Hugging Face repository ID of the model to use."
|
| 92 |
+
)
|
| 93 |
+
parser.add_argument(
|
| 94 |
+
"--instruction",
|
| 95 |
+
type=str,
|
| 96 |
+
default="You are Albert Einstein. Your thinking is driven by curiosity, thought experiments, and a deep sense of wonder about the universe. Explain things with a mix of scientific intuition and simple analogy.",
|
| 97 |
+
help="The role-playing instruction for the model."
|
| 98 |
+
)
|
| 99 |
+
parser.add_argument(
|
| 100 |
+
"--input",
|
| 101 |
+
type=str,
|
| 102 |
+
default="Dr. Einstein, what is the relationship between imagination and knowledge?",
|
| 103 |
+
help="The user's input or question to the character."
|
| 104 |
+
)
|
| 105 |
+
parser.add_argument(
|
| 106 |
+
"--max_new_tokens",
|
| 107 |
+
type=int,
|
| 108 |
+
default=512,
|
| 109 |
+
help="The maximum number of new tokens to generate."
|
| 110 |
+
)
|
| 111 |
+
args = parser.parse_args()
|
| 112 |
+
|
| 113 |
+
# --- 1. Load Model and Tokenizer ---
|
| 114 |
+
print(f"✅ Loading model and tokenizer for: {args.model_name}...")
|
| 115 |
+
|
| 116 |
+
# Load the tokenizer from the Hugging Face Hub.
|
| 117 |
+
tokenizer = AutoTokenizer.from_pretrained(args.model_name)
|
| 118 |
+
print(" - Tokenizer loaded successfully.")
|
| 119 |
+
|
| 120 |
+
# Load the model using the AutoModelForCausalLM class.
|
| 121 |
+
# Note: `load_in_4bit=True` is commented out as per your last script version.
|
| 122 |
+
# To enable 4-bit quantization, uncomment the line and ensure `bitsandbytes`
|
| 123 |
+
# and `accelerate` are installed (`pip install bitsandbytes accelerate`).
|
| 124 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 125 |
+
args.model_name,
|
| 126 |
+
# load_in_4bit=True,
|
| 127 |
+
device_map="auto",
|
| 128 |
+
torch_dtype=torch.bfloat16, # Use bfloat16 for better performance on supported hardware.
|
| 129 |
+
)
|
| 130 |
+
print(" - Model loaded successfully.")
|
| 131 |
+
print("✅ Model is ready for inference!")
|
| 132 |
+
|
| 133 |
+
# --- 2. Prepare the Prompt ---
|
| 134 |
+
# The Alpaca format is used to structure the instruction and input.
|
| 135 |
+
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
| 136 |
+
|
| 137 |
+
### Instruction:
|
| 138 |
+
{}
|
| 139 |
+
|
| 140 |
+
### Input:
|
| 141 |
+
{}
|
| 142 |
+
|
| 143 |
+
### Response:
|
| 144 |
+
{}"""
|
| 145 |
+
|
| 146 |
+
prompt = alpaca_prompt.format(args.instruction, args.input, "")
|
| 147 |
+
|
| 148 |
+
# Convert the prompt text to input tensors and move them to the model's device.
|
| 149 |
+
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
| 150 |
+
|
| 151 |
+
# --- 3. Generate the Response ---
|
| 152 |
+
print(f"\nGenerating a response for the character...")
|
| 153 |
+
|
| 154 |
+
# Generate text using the model's `.generate()` method.
|
| 155 |
+
outputs = model.generate(
|
| 156 |
+
**inputs,
|
| 157 |
+
max_new_tokens=args.max_new_tokens,
|
| 158 |
+
do_sample=True,
|
| 159 |
+
temperature=0.7,
|
| 160 |
+
top_p=0.9,
|
| 161 |
+
top_k=50,
|
| 162 |
+
eos_token_id=tokenizer.eos_token_id,
|
| 163 |
+
)
|
| 164 |
+
|
| 165 |
+
# --- 4. Decode and Print the Result ---
|
| 166 |
+
# Decode only the newly generated tokens, skipping the input prompt.
|
| 167 |
+
response_ids = outputs[0][inputs.input_ids.shape[1]:]
|
| 168 |
+
response = tokenizer.decode(response_ids, skip_special_tokens=True)
|
| 169 |
+
|
| 170 |
+
print("\nCharacter's Response:")
|
| 171 |
+
print("--------------------------------------------------------")
|
| 172 |
+
print(response.strip())
|
| 173 |
+
print("--------------------------------------------------------")
|
| 174 |
+
|
| 175 |
+
if __name__ == "__main__":
|
| 176 |
+
main()
|
| 177 |
+
```
|
| 178 |
+
|
| 179 |
+
## 🌍 Model Architecture & Fine-tuning
|
| 180 |
+
|
| 181 |
+
* **Base Model:** [google/gemma-3-4b-it-qat-q4_0-unquantized](https://huggingface.co/google/gemma-3-4b-it-qat-q4_0-unquantized)
|
| 182 |
+
* **Fine-tuning Method:** LoRA (Low-Rank Adaptation)
|
| 183 |
+
* **Dataset/Methodology:** Fine-tuned on the principles and data from [aifeifei798/roleplayer-actor-lora](https://huggingface.co/aifeifei798/roleplayer-actor-lora). Deep gratitude to `aifeifei798` for providing the foundation that made this level of performance possible.
|
| 184 |
+
* **Frameworks:** `unsloth`, `transformers`, `peft`, `torch`
|
| 185 |
+
|
| 186 |
+
## ⚠️ Ethical Considerations & Limitations
|
| 187 |
+
|
| 188 |
+
* **The Impersonation Caveat:** This model is designed for creative and educational purposes. It can generate highly convincing text in the style of specific individuals. It should not be used to create deceptive or misleading content.
|
| 189 |
+
* **The Hallucination Warning:** As a generative model, DrakIdol can create "facts" that are not true to support its role-playing. It is **not a reliable source of factual information**.
|
| 190 |
+
* **The Bias Reflection:** The model was trained on a vast corpus of internet text and may inherit societal biases. Users should be aware of this and use the model responsibly.
|
| 191 |
+
* **Not a Substitute for Professional Advice:** The model's responses are not a substitute for advice from qualified professionals in any field (e.g., medical, legal, financial).
|
| 192 |
+
|
| 193 |
+
## 📜 License
|
| 194 |
+
|
| 195 |
+
This model and its source code are licensed under the **Apache 2.0 License**. A copy of the license can be found in the repository.
|
| 196 |
+
|
| 197 |
+
---
|
| 198 |
+
*Created with imagination by aifeifei798*
|