Instructions to use kmd2525/qwen3-4b-structured-output-lora-v4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use kmd2525/qwen3-4b-structured-output-lora-v4 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("unsloth/qwen3-4b-instruct-2507-unsloth-bnb-4bit") model = PeftModel.from_pretrained(base_model, "kmd2525/qwen3-4b-structured-output-lora-v4") - Notebooks
- Google Colab
- Kaggle
qwen3-4b-structured-output-lora-v4
This repository provides a LoRA adapter (v4) 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 — Data Curation
This is v4 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 | Rationale |
|---|---|---|---|
| Dataset | Merged (8,541) | Curated (2,801) | 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: 100 neighbors per test sample
- Total: 2,801 samples (71% of v2)
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"
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
- -
Model tree for kmd2525/qwen3-4b-structured-output-lora-v4
Base model
Qwen/Qwen3-4B-Instruct-2507