noirchan/qwen3-4b-structured-output-lora-v8
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
Training Datasets
- u-10bei/structureddatawithcotdataset512v2
Usage
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).
