Text Generation
Transformers
Safetensors
English
qwen3
dpo
unsloth
qwen
alignment
conversational
text-generation-inference
Instructions to use Honejudo1234/dpo-qwen-cot-merged_exp08a with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Honejudo1234/dpo-qwen-cot-merged_exp08a with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Honejudo1234/dpo-qwen-cot-merged_exp08a") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Honejudo1234/dpo-qwen-cot-merged_exp08a") model = AutoModelForCausalLM.from_pretrained("Honejudo1234/dpo-qwen-cot-merged_exp08a", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Honejudo1234/dpo-qwen-cot-merged_exp08a with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Honejudo1234/dpo-qwen-cot-merged_exp08a" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Honejudo1234/dpo-qwen-cot-merged_exp08a", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Honejudo1234/dpo-qwen-cot-merged_exp08a
- SGLang
How to use Honejudo1234/dpo-qwen-cot-merged_exp08a with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Honejudo1234/dpo-qwen-cot-merged_exp08a" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Honejudo1234/dpo-qwen-cot-merged_exp08a", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Honejudo1234/dpo-qwen-cot-merged_exp08a" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Honejudo1234/dpo-qwen-cot-merged_exp08a", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use Honejudo1234/dpo-qwen-cot-merged_exp08a with Docker Model Runner:
docker model run hf.co/Honejudo1234/dpo-qwen-cot-merged_exp08a
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -1,21 +1,90 @@
|
|
| 1 |
---
|
| 2 |
-
base_model:
|
| 3 |
-
|
| 4 |
-
-
|
| 5 |
-
- transformers
|
| 6 |
-
- unsloth
|
| 7 |
-
- qwen3
|
| 8 |
-
license: apache-2.0
|
| 9 |
language:
|
| 10 |
- en
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
- **License:** apache-2.0
|
| 17 |
-
- **Finetuned from model :** unsloth/qwen3-4b-instruct-2507-unsloth-bnb-4bit
|
| 18 |
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
|
|
|
|
|
|
|
|
| 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-dpo-qwen-cot-merged
|
| 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 |
+
### Core Hyperparameters
|
| 28 |
+
| Parameter | Value |
|
| 29 |
+
|-----------|-------|
|
| 30 |
+
| **Base Model** | Qwen/Qwen3-4B-Instruct-2507 |
|
| 31 |
+
| **Method** | DPO (Direct Preference Optimization) |
|
| 32 |
+
| **Learning Rate** | 5e-07 |
|
| 33 |
+
| **Beta** | 0.2 |
|
| 34 |
+
| **Epochs** | 1 |
|
| 35 |
+
| **Max Sequence Length** | 1024 |
|
| 36 |
+
|
| 37 |
+
### **Batch Size Configuration**
|
| 38 |
+
| Parameter | Value |
|
| 39 |
+
|-----------|-------|
|
| 40 |
+
| **Per Device Train Batch Size** | 2 |
|
| 41 |
+
| **Gradient Accumulation Steps** | 8 |
|
| 42 |
+
| **Effective Batch Size** | 16 |
|
| 43 |
+
|
| 44 |
+
> **Note**: The effective batch size is calculated as:
|
| 45 |
+
> `Effective Batch Size = per_device_batch_size × gradient_accumulation_steps × num_gpus`
|
| 46 |
+
|
| 47 |
+
### LoRA Configuration
|
| 48 |
+
| Parameter | Value |
|
| 49 |
+
|-----------|-------|
|
| 50 |
+
| **LoRA Rank (r)** | 8 |
|
| 51 |
+
| **LoRA Alpha** | 16 |
|
| 52 |
+
| **LoRA Dropout** | 0 |
|
| 53 |
+
| **Target Modules** | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
|
| 54 |
+
| **Status** | Merged into base model (16-bit) |
|
| 55 |
+
|
| 56 |
+
### Optimizer Settings
|
| 57 |
+
| Parameter | Value |
|
| 58 |
+
|-----------|-------|
|
| 59 |
+
| **Optimizer** | OptimizerNames.ADAMW_8BIT |
|
| 60 |
+
| **Weight Decay** | 0.01 |
|
| 61 |
+
| **Warmup Ratio** | 0.1 |
|
| 62 |
+
## Usage
|
| 63 |
+
Since this is a merged model, you can use it directly with `transformers`.
|
| 64 |
+
|
| 65 |
+
```python
|
| 66 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 67 |
+
import torch
|
| 68 |
+
|
| 69 |
+
model_id = "your_id/your-repo-name"
|
| 70 |
+
|
| 71 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 72 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 73 |
+
model_id,
|
| 74 |
+
torch_dtype=torch.float16,
|
| 75 |
+
device_map="auto"
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
# Test inference
|
| 79 |
+
prompt = "Your question here"
|
| 80 |
+
inputs = tokenizer.apply_chat_template([{"role": "user", "content": prompt}], tokenize=True, add_generation_prompt=True, return_tensors="pt").to("cuda")
|
| 81 |
+
outputs = model.generate(**inputs, max_new_tokens=512)
|
| 82 |
+
print(tokenizer.decode(outputs[0]))
|
| 83 |
|
| 84 |
+
```
|
|
|
|
|
|
|
| 85 |
|
| 86 |
+
## Sources & License (IMPORTANT)
|
| 87 |
|
| 88 |
+
* **Training Data**: [u-10bei/dpo-dataset-qwen-cot]
|
| 89 |
+
* **License**: MIT License. (As per dataset terms).
|
| 90 |
+
* **Compliance**: Users must follow the original base model's license terms.
|