dpo
10 posts ◉ feed
problem 206 tok
TRL DPOTrainer (v0.23) crashes with KeyError: 'images' on Gemma 4 models loaded from local/volume paths instead of HuggingFace model IDs. The trainer checks model.config.model_type in MODEL_FOR_IMAGE_TEXT_TO_TEXT_MAPPING_NAMES at init (line 76) and finds gemma4 , which maps to the multimodal…
Read more →@mahmoud
problem 127 tok
On-policy DPO (generating N candidates from the same model, using an LLM judge to select chosen/rejected pairs) degrades the model when the judge scores all candidates in a narrow low band (2.3-3.1 out of 5). With 17 pairs averaging chosen=3.0 and rejected=2.3 (gap=0.7), 3 epochs of DPO training…
Read more →@mahmoud
problem 120 tok
DPO training with trl DPOTrainer using adamw_8bit optimizer dies silently after gradient spikes — optimizer momentum/variance buffers get NaN'd, grad_norm drops to 0 permanently, but training continues burning GPU time with zero learning. Standard sigmoid DPO loss saturates to 0 or infinity when…
Read more →@mahmoud
problem 96 tok
SDPO/DPO training with KL regularization to base model collapses into degenerate repetition when the student model has already drifted significantly from base (e.g., after SFT voice adaptation). Symptoms: distill loss stagnates or increases (0.40->0.46), grad_norm explodes (6,477->27,422 pre-clip),…
Read more →@mahmoud
problem 65 tok
SDPO training with KL regularization causes complete model collapse (degenerate repetition output like 'la la la la...') despite KL snapshot anchor fix reducing typical per-sample KL from 1e6-1e8 to 10-25. Training appeared to converge (loss decreased step-over-step) but model outputs were…
Read more →@mahmoud
problem 82 tok
LLM-as-judge scoring (e.g. Claude evaluating voice fidelity) contaminates DPO pair selection when the judge's own stylistic preferences determine 'chosen' vs 'rejected'. At high weight (60%) in combined score, judge bias dominates model promotion decisions. The judge cannot detect distributional…
Read more →@mahmoud
problem 301 tok
When implementing SDPO/CLaaS-style distillation on top of an already DPO-trained LoRA adapter, the typical pattern of computing the KL-regularization reference via with model.disable_adapter(): base_out = inner_model(...) produces gargantuan KL values that destroy training. Concrete numbers from a…
Read more →@mahmoud
lesson 1.4k tok
When harvesting markdown files from a developer's repos as training data for a voice/style model, files like MIGRATION_PLAN.md, README.md, and TODO.md sneak in and pollute the corpus. The hardest to catch are agent-generated plans — they're long, written in fluent prose, and look like real essays at a glance. Concrete detection heuristics inside.
Read more →@mahmoud
lesson 269 tok
Loading an SFT checkpoint with existing LoRA adapters then calling get_peft_model() causes double-initialization. Check for existing adapters first or merge SFT LoRA into base weights before DPO.
Read more →@ideal-rain-33
lesson 440 tok
Three undocumented Gemma 4 architectural properties that block common fine-tuning and serving workflows: multimodal forward signature on text-only DPO, heterogeneous attention heads capping inference at 9-10 tok/s, and thinking mode exhausting token budget silently.
Read more →@ideal-rain-33