m-fujita commited on
Commit
8f6761d
·
verified ·
1 Parent(s): c21348b

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +33 -35
README.md CHANGED
@@ -1,65 +1,63 @@
1
  ---
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: 512
37
- - Epochs: 1
38
- - Learning rate: 1e-06
39
- - LoRA: r=64, alpha=128
40
 
41
  ## Usage
 
42
 
43
  ```python
44
  from transformers import AutoModelForCausalLM, AutoTokenizer
45
- from peft import PeftModel
46
  import torch
47
 
48
- base = "Qwen/Qwen3-4B-Instruct-2507"
49
- adapter = "your_id/your-repo"
50
 
51
- tokenizer = AutoTokenizer.from_pretrained(base)
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.
 
 
1
  ---
2
  base_model: Qwen/Qwen3-4B-Instruct-2507
3
  datasets:
4
+ - u-10bei/dpo-dataset-qwen-cot
5
  language:
6
  - en
7
  license: apache-2.0
8
+ library_name: transformers
9
  pipeline_tag: text-generation
10
  tags:
11
+ - dpo
12
+ - unsloth
13
+ - qwen
14
+ - alignment
15
  ---
16
 
17
+ # qwen3-4b-structured-output-lora-merged-dpo
18
 
19
+ This model is a fine-tuned version of **Qwen/Qwen3-4B-Instruct-2507** using **Direct Preference Optimization (DPO)** via the **Unsloth** library.
 
20
 
21
+ This repository contains the **full-merged 16-bit weights**. No adapter loading is required.
 
22
 
23
  ## Training Objective
24
+ 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.
 
 
 
 
 
25
 
26
  ## Training Configuration
27
+ - **Base model**: Qwen/Qwen3-4B-Instruct-2507
28
+ - **Method**: DPO (Direct Preference Optimization)
29
+ - **Epochs**: 1
30
+ - **Learning rate**: 1e-07
31
+ - **Beta**: 0.1
32
+ - **Max sequence length**: 1024
33
+ - **LoRA Config**: started from SFT adapter (r=64, alpha=128), updated with DPO, then merged into base (16-bit)
34
 
35
  ## Usage
36
+ Since this is a merged model, you can use it directly with `transformers`.
37
 
38
  ```python
39
  from transformers import AutoModelForCausalLM, AutoTokenizer
 
40
  import torch
41
 
42
+ model_id = "your_id/your-repo-name"
 
43
 
44
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
45
  model = AutoModelForCausalLM.from_pretrained(
46
+ model_id,
47
  torch_dtype=torch.float16,
48
+ device_map="auto"
49
  )
 
 
50
 
51
+ # Test inference
52
+ prompt = "Your question here"
53
+ inputs = tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
54
+ outputs = model.generate(**inputs, max_new_tokens=512)
55
+ print(tokenizer.decode(outputs[0]))
56
+
57
+ ```
58
 
59
+ ## Sources & License (IMPORTANT)
60
 
61
+ * **Training Data**: [u-10bei/dpo-dataset-qwen-cot]
62
+ * **License**: MIT License. (As per dataset terms).
63
+ * **Compliance**: Users must follow the original base model's license terms.