Downloads · 30 days
7
13% of all-time downloads
taozi555/rp-glm-4.7-flash-lora
rp-glm-4.7-flash-lora is a text generation model from taozi555. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
Downloads · 30 days
7
13% of all-time downloads
All-time downloads
54
Public
Repo size
75.9 MB
Likes
0
Public
Click a slice to open those files.
.safetensors55.6 MB · 73%
From the Hugging Face model README
基于 GLM-4.7-Flash 的角色扮演 LoRA 适配器。
这是一个 LoRA (Low-Rank Adaptation) 适配器,专门针对角色扮演场景进行了微调。
| 参数 | 值 |
|---|---|
| 基础模型 | unsloth/GLM-4.7-Flash |
| LoRA Rank | 16 |
| LoRA Alpha | 32 |
| LoRA Dropout | 0 |
| Target Modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj, in_proj, out_proj |
| 序列长度 | 26000 tokens |
| 训练精度 | bf16 |
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_model_name = "unsloth/GLM-4.7-Flash"
lora_name = "taozi555/rp-glm-4.7-flash-lora"
# 加载基础模型
tokenizer = AutoTokenizer.from_pretrained(base_model_name, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
base_model_name,
torch_dtype="auto",
device_map="auto",
trust_remote_code=True,
)
# 加载 LoRA
model = PeftModel.from_pretrained(model, lora_name)
# 推理
messages = [
{"role": "system", "content": "你是一位来自中世纪的强大魔法师,名叫梅林。"},
{"role": "user", "content": "伟大的梅林,请问您能教我魔法吗?"}
]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, top_p=0.9)
response = tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True)
print(response)
from peft import PeftModel
# 加载后合并
model = PeftModel.from_pretrained(base_model, lora_name)
model = model.merge_and_unload() # 合并权重
# 现在可以像普通模型一样使用
unsloth/GLM-4.7-Flash 配合使用Apache 2.0