Skip to content
ML to LLMs
Cheat sheets

LLM adaptation

Prompting, RAG, fine-tuning, LoRA, and preference optimization compared by what they change and when to use them.

MethodWhat changesCostUse whenNot for
Prompting (zero/few-shot)context onlylowestfirst attempt for any task; format and instructionsknowledge the model lacks
RAGcontext, with retrieved documentsmoderate (index, retrieval)private or frequently changing facts; citationschanging style or format
Tool callingcontext, with live data and actionsmoderateexact lookups, calculations, actionsopen-ended knowledge
LoRA / PEFTsmall added weights (r(din+dout)r(d_{\text{in}} + d_{\text{out}}) per matrix)low to moderate trainingconsistent format, tone, domain behavior; making a small model good at a narrow taskinjecting changing facts
Full fine-tuningall weightshighlarge data, big domain shiftsmall data (overfits, forgets)
Instruction tuning (SFT)weights, on instruction-response pairshighturning a base model into an assistant
Preference optimization (RLHF, DPO)weights, on ranked response pairshighhelpfulness, harmlessness, styleadding knowledge
Key distinction

RAG changes the model's context; fine-tuning changes its weights. Use RAG for facts that change; fine-tune for behavior.

Decision order: prompt → add RAG/tools → LoRA → full fine-tuning. Each step must beat the previous one on an evaluation set.

LoRA arithmetic: a 4096 × 4096 matrix has 16.8M parameters; rank 8 trains 65,536 (0.39%).

Hallucination controls: grounding with citations, tools, constrained outputs, verification, abstention, human review. Lower temperature improves consistency, not truth.

Lessons: Adapting LLMs · The RAG pipeline