DTakai/sft4-allowed4k-1epoch-lora
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 for:
- JSON
- YAML
- XML
- TOML
- CSV
The training script applies loss to the final assistant output only. Intermediate reasoning (Chain-of-Thought) is masked.
Training Configuration
- Base model:
Qwen/Qwen3-4B-Instruct-2507 - Method: QLoRA (4-bit) with Unsloth
- Max sequence length: 1536
- Epochs: 1 (250 steps for 4000 training samples)
- Learning rate: 1e-6
- LoRA: r=64, alpha=128, dropout=0
Training Data
This adapter was trained on a cleaned + deduplicated dataset built from the organizer-approved SFT datasets:
u-10bei/structured_data_with_cot_dataset_512_v2u-10bei/structured_data_with_cot_dataset_512_v4u-10bei/structured_data_with_cot_dataset_512_v5u-10bei/structured_data_with_cot_dataset_512u-10bei/structured_data_with_cot_dataset_v2u-10bei/structured_data_with_cot_datasetdaichira/structured-3k-mix-sftdaichira/structured-5k-mix-sftdaichira/structured-hard-sft-4k
The local build process validates that assistant outputs are parseable for their target format and removes exact duplicates.
Notes:
- Please refer to each dataset card for its license/terms.
- You must also comply with the base model's terms of use.
License
This repository contains LoRA adapter weights only.
- Base model license: Apache-2.0 (see:
Qwen/Qwen3-4B-Instruct-2507) - Training data licenses (per dataset cards):
daichira/*: CC-BY-4.0u-10bei/*: MIT (please verify each dataset page)
Usage
Transformers + PEFT
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_id = "Qwen/Qwen3-4B-Instruct-2507"
adapter_id = "DTakai/sft4-allowed4k-1epoch-lora"
tokenizer = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(
base_id,
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base, adapter_id)
# Optional: merge LoRA into base weights
merged = model.merge_and_unload()
vLLM (Competition-style)
If you are following a notebook that merges the LoRA adapter and runs vLLM, you can point it at:
- Base:
Qwen/Qwen3-4B-Instruct-2507 - Adapter:
DTakai/sft4-allowed4k-1epoch-lora
Limitations
- Structured formats are still fragile, especially TOML generation.
- This adapter was trained for structured formatting, not for general open-ended chat.
日本語
このリポジトリは、Qwen/Qwen3-4B-Instruct-2507 をベースモデルとして、QLoRA (4-bit, Unsloth) を用いてファインチューニングした LoRA アダプタを提供します。
本リポジトリには LoRA アダプタの重みのみが含まれています。ベースモデルは別途ロードする必要があります。
学習の目的
このアダプタは、以下の構造化出力の精度向上を目的として学習されています。
- JSON
- YAML
- XML
- TOML
- CSV
学習スクリプトでは、損失(Loss)は最終的なアシスタント出力のみに適用されます。中間の推論(Chain-of-Thought)はマスクされています。
学習設定
- ベースモデル:
Qwen/Qwen3-4B-Instruct-2507 - 手法: Unsloth を用いた QLoRA (4-bit)
- 最大シーケンス長: 1536
- エポック数: 1(学習サンプル 4000 に対して 250 steps)
- 学習率: 1e-6
- LoRA: r=64, alpha=128, dropout=0
学習データ
このアダプタは、主催者が許可した SFT データセット群から作成した「クリーニング済み + 重複排除済み」のデータを用いて学習されています。
u-10bei/structured_data_with_cot_dataset_512_v2u-10bei/structured_data_with_cot_dataset_512_v4u-10bei/structured_data_with_cot_dataset_512_v5u-10bei/structured_data_with_cot_dataset_512u-10bei/structured_data_with_cot_dataset_v2u-10bei/structured_data_with_cot_datasetdaichira/structured-3k-mix-sftdaichira/structured-5k-mix-sftdaichira/structured-hard-sft-4k
ローカルのビルド工程では、アシスタント出力がターゲット形式としてパース可能であることを検証し、完全一致の重複を除去します。
注意:
- 各データセットのライセンス/利用条件は、それぞれの Dataset Card を参照してください。
- ベースモデルの利用規約にも必ず従ってください。
ライセンス
本リポジトリには LoRA アダプタの重みのみが含まれます。
- ベースモデルのライセンス: Apache-2.0(
Qwen/Qwen3-4B-Instruct-2507を参照) - 学習データのライセンス(各 Dataset Card に基づく):
daichira/*: CC-BY-4.0u-10bei/*: MIT(各データセットページで確認してください)
使い方
Transformers + PEFT
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
base_id = "Qwen/Qwen3-4B-Instruct-2507"
adapter_id = "DTakai/sft4-allowed4k-1epoch-lora"
tokenizer = AutoTokenizer.from_pretrained(base_id)
base = AutoModelForCausalLM.from_pretrained(
base_id,
torch_dtype=torch.float16,
device_map="auto",
)
model = PeftModel.from_pretrained(base, adapter_id)
# Optional: merge LoRA into base weights
merged = model.merge_and_unload()
vLLM(コンペの推論手順に近い形)
LoRA アダプタをマージして vLLM で推論するノートブック/スクリプトを使う場合は、以下を指定できます。
- Base:
Qwen/Qwen3-4B-Instruct-2507 - Adapter:
DTakai/sft4-allowed4k-1epoch-lora
制約 / 注意点
- 構造化フォーマットの生成は依然として壊れやすく、特に TOML は失敗しやすいです。
- 本アダプタは構造化フォーマットの出力を目的としており、一般的な雑談用途に最適化されていません。
- Downloads last month
- 2
Model tree for DTakai/sft4-allowed4k-1epoch-lora
Base model
Qwen/Qwen3-4B-Instruct-2507