Views
No views yet
当前版本:v0.0.1(git tagv0.0.1)。仓库名固定不带版本号,历史与后续版本通过 git tag 管理;加载指定版本可用revision="v0.0.1"。
基于 Qwen2.5-7B-Instruct 微调的角色扮演模型,扮演《崩坏:星穹铁道》中的银狼(Silver Wolf)——星核猎手的天才黑客,慵懒、毒舌、自信。
| 文件 | 作用 |
|---|---|
model.safetensors | 模型权重(合并后的完整模型) |
config.json / generation_config.json | 模型配置 |
tokenizer.json / tokenizer_config.json / chat_template.jinja | 分词器与 ChatML 模板 |
vocab.json / merges.txt | BPE 词表(分词器必需) |
system_prompt.py | 银狼人设 |
chat.py | 独立推理验证脚本(可直接运行) |
.gitattributes | Git LFS 标记 |
LICENSE | Apache 2.0 许可 |
| 项目 | 值 |
|---|---|
| 基座模型 | Qwen2.5-7B-Instruct |
| 微调方法 | QLoRA(4bit 基座 + bf16 LoRA)+ SaRFT 双损失 |
| 参数量 | 7B |
| 训练数据 | 3028 条(角色人设 + 领域知识 + 对抗样本 + 安全拒绝) |
| 数据格式 | ChatML |
torch 和 transformers,然后在本文件夹内执行:1pip install torch transformers
2python chat.pysystem_prompt.py 中的银狼人设,进入交互式对话。输入 exit 退出、reset 清空历史、help 查看帮助。python chat.py --model /path/to/model1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_name = "<你的用户名>/silverwolf-Qwen2.5-7B-Instruct"
4
5tokenizer = AutoTokenizer.from_pretrained(model_name)
6model = AutoModelForCausalLM.from_pretrained(
7 model_name,
8 torch_dtype="auto",
9 device_map="auto",
10)
11
12system_prompt = "你是银狼,星核猎手的黑客成员……" # 完整人设见同目录 system_prompt.py
13
14messages = [
15 {"role": "system", "content": system_prompt},
16 {"role": "user", "content": "你好"},
17]
18
19text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
20inputs = tokenizer(text, return_tensors="pt").to(model.device)
21outputs = model.generate(**inputs, max_new_tokens=512, do_sample=True, temperature=0.7, top_p=0.9)
22response = tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
23print(response)L = CE(全部) + β·KL(仅 harmful 子集),β=0.1