Text Generation
PEFT
Safetensors
English
qlora
lora
structured-output
v4.1

qwen3-4b-structured-output-lora-v4.1

This repository provides a LoRA adapter (v4.1) 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.

Version: v4.1 — Data Curation (k=50)

This is v4.1 of the SFT training, focusing on data curation via vector search. Based on v3's lesson (score dropped from 0.751 to 0.726 with more data), we curated the training data.

Changes from v3

Parameter v3 v4.1 Rationale
Dataset Merged (8,541) Curated k=50 (1,695) Quality over quantity
MAX_SEQ_LEN 1024 1024 Same as v2/v3
Epochs 1 1 Same as v2/v3
Learning Rate 5e-6 5e-06 Same as v2/v3

Curated Dataset Details

  • Method: sentence-transformers + k-NN search for test-similar data
  • k: 50 neighbors per test sample
  • Total: 1,695 samples (71% of v4)

Source distribution: 2-2_5k_mix(46%), 2-1_3k_mix(35%), 2-3_hard_4k(19%)

Training Objective

This adapter is trained to improve structured output accuracy (JSON / YAML / XML / TOML / CSV) for the StructEval-T benchmark.

Loss is applied only to the final assistant output, while intermediate reasoning (Chain-of-Thought) is masked.

Training Configuration

  • Base model: Qwen/Qwen3-4B-Instruct-2507
  • Method: QLoRA (4-bit, Unsloth)
  • Max sequence length: 1024
  • Epochs: 1
  • Learning rate: 5e-06
  • Batch size: 2 (effective: 16)
  • Gradient accumulation: 8
  • LoRA: r=64, alpha=128
  • CoT masking: enabled (loss on final output only)

Usage

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

base = "Qwen/Qwen3-4B-Instruct-2507"
adapter = "your_id/qwen3-4b-structured-output-lora-v4.1"

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

Sources & Terms (IMPORTANT)

Training data: merged dataset (1-1_512_v2 + 1-2_512_v4)

Dataset License: MIT License. This dataset is 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.

Downloads last month
218
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for kmd2525/qwen3-4b-structured-output-lora-v4.1

Adapter
(5273)
this model

Datasets used to train kmd2525/qwen3-4b-structured-output-lora-v4.1