Text Generation
Transformers
Safetensors
Chinese
qwen3
chinese-novels
creative-writing
full-sft
conversational
text-generation-inference
Instructions to use mikuhhn1239/qwen3-8b-novel-base-sft with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mikuhhn1239/qwen3-8b-novel-base-sft with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mikuhhn1239/qwen3-8b-novel-base-sft") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("mikuhhn1239/qwen3-8b-novel-base-sft") model = AutoModelForCausalLM.from_pretrained("mikuhhn1239/qwen3-8b-novel-base-sft", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use mikuhhn1239/qwen3-8b-novel-base-sft with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mikuhhn1239/qwen3-8b-novel-base-sft" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mikuhhn1239/qwen3-8b-novel-base-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mikuhhn1239/qwen3-8b-novel-base-sft
- SGLang
How to use mikuhhn1239/qwen3-8b-novel-base-sft with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "mikuhhn1239/qwen3-8b-novel-base-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mikuhhn1239/qwen3-8b-novel-base-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "mikuhhn1239/qwen3-8b-novel-base-sft" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mikuhhn1239/qwen3-8b-novel-base-sft", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mikuhhn1239/qwen3-8b-novel-base-sft with Docker Model Runner:
docker model run hf.co/mikuhhn1239/qwen3-8b-novel-base-sft
Qwen3-8B Novel Base SFT
基于 Qwen3-8B 全参微调,用 669 本中文网络小说训练(约 7200 万字符)。
项目地址:https://github.com/lin1753/novel2galgame
训练代码仓库:https://github.com/lin1753/novel-agent
用途
All Novel Can Be Galgame 工作台的 Stage1 基座模型。
学习中文小说的叙事风格和角色对话模式,作为下游 LoRA adapter 的基座,执行三类 Agent 任务:
- Agent 1:
mikuhhn1239/qwen3-8b-narrative-parsing-lora— 叙事单元分类 - Agent 2:
mikuhhn1239/qwen3-8b-scene-segmentation-lora— 场景边界检测 - Agent 3:
mikuhhn1239/qwen3-8b-attribution-assist-lora— 角色归因
加载
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"mikuhhn1239/qwen3-8b-novel-base-sft",
torch_dtype="auto",
device_map="auto",
)
tokenizer = AutoTokenizer.from_pretrained(
"mikuhhn1239/qwen3-8b-novel-base-sft"
)
4-bit 量化(适用于 8GB 显存):
from transformers import BitsAndBytesConfig
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_compute_dtype="float16",
bnb_4bit_quant_type="nf4",
)
model = AutoModelForCausalLM.from_pretrained(
"mikuhhn1239/qwen3-8b-novel-base-sft",
quantization_config=bnb_config,
device_map="auto",
)
训练数据
| 文件 | 条数 | 说明 |
|---|---|---|
continuation.jsonl |
36,092 | 续写:给前半段→续后半段 |
instruction.jsonl |
36,481 | 指令式续写 |
| 合计 | 72,573 |
格式: ChatML [system, user, assistant]
训练详情
调试历程
全参微调 8B 模型内存压力大,经历多轮调试:
| # | 问题 | 原因 | 解决 |
|---|---|---|---|
| 1 | 单卡 OOM (78G/80G) | optimizer+grads+model≈116G/卡 | 上 4 卡 DDP |
| 2 | 4 卡 DDP 仍 OOM (79G/80G) | DDP 每卡存完整 AdamW 状态(66G) | 加 DeepSpeed ZeRO-2 |
| 3 | ZeRO-2 backward OOM | 内存碎片 | PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True |
| 4 | batch=2 预估 26 小时 | 序列太长 | seq_len 4096→2048, epochs 3→2, batch 2→4 |
最终超参
| 参数 | 值 |
|---|---|
| 方法 | 全参数 SFT |
| 有效 batch size | 64 (4 GPU × 4 batch × 4 accumulation) |
| 学习率 | 2e-5 |
| 优化器 | AdamW (adamw_torch_fused) |
| warmup | 3% |
| scheduler | linear decay |
| 精度 | bf16 |
| 最大序列长度 | 2048 |
| epochs | 2 |
| gradient checkpointing | True |
| 分布式 | DeepSpeed ZeRO-2 (4×A800 80GB) |
训练结果
- 耗时: ~9 小时
- Loss: 3.36 → 2.47
- 产物: 16GB (4 个 safetensors 分片)
限制
- 仅支持中文输入
- 训练数据以网络小说为主,非通用指令模型
- 无安全对齐,不适用于敏感内容生成
- Downloads last month
- 236
Model tree for mikuhhn1239/qwen3-8b-novel-base-sft
Base model
Qwen/Qwen3-8B-Base Finetuned
Qwen/Qwen3-8B