Qwen3.5-27B Chinese Novel Style LoRA

中文小说文风适配器,挂在 Qwen/Qwen3.5-27B 上。学习目标是叙述距离、句长、标点习惯、对白密度与段落节奏, 用于给定前文续写场景,而非事实问答。

训练

  • 方法:QLoRA(4bit 量化底座,bf16 compute),LoRA r=16 / alpha=32 / dropout=0.05
  • target:q/k/v/o/gate/up/down_proj(不训练 embed 与 lm_head)
  • 数据:人工筛选的特定文风小说片段(人工清洗的叙事文片段,按固定续写指令构造成 input/output 对, 仅对 output 计 loss)。仅学习文风,不含任何事实性/指令遵循类语料
  • 1 epoch,max_seq_length=2048,lr 1e-4 cosine

用法

import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel

tok = AutoTokenizer.from_pretrained("roaminwind/qwen3.5-27b-novel-style-lora")
bnb = BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.bfloat16)
model = AutoModelForImageTextToText.from_pretrained(
    "Qwen/Qwen3.5-27B", quantization_config=bnb, device_map="cuda")
model = PeftModel.from_pretrained(model, "roaminwind/qwen3.5-27b-novel-style-lora")
model.eval()

instr = ("按给定前文续写。保持同样的叙述距离、句长和标点习惯。"
         "只写正文,不要总结,不要标题,不要列点,不要解释你在做什么。")
prompt = instr + "\n" + "你的前文……"
text = tok.apply_chat_template([{"role": "user", "content": prompt}],
                               tokenize=False, add_generation_prompt=True)
ids = tok(text, return_tensors="pt").to("cuda")
out = model.generate(**ids, max_new_tokens=800, do_sample=True,
                     temperature=0.7, top_p=0.9, repetition_penalty=1.05)
print(tok.decode(out[0][ids["input_ids"].shape[1]:], skip_special_tokens=True))

解码建议(重要)

  • 必须使用采样解码:greedy 会产生复读循环(temperature=0.7, top_p=0.9, repetition_penalty=1.05 经验值稳定)
  • 长文写作建议分段续写:每次生成 600-900 字,将结果拼回前文再次调用
  • 该适配器只调节文风,知识、推理与长程情节规划能力来自底座模型

许可

权重基于 Qwen/Qwen3.5-27B(Apache-2.0),遵循其许可。

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for roaminwind/qwen3.5-27b-novel-style-lora

Base model

Qwen/Qwen3.5-27B
Adapter
(106)
this model