CoolFace
Modelpublic

noirchan/qwen3-4b-structured-output-lora-v8

sourceHugging Faceapache-2.0updated 7mo agoView on Hugging Face
0likes11downloads
Model Card

qwen3-4b-structured-output-lora-v8

This repository provides a LoRA adapter fine-tuned from Qwen/Qwen3-4B-Instruct-2507 using QLoRA (4-bit, Unsloth).

This repository contains LoRA adapter weights only. The base model must be loaded separately.

Training Objective

This adapter is trained to improve structured output accuracy (JSON / YAML / XML / TOML / CSV).

Loss is applied only to the final assistant output (assistant-only loss). CoT reasoning steps are physically removed from training data via preprocessing. Empty Think Injection (<think>\n</think>) is applied to suppress thinking output.

Training Configuration

ParameterValue
Base modelQwen/Qwen3-4B-Instruct-2507
MethodQLoRA (4-bit, Unsloth)
Max sequence length512
Epochs2
Learning rate5e-05
LR schedulercosine
Warmup ratio0.1
Gradient accumulation steps8
Weight decay0.05
LoRA rank (r)64
LoRA alpha64
LoRA dropout0.0
LoRA target modulesqproj, kproj, vproj, oproj, gateproj, upproj, down_proj
PreprocessingEmpty Think Injection + CoT removal

Training Datasets

  • —u-10bei/structureddatawithcotdataset512v2

Usage

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

base    = "Qwen/Qwen3-4B-Instruct-2507"
adapter = "noirchan/qwen3-4b-structured-output-lora-v8"

tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(
    base,
    torch_dtype=torch.float16,
    device_map="auto",
)
model = PeftModel.from_pretrained(model, adapter)

messages = [{"role": "user", "content": "Convert the following to JSON: name=Alice, age=30"}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.0, do_sample=False)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Sources & Terms (IMPORTANT)

Training datasets used:

  • —u-10bei/structureddatawithcotdataset512v2

Dataset License: MIT License. These datasets are used and distributed under the terms of the MIT License.

Compliance: Users must comply with the MIT license (including copyright notice) and the base model's original terms of use (Apache 2.0).