CoolFace
Modelpublic

Shion1124/dapo-dora-qwen-struct

sourceHugging Faceapache-2.0updated 8mo agoView on Hugging Face
0likes14downloads
Model Card

Qwen3-4B-DAPO-DoRA-StructEval-v1

This model implements DAPO (Direct Alignment from Preference Optimization), an RLVR (Reinforcement Learning from Verifiable Rewards) approach, combined with DoRA (Weight-Decomposed Low-Rank Adaptation).

๐ŸŽฏ Key Innovation: DAPO + DoRA

What is DAPO?

DAPO extends DPO by incorporating verifiable rewards during training:

  • โ€”Traditional DPO: Learns from preference pairs (chosen vs. rejected)
  • โ€”DAPO: Adds automated verification of structured outputs (JSON/XML/YAML validity)
  • โ€”Verification Weight: 30% of the loss signal comes from format validation

Why DoRA for DAPO?

DoRA's weight decomposition (magnitude + direction) is ideal for DAPO because:

  • โ€”Stable learning with stronger reward signals
  • โ€”Better convergence with verification-augmented loss
  • โ€”Lower rank (r=32) achieves higher quality than standard LoRA

๐Ÿ“Š Training Pipeline

Stage 1: SFT + DoRA

  • โ€”Data: 70% v5 (high-quality) + 30% Hard-Mix (complex reasoning)
  • โ€”Method: DoRA (r=32, alpha=64)
  • โ€”Focus: Learn structured output generation with CoT masking

Stage 2: DAPO + DoRA (This Model)

  • โ€”Data: DPO preference dataset with CoT reasoning
  • โ€”Method: DAPO with 30% verification reward
  • โ€”Focus: Align outputs to preferred structures + validate syntax

๐Ÿ”ง Training Configuration

DAPO Settings:

  • โ€”Learning rate: 2e-05 (optimized for DoRA stability)
  • โ€”Beta: 0.15 (preference strength)
  • โ€”Verification weight: 0.3 (30% validation reward)
  • โ€”Max sequence length: 1536

DoRA Settings:

  • โ€”Rank: 32 (optimal for DoRA)
  • โ€”Alpha: 64 (r * 2 ratio)
  • โ€”Dropout: 0 (DoRA recommendation)
  • โ€”Target modules: All attention + MLP layers

Optimization:

  • โ€”Epochs: 1
  • โ€”Batch size: 2 ร— 4 accumulation = 8 effective
  • โ€”Weight decay: 0.005 (light for DoRA)
  • โ€”Warmup ratio: 0.15 (DoRA stability)

๐Ÿš€ Usage

python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch

model_id = "Shion1124/dapo-dora-qwen-struct"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
    model_id,
    torch_dtype=torch.float16,
    device_map="auto"
)

prompt = "Convert this to JSON: Name: Alice, Age: 30, City: Tokyo"
inputs = tokenizer.apply_chat_template(
    [{"role": "user", "content": prompt}],
    tokenize=True,
    add_generation_prompt=True,
    return_tensors="pt"
).to("cuda")

outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.1)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))

๐Ÿ“ˆ Expected Performance

Compared to base DPO:

  • โ€”Format Accuracy: +5-10% (from verification rewards)
  • โ€”Reasoning Quality: +3-7% (from DoRA stability)
  • โ€”Overall Score: 0.85-0.92 on StructEval-T

๐Ÿ“š Training Data

  1. 1.SFT Stage:
  2. 2.u-10bei/structureddatawithcotdataset512v5
  3. 3.daichira/structured-hard-sft-4k
  1. 1.DAPO Stage:
  2. 2.u-10bei/dpo-dataset-qwen-cot (preference pairs)

โš–๏ธ License

  • โ€”Model: Apache 2.0
  • โ€”Dataset: MIT License (see original datasets)
  • โ€”Users must comply with base model and dataset terms

๐Ÿ”ฌ Technical Details

Verifiable Rewards:

  • โ€”JSON validation: json.loads() success = 1.0 reward
  • โ€”XML validation: ElementTree.fromstring() success = 1.0 reward
  • โ€”YAML validation: yaml.safe_load() success = 1.0 reward
  • โ€”Partial credit: 0.3 for attempted format with errors

Loss Function:

DAPO_loss = (1 - ฮฑ) ร— DPO_loss + ฮฑ ร— Verification_penalty
where ฮฑ = 0.3 (verification weight)

Built with โค๏ธ using Unsloth + DAPO + DoRA