Downloads · 30 days
86
21% of all-time downloads
JiangLing-js/Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO
Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO is a text generation model from JiangLing-js. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as other.
JiangLing-js/Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO is an experimental Chinese long-form creative-writing LoRA adapter based on unsloth/Qwen3.8-27B.
Downloads · 30 days
86
21% of all-time downloads
All-time downloads
402
Public
Repo size
727 MB
Likes
10
Public
Click a slice to open those files.
.safetensors707 MB · 97%
From the Hugging Face model README
JiangLing-js/Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO is an experimental Chinese long-form creative-writing LoRA adapter based on unsloth/Qwen3.8-27B.
The model was trained in two stages:
The main purpose of this experiment is to investigate whether a large language model can learn more natural Chinese web-fiction prose through:
structured outline
→ human-written scene
→ SFT
→ human prose vs. LLM prose preference pairs
→ DPO
unsloth/Qwen3.8-27Bq_proj
k_proj
v_proj
o_proj
gate_proj
up_proj
down_proj
out_proj
This model is primarily intended for structured Chinese fiction generation.
A typical prompt may contain:
setting / era
character states
previous-story summary
retrieved world information
scene objective
plot beats
conflict
required ending state
The model is then expected to generate a continuous prose scene rather than explain the writing process.
It may be useful for:
This adapter was not designed for:
The validated SFT dataset contained 2,380 scene-level examples.
| Split | Samples |
|---|---|
| Train | 1,732 |
| Validation | 331 |
| Test | 317 |
| Total | 2,380 |
Task composition:
| Task | Samples |
|---|---|
| Outline → scene | 1,056 |
| Context → next scene | 602 |
| Retrieved setting information → scene | 399 |
| Dialogue/conflict → scene | 323 |
The original novel was first processed through:
TXT cleaning
→ chapter segmentation
→ scene segmentation
→ reverse scene outlining
→ SFT construction
The final validated SFT dataset had:
Preference data was created after SFT.
Two negative-response sources were used:
The preferred responses were human-written source passages.
Preference pipeline:
680 prompts
→ 860 generated candidates
→ automatic filtering
→ 607 selected preference pairs
Final split:
| Split | Pairs |
|---|---|
| DPO train | 574 |
| DPO validation | 33 |
| Total | 607 |
Automatic filters included:
minimum rejected length: 450 characters
minimum rejected/chosen length ratio: 0.65
maximum rejected/chosen length ratio: 1.70
maximum chosen/rejected similarity: 82
verbatim overlap threshold: 64 characters
maximum full sequence: 4096 tokens
maximum prompt: 2800 tokens
maximum completion: 1900 tokens
The model was trained with assistant-only loss.
System and user prompt tokens were masked from the training loss; only the assistant fiction response contributed to optimization.
Base model: unsloth/Qwen3.8-27B
Precision: BF16
Max sequence length: 4096
LoRA r: 64
LoRA alpha: 128
LoRA dropout: 0.0
Epochs: 1
Learning rate: 2e-5
Micro batch size: 2
Gradient accumulation: 4
Effective batch size: 8
Warmup ratio: 0.05
Weight decay: 0.001
Seed: 3407
Optimizer: AdamW 8-bit
Gradient checkpointing: enabled
Thinking: disabled
Train loss: 2.3471
Validation loss: 2.2639
Training runtime:
~3057 seconds
~50.9 minutes
GPU memory:
Peak allocated: ~58.60 GB
Peak reserved: ~59.55 GB
The SFT LoRA adapter was used as the starting policy.
A frozen copy of the SFT adapter was used as the reference policy.
Reference chosen/rejected log probabilities were precomputed before optimization.
The objective combined standard sigmoid DPO with a small chosen-response NLL regularization term.
Epochs: 1
Learning rate: 5e-6
DPO beta: 0.10
RPO alpha: 0.20
Micro batch size: 1
Gradient accumulation: 8
Effective batch size: 8
Max length: 4096
Max prompt length: 2800
Max completion length: 1900
Warmup ratio: 0.05
Weight decay: 0.001
Seed: 7331
Validation set size: 33 preference pairs
| Metric | Value |
|---|---|
| DPO train loss | 0.4551 |
| DPO eval loss | 0.4545 |
| Reward / chosen | +3.1900 |
| Reward / rejected | -13.6067 |
| Reward margin | +16.7967 |
| Preference accuracy | 1.0000 |
| Chosen NLL loss | 2.2644 |
The 1.0 preference accuracy means that, on this small 33-pair validation set, every chosen response received a higher implicit reward than its rejected counterpart.
It does not mean that the model has 100% general writing accuracy.
Training runtime: ~2359 seconds (~39.3 min)
Full recorded DPO-stage elapsed time:
~3541 seconds (~59 min)
Evaluation runtime:
~40.7 seconds
GPU memory:
Peak allocated: ~69.08 GB
Peak reserved: ~72.12 GB
Hardware:
NVIDIA A100-SXM4-80GB
A qualitative generation test was run on the first example of the held-out test.jsonl split.
Before generation, the original assistant response was explicitly removed:
final_prompt_messages = [
m
for m in final_sample["messages"]
if m["role"] != "assistant"
]
Therefore the model did not receive the gold prose response in its generation prompt.
Generation parameters:
max_new_tokens: 1700
temperature: 0.85
top_p: 0.90
top_k: 40
repetition_penalty: 1.05
thinking: disabled
The generated passage and gold target were saved separately for manual comparison.
As an additional informal experiment, one DPO-generated held-out passage was submitted to the Zhuque / 朱雀 AI-text detector.
The detector classified that specific generated passage as:
纯人工 / human-written
from unsloth import FastLanguageModel
import torch
MODEL_ID = "JiangLing-js/Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO"
model, processor = FastLanguageModel.from_pretrained(
model_name=MODEL_ID,
max_seq_length=4096,
load_in_4bit=False,
load_in_8bit=False,
full_finetuning=False,
)
FastLanguageModel.for_inference(model)
tokenizer = (
processor.tokenizer
if hasattr(processor, "tokenizer")
else processor
)
if tokenizer.pad_token_id is None:
tokenizer.pad_token = tokenizer.eos_token
messages = [
{
"role": "system",
"content": "你是一名中文长篇小说写作助手,只输出小说正文。"
},
{
"role": "user",
"content": """
【人物状态】
主角刚结束长途赶路,体力下降,但仍保持警惕。
【前情】
主角跟随导师进入陌生山谷。
【事件骨架】
1. 两人进入山谷。
2. 主角观察周围环境。
3. 导师说明训练要求。
4. 主角意识到后续训练不会轻松。
【写作要求】
写成完整连续的小说场景。
"""
},
]
prompt = processor.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False,
)
inputs = tokenizer(
prompt,
return_tensors="pt",
add_special_tokens=False,
).to("cuda")
with torch.inference_mode():
outputs = model.generate(
**inputs,
max_new_tokens=1700,
do_sample=True,
temperature=0.85,
top_p=0.90,
top_k=40,
repetition_penalty=1.05,
use_cache=True,
)
generated = tokenizer.decode(
outputs[0][inputs["input_ids"].shape[1]:],
skip_special_tokens=True,
)
print(generated)
This remains a small, domain-specific experiment.
Important limitations include:
The training corpus contains material derived from copyrighted literary works.
The original source text is not distributed in this model repository.
Any dataset repository containing source passages should be kept private or otherwise distributed only when the uploader has the appropriate rights or legal basis to do so.
This adapter does not grant any rights to the underlying literary works.
Core software versions:
PyTorch: 2.8.0
Transformers: 5.3.0
TRL: 0.22.2
PEFT: 0.20.0
Datasets: 4.3.0
Unsloth: 2026.8.19
Recommended repository files:
adapter_model.safetensors
adapter_config.json
tokenizer.json
tokenizer_config.json
processor_config.json
chat_template.jinja
training/dpo_hparams.json
training/dpo_metrics.json
training/training_args.json
training/filter_report.json
@misc{Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO,
author = {JiangLing-js},
title = {Qwen3.8-27B-Chinese-Xuanhuan-Novel-Writer-DPO},
year = {2026},
howpublished = {Hugging Face Model Repository},
note = {Chinese creative-writing LoRA adapter based on Qwen3.8-27B}
}
Built with: