LLMs & Applied NLPAdvanced20 min read5 questions

Fine-tuning, LoRA/QLoRA and Preference Optimisation

When to fine-tune at all, how LoRA actually works, and the real difference between RLHF and DPO — with the numbers that justify each choice.

Covers: Full fine-tuning vs PEFT, LoRA and QLoRA mathematics, instruction tuning, RLHF vs DPO, catastrophic forgetting

Fine-tuning is the most over-recommended solution in applied AI. The first job of a strong candidate is to say when not to do it — and the second is to know exactly how LoRA works when you do.

Filter
0/5 mastered
Intermediatefine-tuningragdecision-makingAsked at Anthropic, OpenAI solutions

30-second answer

That fine-tuning is the wrong tool for that goal. Fine-tuning adjusts behaviour, format and style; it is an unreliable and expensive way to inject facts, and the facts go stale the moment the docs change. RAG is the correct approach for knowledge. I would propose RAG first, then consider fine-tuning only if the remaining gap is about tone, output format, or a domain-specific task the base model performs poorly.

AdvancedloraqlorapeftAsked at Hugging Face, Together AI

30-second answer

LoRA freezes the pre-trained weight W and learns a low-rank update ΔW = BA where B is d×r and A is r×k with r ≪ d. You train ~0.1–1% of the parameters, so optimiser state collapses and adapters are megabytes rather than gigabytes. QLoRA adds 4-bit NF4 quantisation of the frozen base weights plus double quantisation and paged optimisers, letting you fine-tune a 65B model on a single 48GB GPU. Rank 8–16 covers most style/format tasks; 64–128 for genuinely new capabilities.

ExpertrlhfdpoalignmentAsked at Anthropic, OpenAI

30-second answer

RLHF has three stages: supervised fine-tuning, training a reward model on human preference pairs, then optimising the policy against that reward with PPO plus a KL penalty to the reference model. DPO proves the optimal RLHF policy has a closed form, which lets you skip the reward model and the RL loop entirely and optimise a simple classification-style loss directly on preference pairs. DPO won on simplicity, stability and cost — it needs two models in memory instead of four.

Advancedcatastrophic-forgettingfine-tuningdata-mixingAsked at Hugging Face, Cohere

30-second answer

Catastrophic forgetting: gradient descent on a narrow distribution moves weights away from the configuration that encoded general capability, and nothing in the loss penalises that. Fixes ranked by effectiveness: mix 5–30% general instruction data into the fine-tuning set, use LoRA so the base weights are frozen, lower the learning rate and train fewer epochs, and always evaluate on a general benchmark alongside your domain metric.

Advanceddata-curationinstruction-tuningsftAsked at Scale AI, Surge

30-second answer

Quality and diversity beat volume decisively. LIMA showed 1,000 carefully curated examples can outperform 50,000 noisy ones for instruction tuning. Target 1,000–10,000 examples for style and format tasks, 10,000–100,000 for genuinely new capability. Good examples are diverse in phrasing and task type, consistent in output format, contain no contradictions, and — critically — no example should require knowledge the model does not have.

Showing 5 of 5 questions for fine-tuning-lora-and-rlhf.

Check your understanding

5 questions · no sign-up, nothing stored

0/5 answered
Question 1

1.A stakeholder wants to fine-tune so the model 'knows' their documentation. The correct response is:

Question 2

2.In LoRA, matrix B is initialised to zero because:

Question 3

3.DPO eliminates the need for a reward model because:

Question 4

4.The most effective single fix for catastrophic forgetting during fine-tuning is:

Question 5

5.The LIMA paper demonstrated that:

Hands-on challenge

Build it — this is what you talk about in a deep-dive round.

Run a controlled fine-tuning experiment

Fine-tune a small open model on a domain task and quantify every trade-off you have read about here.

Requirements

  • A held-out eval set of 100+ hand-curated examples, plus a general benchmark and a format-compliance check.
  • LoRA runs at r ∈ {8, 16, 64}, and separately targeting attention-only vs all linear layers.
  • Data-mixing sweep at general_ratio ∈ {0, 0.05, 0.15, 0.30}; plot domain accuracy against the general benchmark.
  • A dataset audit report (duplicates, diversity, format consistency, length skew, accidental refusals) before training.

Stretch goals

  • Run DPO on preference pairs generated from your SFT model and measure the reward margin and preference accuracy.
  • Sweep weight interpolation λ between base and fine-tune and find the Pareto front.