Downloads · 30 days
18
5% of all-time downloads
kabuizuchi-trading/qwen3-4b-lora-structured
qwen3-4b-lora-structured is a text generation model from kabuizuchi-trading. 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.
Downloads · 30 days
18
5% of all-time downloads
All-time downloads
334
Public
Repo size
3.2 GB
Likes
0
Public
Click a slice to open those files.
.safetensors1.1 GB · 99%
From the Hugging Face model README
<# Qwen3-4B-Instruct-2507-lora001>
This repository provides a LoRA adapter fine-tuned from Qwen/Qwen3-4B-Instruct-2507 using Unsloth + PEFT (LoRA).
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). with an emphasis on returning only the requested structured output (no explanations, no markdown fences).
Key design choices implemented in the training code:
Output: / Final: / Answer:.In addition, the training pipeline applies output cleaning and format-biased augmentation:
<think>...</think> blocks when present{, [, <, YAML/TOML-like starts)r=128 (SFT_LORA_R), alpha=256 (SFT_LORA_ALPHA), dropout=0.05 (SFT_LORA_DROPOUT)q_proj,k_proj,v_proj,o_proj,gate_proj,up_proj,down_proj (SFT_LORA_TARGET_MODULES)200 steps (SFT_EVAL_STEPS, SFT_SAVE_STEPS)Notes:
load_in_4bit=False (i.e., not QLoRA 4-bit by default).bf16=True).from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base = "Qwen/Qwen3-4B-Instruct-2507"
adapter = "your_id/your-repo"
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": (
"IMPORTANT:
"
"- Output ONLY the requested TOML.
"
"- No explanations, no markdown fences.
"
"- Ensure the output parses correctly.
"
"Task: Create a TOML config with title='demo' and ports=[8000,8001].
"
"Output:
"
)
}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs,
max_new_tokens=256,
do_sample=False,
temperature=0.0,
)
print(tokenizer.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
Training data: u-10bei/structured_data_with_cot_dataset_512_v5
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.