LLMS & TRANSFORMERS · INTERVIEW QUESTION
Explain the difference between LoRA, full fine-tuning, and prompt tuning. When would you use each?
🟡 intermediate · Pre-training & Fine-tuning
Hint: Think about parameter efficiency, compute requirements, and catastrophic forgetting.
Answer
Parameter-efficient fine-tuning methods adapt LLMs without updating all billions of parameters.
Comparison
| Method | Trainable Params | Quality | Memory | Inference Cost |
|---|---|---|---|---|
| Full fine-tuning | 100% | Best | Very high | Same |
| LoRA | 0.1-1% | Near full FT | Low | Zero overhead* |
| QLoRA | 0.1-1% | Near full FT | Very low | Low |
| Prompt tuning | 0.01% | Lower | Minimal | Minimal |
*After merging adapter into base weights.
LoRA (Low-Rank Adaptation)
Freezes base model, adds trainable low-rank matrices: where , , .
python
from peft import LoraConfig, get_peft_model
config = LoraConfig(r=16, lora_alpha=32, target_modules=['q_proj', 'v_proj'])
model = get_peft_model(base_model, config)
model.print_trainable_parameters() # ~0.2% of totalWhen to Use Each
- Full FT: small specialized models, unlimited compute
- LoRA: large models, limited compute (most practical choice)
- QLoRA: memory-constrained (single GPU for 70B models)
- Prompt tuning: quick task adaptation, no model modification
Related questions
- How do you evaluate LLMs? What benchmarks and metrics matter?
- What is the difference between encoder-only, decoder-only, and encoder-decoder transformers?
- Explain the tokenization strategies used in LLMs: BPE, WordPiece, and SentencePiece.
- What is the scaling laws relationship between model size, data, and compute?
- Explain the self-attention mechanism in detail. What are Q, K, V and why do we use scaled dot-product attention?