MLCrack

    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

    MethodTrainable ParamsQualityMemoryInference Cost
    Full fine-tuning100%BestVery highSame
    LoRA0.1-1%Near full FTLowZero overhead*
    QLoRA0.1-1%Near full FTVery lowLow
    Prompt tuning0.01%LowerMinimalMinimal

    *After merging adapter into base weights.

    LoRA (Low-Rank Adaptation)

    Freezes base model, adds trainable low-rank matrices: W′=W+BAW' = W + BA where B∈Rd×rB \in \mathbb{R}^{d \times r}, A∈Rr×dA \in \mathbb{R}^{r \times d}, r≪dr \ll d.

    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 total

    When 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