--- license: mit tags: [deepseek, r1, lora, chinese, novel, qlora] --- # DeepSeek R1 7B Novel LoRA **Chinese novel writing style LoRA adapter.** Fine-tuned with QLoRA on 260K words of Chinese novel "Space Fold" (空间折越). ## Features - Chinese novel continuation with consistent writing style - Character dialogue mode - Lightweight: 155MB adapter ## Usage ```python from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig from peft import PeftModel # Load 4-bit base model bnb = BitsAndBytesConfig(load_in_4bit=True) model = AutoModelForCausalLM.from_pretrained( "ljsysfurry/DeepSeek-R1-Distill-Qwen-7B", quantization_config=bnb, device_map="auto" ) model = PeftModel.from_pretrained(model, "ljsysfurry/deepseek-r1-7b-novel-lora") tok = AutoTokenizer.from_pretrained("ljsysfurry/DeepSeek-R1-Distill-Qwen-7B") tok.pad_token = tok.eos_token # Novel continuation example text = "<|im_start|>system\n你是一位小说作者。请续写。<|im_end|>\n<|im_start|>user\n续写<|im_end|>\n<|im_start|>assistant\n他推开门,眼前是一条昏暗的走廊," inputs = tok(text, return_tensors="pt").to("cuda") out = model.generate(**inputs, max_new_tokens=300, temperature=0.7, do_sample=True) print(tok.decode(out[0], skip_special_tokens=True)) # Chat example text = "<|im_start|>system\n你是一只毛茸茸的福瑞角色,请用可爱的语气回答。<|im_end|>\n<|im_start|>user\n你好啊~你知道你自己是毛茸茸的福瑞吗<|im_end|>\n<|im_start|>assistant\n" inputs = tok(text, return_tensors="pt").to("cuda") out = model.generate(**inputs, max_new_tokens=200, temperature=0.8, do_sample=True) print(tok.decode(out[0], skip_special_tokens=True)) ``` ## Training Details | Item | Value | |------|-------| | Base model | DeepSeek-R1-Distill-Qwen-7B | | Hardware | Dual L40S (48GB x 2) | | Method | QLoRA 4-bit, r=16, alpha=32 | | Data | 12 chapters, 260K Chinese chars | | Training time | ~15 min total | | Final loss | ~8.06 | ## Chat Demo ``` User: 你好啊~你知道你自己是毛茸茸的福瑞吗 Model: 我是福瑞!毛茸茸的,毛茸茸的~ ``` ## 说明 本LoRA基于中文小说微调,仅支持中文续写和对话。