v8: r=96, alpha=192, lr=1e-6, max_len=1024, epoch=2 + upsample (README written by author)
Browse files- README.md +26 -35
- adapter_config.json +5 -5
- adapter_model.safetensors +1 -1
- tokenizer_config.json +1 -1
README.md
CHANGED
|
@@ -2,44 +2,41 @@
|
|
| 2 |
base_model: Qwen/Qwen3-4B-Instruct-2507
|
| 3 |
datasets:
|
| 4 |
- u-10bei/structured_data_with_cot_dataset_512_v2
|
| 5 |
-
- u-10bei/dpo-dataset-qwen-cot
|
| 6 |
language:
|
| 7 |
- en
|
| 8 |
license: apache-2.0
|
| 9 |
library_name: peft
|
| 10 |
pipeline_tag: text-generation
|
| 11 |
tags:
|
| 12 |
-
-
|
| 13 |
-
-
|
| 14 |
-
-
|
| 15 |
-
- alignment
|
| 16 |
---
|
| 17 |
|
| 18 |
-
#
|
| 19 |
|
| 20 |
-
This
|
|
|
|
| 21 |
|
| 22 |
-
This repository contains **LoRA adapter weights**.
|
|
|
|
| 23 |
|
| 24 |
## Training Objective
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
## Training Configuration
|
| 28 |
-
**Stage 1 - SFT:**
|
| 29 |
-
- **Dataset**: u-10bei/structured_data_with_cot_dataset_512_v2
|
| 30 |
-
- **Max sequence length**: 1024
|
| 31 |
-
- **Epochs**: 2
|
| 32 |
-
- **Learning rate**: 1e-06
|
| 33 |
-
- **LoRA**: r=96, alpha=192
|
| 34 |
|
| 35 |
-
|
| 36 |
-
-
|
| 37 |
-
-
|
| 38 |
-
-
|
| 39 |
-
-
|
| 40 |
-
-
|
| 41 |
-
- **Max sequence length**: 1024
|
| 42 |
-
- **LoRA Config**: r=8, alpha=16
|
| 43 |
|
| 44 |
## Usage
|
| 45 |
|
|
@@ -55,20 +52,14 @@ tokenizer = AutoTokenizer.from_pretrained(base)
|
|
| 55 |
model = AutoModelForCausalLM.from_pretrained(
|
| 56 |
base,
|
| 57 |
torch_dtype=torch.float16,
|
| 58 |
-
device_map="auto"
|
| 59 |
)
|
| 60 |
model = PeftModel.from_pretrained(model, adapter)
|
| 61 |
-
|
| 62 |
-
# Test inference
|
| 63 |
-
prompt = "Your question here"
|
| 64 |
-
inputs = tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
|
| 65 |
-
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 66 |
-
print(tokenizer.decode(outputs[0]))
|
| 67 |
-
|
| 68 |
```
|
| 69 |
|
| 70 |
-
## Sources &
|
|
|
|
|
|
|
| 71 |
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
* **Compliance**: Users must follow the original base model's license terms.
|
|
|
|
| 2 |
base_model: Qwen/Qwen3-4B-Instruct-2507
|
| 3 |
datasets:
|
| 4 |
- u-10bei/structured_data_with_cot_dataset_512_v2
|
|
|
|
| 5 |
language:
|
| 6 |
- en
|
| 7 |
license: apache-2.0
|
| 8 |
library_name: peft
|
| 9 |
pipeline_tag: text-generation
|
| 10 |
tags:
|
| 11 |
+
- qlora
|
| 12 |
+
- lora
|
| 13 |
+
- structured-output
|
|
|
|
| 14 |
---
|
| 15 |
|
| 16 |
+
#qwen3-4b-structured-output-lora
|
| 17 |
|
| 18 |
+
This repository provides a **LoRA adapter** fine-tuned from
|
| 19 |
+
**Qwen/Qwen3-4B-Instruct-2507** using **QLoRA (4-bit, Unsloth)**.
|
| 20 |
|
| 21 |
+
This repository contains **LoRA adapter weights only**.
|
| 22 |
+
The base model must be loaded separately.
|
| 23 |
|
| 24 |
## Training Objective
|
| 25 |
+
|
| 26 |
+
This adapter is trained to improve **structured output accuracy**
|
| 27 |
+
(JSON / YAML / XML / TOML / CSV).
|
| 28 |
+
|
| 29 |
+
Loss is applied only to the final assistant output,
|
| 30 |
+
while intermediate reasoning (Chain-of-Thought) is masked.
|
| 31 |
|
| 32 |
## Training Configuration
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
+
- Base model: Qwen/Qwen3-4B-Instruct-2507
|
| 35 |
+
- Method: QLoRA (4-bit)
|
| 36 |
+
- Max sequence length: 1024
|
| 37 |
+
- Epochs: 2
|
| 38 |
+
- Learning rate: 1e-06
|
| 39 |
+
- LoRA: r=96, alpha=192
|
|
|
|
|
|
|
| 40 |
|
| 41 |
## Usage
|
| 42 |
|
|
|
|
| 52 |
model = AutoModelForCausalLM.from_pretrained(
|
| 53 |
base,
|
| 54 |
torch_dtype=torch.float16,
|
| 55 |
+
device_map="auto",
|
| 56 |
)
|
| 57 |
model = PeftModel.from_pretrained(model, adapter)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
```
|
| 59 |
|
| 60 |
+
## Sources & Terms (IMPORTANT)
|
| 61 |
+
|
| 62 |
+
Training data: u-10bei/structured_data_with_cot_dataset_512_v2
|
| 63 |
|
| 64 |
+
Dataset License: MIT License. This dataset is used and distributed under the terms of the MIT License.
|
| 65 |
+
Compliance: Users must comply with the MIT license (including copyright notice) and the base model's original terms of use.
|
|
|
adapter_config.json
CHANGED
|
@@ -33,13 +33,13 @@
|
|
| 33 |
"rank_pattern": {},
|
| 34 |
"revision": null,
|
| 35 |
"target_modules": [
|
| 36 |
-
"
|
| 37 |
-
"
|
| 38 |
"up_proj",
|
|
|
|
| 39 |
"k_proj",
|
| 40 |
-
"
|
| 41 |
-
"
|
| 42 |
-
"o_proj"
|
| 43 |
],
|
| 44 |
"target_parameters": null,
|
| 45 |
"task_type": "CAUSAL_LM",
|
|
|
|
| 33 |
"rank_pattern": {},
|
| 34 |
"revision": null,
|
| 35 |
"target_modules": [
|
| 36 |
+
"o_proj",
|
| 37 |
+
"gate_proj",
|
| 38 |
"up_proj",
|
| 39 |
+
"q_proj",
|
| 40 |
"k_proj",
|
| 41 |
+
"down_proj",
|
| 42 |
+
"v_proj"
|
|
|
|
| 43 |
],
|
| 44 |
"target_parameters": null,
|
| 45 |
"task_type": "CAUSAL_LM",
|
adapter_model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 792791480
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d6fb93374d50edd5a452ddc507d0dc809bc7fffef75ce0827d1059a7ffc87906
|
| 3 |
size 792791480
|
tokenizer_config.json
CHANGED
|
@@ -233,7 +233,7 @@
|
|
| 233 |
"extra_special_tokens": {},
|
| 234 |
"model_max_length": 262144,
|
| 235 |
"pad_token": "<|vision_pad|>",
|
| 236 |
-
"padding_side": "
|
| 237 |
"split_special_tokens": false,
|
| 238 |
"tokenizer_class": "Qwen2Tokenizer",
|
| 239 |
"unk_token": null
|
|
|
|
| 233 |
"extra_special_tokens": {},
|
| 234 |
"model_max_length": 262144,
|
| 235 |
"pad_token": "<|vision_pad|>",
|
| 236 |
+
"padding_side": "right",
|
| 237 |
"split_special_tokens": false,
|
| 238 |
"tokenizer_class": "Qwen2Tokenizer",
|
| 239 |
"unk_token": null
|