CoolFace
Modelpublic

liuyanliang/qwen3-4b-instruct-modern-to-luxun-api-lora-fast

sourceHugging Faceupdated 3mo agoView on Hugging Face
1likes11downloads
Model Card

qwen3-4b-instruct-modern-to-luxun-api-lora-fast

This repository contains a LoRA adapter for Qwen/Qwen3-4B-Instruct-2507. It was fine-tuned for Chinese modern-text rewriting in a Lu Xun-inspired prose style.

本仓库只包含 LoRA adapter,不包含 Qwen3-4B 基座模型权重。推理时需要同时加载基座模型和本 adapter。

Model Details

  • —Base model: Qwen/Qwen3-4B-Instruct-2507
  • —Adapter type: LoRA, PEFT
  • —Task: Chinese style transfer / text generation
  • —Language: Chinese
  • —Primary use: rewrite modern Chinese prose into a Lu Xun-inspired style

Intended Use

This adapter is intended for the Classical Chinese NLP demo backend in the luxun_style route. It can also be loaded manually with transformers and peft.

The model is intended for stylistic rewriting experiments and demos. It should not be used as an authoritative representation of Lu Xun's original writing.

Usage

python
import torch
from peft import PeftModel
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig

base_model = "Qwen/Qwen3-4B-Instruct-2507"
adapter = "liuyanliang/qwen3-4b-instruct-modern-to-luxun-api-lora-fast"

tokenizer = AutoTokenizer.from_pretrained(base_model, trust_remote_code=True)
if tokenizer.pad_token_id is None:
    tokenizer.pad_token = tokenizer.eos_token

quantization_config = BitsAndBytesConfig(
    load_in_4bit=True,
    bnb_4bit_quant_type="nf4",
    bnb_4bit_use_double_quant=True,
    bnb_4bit_compute_dtype=torch.float16,
)

model = AutoModelForCausalLM.from_pretrained(
    base_model,
    trust_remote_code=True,
    device_map="auto",
    quantization_config=quantization_config,
)
model = PeftModel.from_pretrained(model, adapter)
model.eval()

For this project backend:

bash
export CCNLP_QWEN_BASE_MODEL=Qwen/Qwen3-4B-Instruct-2507
export CCNLP_LUXUN_ADAPTER=liuyanliang/qwen3-4b-instruct-modern-to-luxun-api-lora-fast

PYTHONPATH=src uvicorn ccnlp.api_server:app --host 127.0.0.1 --port 8000

Prompt Format

The adapter was trained for the project's Lu Xun style-transfer task. In the project code, prompts are built by ccnlp.causal_sft.build_generation_prompt. For best results, use the same prompt construction logic as the backend.

Limitations

  • —This adapter depends on the Qwen3-4B base model.
  • —Generated text may contain stylistic imitation errors, factual errors, or unnatural phrasing.
  • —The adapter is designed for Chinese text. Other languages are out of scope.
  • —The model card does not include benchmark results yet.

Files

  • —adapter_model.safetensors: LoRA adapter weights
  • —adapter_config.json: PEFT adapter configuration
  • —tokenizer files copied from the training/export environment

Framework Versions

  • —PEFT 0.19.1
  • —Transformers 4.57.6