Downloads · 30 days
10
13% of all-time downloads
uchkw/qwen3-4b-structured-output-lora
qwen3-4b-structured-output-lora is a text generation model from uchkw. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This repository provides a LoRA adapter fine-tuned from unsloth/Qwen3-4B-Instruct-2507 using QLoRA (4-bit, Unsloth). This repository contains LoRA adapter weights only. The base model must be loaded separately.
Downloads · 30 days
10
13% of all-time downloads
All-time downloads
75
Public
Repo size
1.6 GB
Likes
0
Public
Click a slice to open those files.
.safetensors529 MB · 97%
From the Hugging Face model README
This repository provides a LoRA adapter fine-tuned from unsloth/Qwen3-4B-Instruct-2507 using QLoRA (4-bit, Unsloth). This repository contains LoRA adapter weights only. The base model must be loaded separately.
This adapter is trained to improve structured output accuracy (JSON / YAML / XML / TOML / CSV).
Loss is applied only to the final assistant output, while intermediate reasoning (Chain-of-Thought) is masked.
Output supervision uses mode after_marker with markers: </think>, Output:, OUTPUT:, Final:, Answer:, Result:, Response:.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base = "unsloth/Qwen3-4B-Instruct-2507"
adapter = "uchkw/qwen3-4b-structured-output-lora"
tokenizer = AutoTokenizer.from_pretrained(base)
model = AutoModelForCausalLM.from_pretrained(
base,
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(model, adapter)
FIRST TRAINING: This adapter was trained on a mix of the following datasets. The total number of samples used for the first training phase was 9,094.
| Dataset | License |
|---|---|
| u-10bei/structured_data_with_cot_dataset_512_v5 | MIT |
| daichira/structured-hard-sft-4k | CC-BY-4.0 |
SECOND TRAINING: Then the adapter was continued training on a rule-based JSON→TOML augmentation dataset derived from the u-10bei structured_data_with_cot_dataset_* series (train + validation) with inline-table expansion. TOML validity was checked via tomllib, and no LLM was used for generation. The total number of samples used for the second training phase was 7,146.
The u-10bei structured_data_with_cot_dataset_* series datasets used for the second training phase are as follows:
THIRD TRAINING: The adapter was then further trained on a mixed dataset of 20,000 samples that includes StructEval-style Text-to-TOML synthetic data and invalid-to-valid repair data.
tomllib, and structurally invalid samples were excluded.max_seq_length=2048 were excluded.