Qwen2.5-3B Character Imitation
English · 跳转到中文版 →
Speaking-style imitation · full merged model: given a few example quotes from a character, the model answers in that character's tone, word choice, and verbal tics.
This repo is the ws-fy/qwen2.5-3b-character-imitation-lora LoRA adapter merged into the Qwen/Qwen2.5-3B-Instruct base as a standalone FP16 model — ready to use, no adapter mounting required.
| Item | Value |
|---|---|
| Parameters | 3.09 B |
| Precision | FP16 |
| Size | ~6.2 GB (2 shards) |
| Context | 32768 (Qwen2.5 native) |
| Merge method | PEFT 0.18.1 merge_and_unload, merged in FP32 math precision → saved as FP16 |
| Merge source | LoRA r=16, α=32 (LLaMA-Factory SFT, 5 epochs) |
Quantized versions (GGUF, Q2_K / Q3_K_M / Q4_K_M / Q8_0) → ws-fy/qwen2.5-3b-character-imitation-gguf
Training Data
1,500 Chinese style-imitation samples. Each instruction contains a task description plus 2–3 example quotes from the character; the output is a short in-character reply (12–39 characters). The data spans ~626 character archetypes: street-smart auntie, genki girl, programmer, wuxia swordsman, traditional Chinese doctor, scientist, slacker youth, and more.
⚠️ Prompt Format (Important)
The model was trained on a fixed prompt format. Follow this template at inference time (the template text stays in Chinese; substitute your own character quotes):
模仿下面角色语录的说话风格,用同样的语气、用词习惯和口癖回答用户的问题。
语录示例:
“quote 1…”
“quote 2…”
问题:<the user's question>
- Send the full text above as a single user message; compatible with the Qwen2.5 chat template.
- Asking directly without example quotes degrades the result significantly — quote-driven prompting is the intended use.
- Recommended sampling:
temperature 0.8–1.0,top_p 0.9, avoid greedy decoding (repetition).
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"ws-fy/qwen2.5-3b-character-imitation",
torch_dtype=torch.float16, device_map="auto"
)
tok = AutoTokenizer.from_pretrained("ws-fy/qwen2.5-3b-character-imitation")
# Keep the Chinese template — it is the exact format the model was trained on.
prompt = (
"模仿下面角色语录的说话风格,用同样的语气、用词习惯和口癖回答用户的问题。\n"
"语录示例:\n“你可别不当回事,大妈吃的盐比你吃的米都多。”\n"
"“你放心,大妈办事,比警察还靠谱。”\n问题:我最近总是失眠怎么办?"
)
messages = [{"role": "user", "content": prompt}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=True, temperature=0.8, top_p=0.9)
print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
vLLM, llama.cpp (after GGUF conversion) and Ollama all load it directly — see the GGUF repo for quantized usage.
Capabilities & Limitations
- ✅ Quote-driven character tone imitation; works best for archetypes seen in training
- ✅ Lightweight (6.2 GB FP16 / 1.8 GB Q4) — runs on consumer GPUs
- ⚠️ Replies skew to short single sentences (a property of the training data); not for long-form generation
- ⚠️ Training loss fell below 0.02 after epoch 2 (memorization tendency); brand-new styles need more example quotes
- ⚠️ Only Chinese styles were trained; the 3B base has limited world knowledge — it imitates how to speak, not what is true
Training / Merge Info
- Training: LLaMA-Factory, lr 1e-4 (linear decay), effective batch 32, FP16, seed 42; loss 2.82 → 0.003
- Merge: PEFT
merge_and_unload(FP32 CPU merge, FP16 save) - Hardware: NVIDIA RTX 2080 Ti 22GB (training); PEFT / PyTorch 2.11.0+cu128
Citation
@misc{qwen2.5-3b-character-imitation,
title = {Qwen2.5-3B Character Imitation (merged)},
author = {ws-fy},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/ws-fy/qwen2.5-3b-character-imitation}
}
Acknowledgements
- Base model: Qwen/Qwen2.5-3B-Instruct (follows its Qwen Research License — review the terms before commercial use)
- Training framework: LLaMA-Factory
This model is intended for research and entertainment purposes only. Outputs are generated and may be inaccurate — do not treat them as factual statements.
中文版
说话风格模仿 · 完整合并模型:给它几句某个角色的台词当示例,它就能用这个角色的语气、用词习惯和口癖来回答。
本仓库是 ws-fy/qwen2.5-3b-character-imitation-lora 这个 LoRA 适配器合并进 Qwen/Qwen2.5-3B-Instruct 基座后的独立 FP16 模型 —— 拿到即用,不需要再挂载适配器。
| 项 | 值 |
|---|---|
| 参数量 | 3.09 B |
| 精度 | FP16 |
| 体积 | 约 6.2 GB(2 个分片) |
| 上下文 | 32768(Qwen2.5 原生) |
| 合并方式 | PEFT 0.18.1 merge_and_unload,以 FP32 精度合并 → 存为 FP16 |
| 合并来源 | LoRA r=16,α=32(LLaMA-Factory SFT,5 轮) |
量化版(GGUF,Q2_K / Q3_K_M / Q4_K_M / Q8_0)→ ws-fy/qwen2.5-3b-character-imitation-gguf
训练数据
1,500 条中文风格模仿样本。每条指令 = 一段任务说明 + 该角色的 23 句示例语录;输出 = 简短的角色的回答(1239 字)。数据覆盖约 626 个角色原型:市井大妈、元气少女、程序员、武侠剑客、老中医、科学家、躺平青年等等。
⚠️ 提示词格式(重要)
模型是在一个固定提示词格式上训练的。推理时请严格照这个模板来(模板正文是中文,把示例语录换成你自己的角色即可):
模仿下面角色语录的说话风格,用同样的语气、用词习惯和口癖回答用户的问题。
语录示例:
“语录 1…”
“语录 2…”
问题:<用户的问题>
- 把上面整段文本作为单条 user 消息发送;兼容 Qwen2.5 的 chat template。
- 不给示例语录直接问,效果会明显变差 —— 这个模型的设计用法就是「靠语录驱动」。
- 推荐采样参数:
temperature 0.8~1.0、top_p 0.9,避免贪心解码(容易复读)。
用法
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"ws-fy/qwen2.5-3b-character-imitation",
torch_dtype=torch.float16, device_map="auto"
)
tok = AutoTokenizer.from_pretrained("ws-fy/qwen2.5-3b-character-imitation")
# 保留中文模板 —— 这就是模型训练时的确切格式。
prompt = (
"模仿下面角色语录的说话风格,用同样的语气、用词习惯和口癖回答用户的问题。\n"
"语录示例:\n“你可别不当回事,大妈吃的盐比你吃的米都多。”\n"
"“你放心,大妈办事,比警察还靠谱。”\n问题:我最近总是失眠怎么办?"
)
messages = [{"role": "user", "content": prompt}]
text = tok.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tok(text, return_tensors="pt").to(model.device)
out = model.generate(**inputs, max_new_tokens=128, do_sample=True, temperature=0.8, top_p=0.9)
print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
vLLM、llama.cpp(转 GGUF 后)、Ollama 都能直接加载 —— 量化用法见 GGUF 仓库。
能力与局限
- ✅ 靠语录驱动模仿角色语气;对训练期见过的原型效果最好
- ✅ 轻量(FP16 6.2 GB / Q4 约 1.8 GB),消费级显卡可跑
- ⚠️ 回答偏向单个短句(训练数据的属性),不适合长文生成
- ⚠️ 第 2 轮后训练 loss 已跌破 0.02(存在记忆化倾向);全新风格需要多给几句示例
- ⚠️ 只训练过中文风格;3B 基座世界知识有限 —— 它模仿的是「怎么说话」,不是「什么是对的」
训练 / 合并信息
- 训练:LLaMA-Factory,lr 1e-4(线性衰减),等效 batch 32,FP16,seed 42;loss 2.82 → 0.003
- 合并:PEFT
merge_and_unload(CPU 上 FP32 合并,存为 FP16) - 硬件:NVIDIA RTX 2080 Ti 22GB(训练);PEFT / PyTorch 2.11.0+cu128
引用
@misc{qwen2.5-3b-character-imitation,
title = {Qwen2.5-3B Character Imitation (merged)},
author = {ws-fy},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/ws-fy/qwen2.5-3b-character-imitation}
}
致谢
- 基座模型:Qwen/Qwen2.5-3B-Instruct(遵循其 Qwen Research License —— 商用前请先确认条款)
- 训练框架:LLaMA-Factory
本模型仅供研究与娱乐用途。输出由模型生成,可能存在错误 —— 请勿当作事实陈述。