qwen3-4b-structured-output-lora-base_param-upsweek_v2
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,
while intermediate reasoning (Chain-of-Thought) is masked.
Training Configuration
- Base model: Qwen/Qwen3-4B-Instruct-2507
- Method: QLoRA (4-bit)
- Max sequence length: 512
- Epochs: 3
- Learning rate: 1e-06
- LoRA: r=64, alpha=128
- Task-weighted sampling: enabled (see below)
Task weighting / sampling strategy # ★追加
The training dataset contains multiple structured conversion subtasks
(e.g., JSON ↔ YAML, CSV ↔ JSON, XML ↔ CSV).
To slightly emphasize directions that tended to be more brittle
(e.g., CSV ↔ JSON, XML ↔ CSV/YAML), a simple heuristic
task-level sampling weight was applied at the SFT dataloader level.
Sampling weights (applied to the task_name, case-insensitive)
are as follows:
1{"csv to json": 1.25, "json to csv": 1.25, "xml to csv": 1.25, "xml to yaml": 1.2, "xml to json": 1.15, "csv to yaml": 1.1}
2
3These weights are implemented via the SFT_UPSAMPLE_RULES environment
4variable and are intended to slightly up-weight structurally challenging
5conversion directions while keeping the overall task distribution close
6to the original dataset.
7
8No per-instance weighting or test-set-specific tuning is performed;
9the weighting is defined only at the task_name level.
10
11## Usage
12
13```python
14from transformers import AutoModelForCausalLM, AutoTokenizer
15from peft import PeftModel
16import torch
17
18base = "Qwen/Qwen3-4B-Instruct-2507"
19adapter = "your_id/your-repo"
20
21tokenizer = AutoTokenizer.from_pretrained(base)
22model = AutoModelForCausalLM.from_pretrained(
23 base,
24 torch_dtype=torch.float16,
25 device_map="auto",
26)
27model = PeftModel.from_pretrained(model, adapter)
Sources & Terms (IMPORTANT)
Training data: u-10bei/structured_data_with_cot_dataset_512_v2
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.