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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
- lora
|
| 15 |
---
|
| 16 |
|
| 17 |
+
# Sakura-Qwen3-0.6B-LoRA-Demo-v1
|
| 18 |
+
|
| 19 |
+
[](LICENSE)
|
| 20 |
+
[](https://huggingface.co/Qwen/Qwen3-0.6B)
|
| 21 |
+
[](https://huggingface.co/docs/peft/en/index)
|
| 22 |
+
|
| 23 |
+
## Model Description
|
| 24 |
+
|
| 25 |
+
This is a LoRA adapter trained on **Qwen3-0.6B**, specifically optimized for VTuber role-playing in Chinese context. This model endows the AI with VTuber personality traits, speaking style, and character settings, suitable for VTuber interaction scenarios.
|
| 26 |
+
|
| 27 |
+
## Model Details
|
| 28 |
+
|
| 29 |
+
- **Base Model**: Qwen3-0.6B
|
| 30 |
+
- **Adapter Type**: LoRA (Low-Rank Adaptation)
|
| 31 |
+
- **Application**: VTuber role-playing
|
| 32 |
+
- **Language**: Chinese
|
| 33 |
+
- **Version**: Demo v1
|
| 34 |
+
|
| 35 |
+
## Character Settings
|
| 36 |
+
|
| 37 |
+
[Describe the VTuber character information in detail here, for example:]
|
| 38 |
+
- **Character Name**: 小樱(Sakura)
|
| 39 |
+
- **Personality Traits**: Energetic and cute, gentle and considerate, occasionally mischievous
|
| 40 |
+
- **Speaking Style**: Uses specific speech patterns and emojis
|
| 41 |
+
- **Background Story**:
|
| 42 |
+
- **Specialties**: Interacting with audience
|
| 43 |
+
|
| 44 |
+
## Usage
|
| 45 |
+
|
| 46 |
+
### Loading the Model
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
from peft import PeftModel
|
| 50 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 51 |
+
import torch
|
| 52 |
+
|
| 53 |
+
# Load the Qwen3-0.6B chat model and tokenizer
|
| 54 |
+
model_name = "Qwen/Qwen3-0.6B"
|
| 55 |
+
adapter_name = "Boogon/sakura-qwen3-0.6b-lora-demo-v1"
|
| 56 |
+
|
| 57 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 58 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 59 |
+
model_name,
|
| 60 |
+
torch_dtype=torch.float16,
|
| 61 |
+
device_map="auto"
|
| 62 |
+
)
|
| 63 |
+
model = PeftModel.from_pretrained(model, adapter_name)
|
| 64 |
+
```
|
| 65 |
+
|
| 66 |
+
> Note: If you want to save the model into another directory, remember to use argument **cache_dir**.
|
| 67 |
+
|
| 68 |
+
### Chat Example
|
| 69 |
+
|
| 70 |
+
```python
|
| 71 |
+
def chat_with_vtuber(messages, max_length=512):
|
| 72 |
+
"""
|
| 73 |
+
messages format: [
|
| 74 |
+
{"role": "system", "content": ""},
|
| 75 |
+
{"role": "user", "content": "Hello!"},
|
| 76 |
+
{"role": "assistant", "content": "Hi there, my name's Sakura!(*´▽`*)"},
|
| 77 |
+
{"role": "user", "content": "What's new today?"}
|
| 78 |
+
# ...
|
| 79 |
+
]
|
| 80 |
+
"""
|
| 81 |
+
text = tokenizer.apply_chat_template(
|
| 82 |
+
messages,
|
| 83 |
+
tokenize=False,
|
| 84 |
+
add_generation_prompt=True
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 88 |
+
|
| 89 |
+
with torch.no_grad():
|
| 90 |
+
outputs = model.generate(
|
| 91 |
+
**inputs,
|
| 92 |
+
max_new_tokens=max_length,
|
| 93 |
+
temperature=0.8,
|
| 94 |
+
top_p=0.9,
|
| 95 |
+
do_sample=True,
|
| 96 |
+
repetition_penalty=1.1,
|
| 97 |
+
eos_token_id=tokenizer.eos_token_id
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
response = tokenizer.decode(outputs[0][inputs['input_ids'].shape[1]:], skip_special_tokens=True)
|
| 101 |
+
return response
|
| 102 |
+
|
| 103 |
+
# Example conversation
|
| 104 |
+
messages = [
|
| 105 |
+
{"role": "system", "content": "You are Sakura-chan, a cute VTuber who loves interacting with fans. You speak in a cheerful, cute style with occasional Japanese phrases and emojis."},
|
| 106 |
+
{"role": "user", "content": "Hello Sakura-chan! How are you today?"}
|
| 107 |
+
]
|
| 108 |
+
|
| 109 |
+
response = chat_with_vtuber(messages)
|
| 110 |
+
print(f"Sakura: {response}")
|
| 111 |
+
```
|
| 112 |
+
|
| 113 |
+
### Direct Chat Template Usage
|
| 114 |
+
|
| 115 |
+
```python
|
| 116 |
+
# Alternative method using chat template directly
|
| 117 |
+
conversation = [
|
| 118 |
+
{"role": "user", "content": "What games do you like to play?"}
|
| 119 |
+
]
|
| 120 |
+
|
| 121 |
+
# Apply chat template
|
| 122 |
+
text = tokenizer.apply_chat_template(
|
| 123 |
+
conversation,
|
| 124 |
+
tokenize=False,
|
| 125 |
+
add_generation_prompt=True
|
| 126 |
+
)
|
| 127 |
+
|
| 128 |
+
inputs = tokenizer(text, return_tensors="pt").to(model.device)
|
| 129 |
+
|
| 130 |
+
outputs = model.generate(
|
| 131 |
+
**inputs,
|
| 132 |
+
max_new_tokens=256,
|
| 133 |
+
temperature=0.7,
|
| 134 |
+
do_sample=True
|
| 135 |
+
)
|
| 136 |
+
|
| 137 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 138 |
+
print(response)
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## Training Information
|
| 142 |
+
|
| 143 |
+
- **Training Data**: n/a
|
| 144 |
+
- **Training Objective**: Learn VTuber's dialogue style, personality traits, and interaction patterns
|
| 145 |
+
- **LoRA Configuration**:
|
| 146 |
+
- r: 16
|
| 147 |
+
- lora_alpha: 32
|
| 148 |
+
- target_modules: ["q_proj", "k_proj", "v_proj", "o_proj", "gate_proj", "up_proj", "down_proj"]
|
| 149 |
+
- lora_dropout: 0.05
|
| 150 |
+
- **Training Framework**: PEFT
|
| 151 |
+
|
| 152 |
+
## Features
|
| 153 |
+
|
| 154 |
+
- Character-consistent dialogue
|
| 155 |
+
- Emotional expression with emojis
|
| 156 |
+
- Context-adaptive responses
|
| 157 |
+
- Fan interaction simulation
|
| 158 |
+
- Multi-turn conversation support
|
| 159 |
+
|
| 160 |
+
## License
|
| 161 |
+
|
| 162 |
+
- Base Model: Apache 2.0
|
| 163 |
+
- Adapter: Apache 2.0
|
| 164 |
+
|
| 165 |
+
## Important Notes
|
| 166 |
+
|
| 167 |
+
**Important Notes**:
|
| 168 |
+
- This is a demo version and may have unstable responses
|
| 169 |
+
- Not for commercial use
|
| 170 |
+
- Character dialogue content is fictional and unrelated to real persons
|
| 171 |
+
- The model is optimized for Chinese VTuber role-playing scenarios
|
| 172 |
+
|
| 173 |
+
## Contributing & Feedback
|
| 174 |
+
|
| 175 |
+
Welcome to submit feedback or suggestions through Issues!
|
| 176 |
+
|
| 177 |
+
Anything related can be sent to [Sakura-Adapters](https://github.com/BoogonAgora/Sakura-Adapters)
|
| 178 |
+
|