← Lab
Experiment·Fine-tuning & Alignment·5 min read

LoRA → DPO → GRPO Pipeline

Supervised tuning teaches format and domain. Preference optimization teaches judgement. They solve different problems and run in that order.

LoRA → DPO → GRPO Pipeline

A full alignment pipeline is less mysterious than it sounds: prepare data, run supervised fine-tuning, evaluate, then apply preference optimization — measuring at each stage so you know which step earned which gain.

The stages

01Data preparationDeduplicate and length-filter. Removing a third of a raw set is normal and usually improves the result.
02SFT with LoRA / QLoRATeaches format, domain vocabulary and tool-call structure. Parameter-efficient methods train a fraction of a percent of the weights.
03EvaluationA held-out set scored before going further. Without this the later stages are unmeasurable.
04DPOPreference pairs teach which of two plausible answers is better — something SFT structurally cannot express.
05GRPOGroup-relative optimization where a reward is computable, such as whether a tool call was valid.
06ServeMerge the adapter, quantise, deploy behind a serving stack.

Why DPO after SFT rather than instead of it

SFT can teach a model the shape of a good answer. It cannot teach which of two well-formed answers a human would actually send — there is no signal for that in a single-target dataset. Preference pairs carry exactly that signal, and the best source is corrections real users or agents made in production.

What to expect

On a narrow task with a few thousand clean examples, this sequence can move task accuracy from around 61% to the low 80s, and tool-call validity from under 50% to the mid 90s. Output length often drops substantially too, which shows up directly in serving cost.

What to take away
  • Deduplicate aggressively — a smaller clean set trains better.
  • SFT teaches format; preference optimization teaches judgement.
  • Source preference pairs from real corrections, not synthetic ones.
  • Measure after every stage or you cannot attribute the gain.

Field notes on building production AI systems — collected, verified and written up so they are useful to anyone working on the same problems.

smoke
“Innovation distinguishes between a leader and a follower.”

Need an AI system that holds up in production? Tell me what breaks today and I'll tell you what I'd build.

Call Me now !

mail

abdelmajidzaddi088@gmail.com

address

Mohammedia, Morocco

phone

+212 695 557 631