Text Generation
PEFT
Safetensors
English
qlora
lora
structured-output
mt628754 commited on
Commit
95fc8ba
·
verified ·
1 Parent(s): 6d3d40b

v8: r=96, alpha=192, lr=1e-6, max_len=1024, epoch=2 + upsample (README written by author)

Browse files
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
- - dpo
13
- - unsloth
14
- - qwen
15
- - alignment
16
  ---
17
 
18
- # qwen3-4b-structured-sft-dpo
19
 
20
- This model is fine-tuned from **Qwen/Qwen3-4B-Instruct-2507** using SFT, then further optimized with **Direct Preference Optimization (DPO)** via the **Unsloth** library.
 
21
 
22
- This repository contains **LoRA adapter weights**. The base model must be loaded separately with PeftModel.
 
23
 
24
  ## Training Objective
25
- This model has been optimized using DPO to align its responses with preferred outputs, focusing on improving reasoning (Chain-of-Thought) and structured response quality based on the provided preference dataset.
 
 
 
 
 
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
- **Stage 2 - DPO:**
36
- - **Dataset**: u-10bei/dpo-dataset-qwen-cot
37
- - **Method**: DPO (Direct Preference Optimization)
38
- - **Epochs**: 1
39
- - **Learning rate**: 1e-07
40
- - **Beta**: 0.1
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 & License (IMPORTANT)
 
 
71
 
72
- * **Training Data**: [u-10bei/structured_data_with_cot_dataset_512_v2], [u-10bei/dpo-dataset-qwen-cot]
73
- * **License**: MIT License. (As per dataset terms).
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
- "down_proj",
37
- "q_proj",
38
  "up_proj",
 
39
  "k_proj",
40
- "v_proj",
41
- "gate_proj",
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:03e307618d3940106e51aedd1079b3c177b4018ff3748df585c2992b3582a7e0
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": "left",
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