Tech_Interview_Prep

Fine-Tuning & Adaptation

Adapting a pretrained LLM's behavior via further training, and how that differs from prompting or RAG.

Try answering in your head first, then click a question to check the model answer.

Q1.Explain the difference between prompting, RAG, and fine-tuning as three ways to adapt an LLM's behavior.(show answer)

Prompting changes what you ask the model, entirely in-context with no weight change — the cheapest and fastest to iterate on. RAG changes what context the model sees by retrieving external information at query time, adding knowledge without touching weights. Fine-tuning changes the model's weights via further training, needed when prompting or RAG can't reliably produce a desired behavior or format.

Q2.What is catastrophic forgetting, and what causes it during fine-tuning?(show answer)

Catastrophic forgetting is the model losing previously learned general capabilities while specializing on new fine-tuning data. It's caused by gradient updates optimized for the new narrow task overwriting weight patterns responsible for broader pretrained behavior — more likely with full fine-tuning, an aggressive learning rate, or narrow/repetitive fine-tuning data.

Q3.Explain how LoRA reduces the memory and compute needed for fine-tuning, mechanically.(show answer)

LoRA freezes the original weight matrices and instead trains two much smaller low-rank matrices whose product approximates the weight update. Since gradients and optimizer state only need to be tracked for these small added matrices — not the full-size original weights — memory and compute needed drop dramatically compared to updating every original parameter.

Q4.What is QLoRA, and what problem does it specifically address beyond standard LoRA?(show answer)

QLoRA additionally quantizes the frozen base model's weights, typically to 4-bit, before applying LoRA adapters — further shrinking the memory footprint of the base model itself, not just the trainable adapter. This enables fine-tuning of much larger models on consumer or limited GPU memory that standard LoRA alone couldn't fit.

Q5.Why is RAG usually preferred over fine-tuning for injecting or updating factual knowledge?(show answer)

Fine-tuning bakes knowledge into weights that go stale as soon as underlying facts change, requiring a new training run to update. RAG's knowledge lives in an external, easily re-indexed source, so updating knowledge is just re-indexing documents — far cheaper and faster to keep current than retraining a model.

Q6.Describe RLHF at a high level: what are the main stages?(show answer)

First, collect comparisons between candidate model responses ranked by human preference. Second, train a reward model to predict human preference scores from those comparisons. Third, use reinforcement learning (e.g. PPO) to fine-tune the base model to maximize the reward model's score — shaping tone, helpfulness, and refusal behavior beyond raw instruction-following.

Q7.What problem does Direct Preference Optimization (DPO) solve relative to classic RLHF, and how?(show answer)

DPO removes the need for a separate reward model and RL loop by reformulating preference optimization as a direct classification-style loss over preferred vs. rejected response pairs — simpler and more stable to train while targeting the same underlying preference-alignment goal as RLHF.

Q8.When would you choose full fine-tuning over PEFT/LoRA despite the extra cost?(show answer)

When maximum task performance is critical and the task requires deep, broad changes to model behavior that a small set of adapter parameters can't capture well, or when the deployment target requires a fully self-contained model without needing to merge or serve separate adapters — though in practice LoRA is competitive for most tasks and is the more common default.

Q9.What's the difference between instruction tuning and RLHF/preference tuning, and why are they often applied in sequence?(show answer)

Instruction tuning teaches the model to follow instructions using supervised (instruction, ideal response) examples. RLHF/preference tuning further refines output quality, tone, and safety using relative preference comparisons rather than single correct answers. They're often sequenced because instruction tuning establishes basic instruction-following first, and preference tuning then polishes quality and alignment on top of that base.

Q10.Why does data quality often matter more than data quantity for fine-tuning?(show answer)

Noisy, inconsistent, or low-quality examples teach the model contradictory or undesirable patterns that a small amount of gradient signal can't average out, while a smaller set of carefully curated examples gives a cleaner, more consistent training signal. Quantity without quality can actively hurt performance on the target behavior.

Q11.Explain why the learning rate is a particularly sensitive hyperparameter when fine-tuning versus training from scratch.(show answer)

A pretrained model already encodes substantial useful structure. A learning rate that's too high can overwrite that structure quickly (catastrophic forgetting), especially since fine-tuning typically runs far fewer steps than pretraining, leaving less opportunity to recover from an aggressive early update — fine-tuning generally uses a much smaller learning rate than pretraining from scratch.

Q12.What is model distillation, and how might you use it after fine-tuning a large model?(show answer)

Distillation trains a smaller "student" model to mimic a larger "teacher" model's outputs, e.g. matching its predicted probabilities or generated responses. After fine-tuning a large model to the desired behavior, you could distill that behavior into a smaller, cheaper-to-serve model for production, trading some quality for lower latency and cost.

Q13.Describe how you'd evaluate whether a fine-tuning run succeeded, beyond just checking the training loss went down.(show answer)

Evaluate on a held-out set representative of real usage, not seen during training, to check generalization; specifically test whether the target behavior actually improved; and separately check for regressions on general capabilities or tasks the model previously handled well. Training loss alone doesn't reveal overfitting or forgetting.

Q14.What is prompt tuning, and how does it compare to LoRA in terms of what's being learned?(show answer)

Prompt tuning learns a small set of continuous "soft prompt" embeddings prepended to the input, while all model weights, including LoRA-style adapters, remain untouched. It's even more parameter-efficient than LoRA but generally has less capacity to shift model behavior, making it suited to narrower adaptation needs.

Q15.Explain the tradeoff between PEFT/LoRA and full fine-tuning in terms of catastrophic forgetting risk.(show answer)

Since LoRA freezes the original weights and only trains a small added set of parameters, the base model's original capabilities are largely preserved by construction, making catastrophic forgetting less likely than with full fine-tuning, which directly modifies all the original weights and can more easily drift away from previously learned general behavior.

Q16.Why might a team try few-shot prompting before investing in fine-tuning, even when fine-tuning would likely work better?(show answer)

Few-shot prompting requires no training infrastructure, no labeled dataset curation, and can be iterated on in minutes. It's a fast, low-cost way to validate whether the desired behavior is achievable at all before committing engineering time and compute to collecting fine-tuning data and running training experiments.

Q17.What kinds of tasks are a poor fit for fine-tuning, and why?(show answer)

Tasks primarily needing up-to-date or rapidly changing factual knowledge are a poor fit, since that's better served by RAG, as are tasks with very little available labeled data, since there's insufficient signal to fine-tune reliably. Fine-tuning is best suited to stable, well-defined behavior or format changes with enough quality examples to learn from.

Q18.How would you structure an instruction-tuning dataset for a task like generating structured JSON output from natural language requests?(show answer)

Collect or generate a diverse set of natural-language-request-to-correctly-formatted-JSON-response pairs covering the range of expected inputs and edge cases, ensuring the JSON responses are consistently well-formed and validated — the model will learn to mimic whatever patterns, including inconsistencies, are present in the training examples.

Q19.What's the danger of evaluating a fine-tuned model only on the same distribution of examples it was fine-tuned on?(show answer)

It can look like the fine-tune succeeded, matching in-distribution examples well, while actually failing to generalize to realistic variation in production inputs — because the evaluation never tests behavior outside what the model has effectively memorized from training.

Q20.Explain why RLHF specifically uses comparisons between responses rather than single "correct" labeled examples.(show answer)

For open-ended generation, there's often no single objectively correct response, but humans can more reliably and consistently judge which of two candidate responses is better. Pairwise preference judgments provide a more tractable and consistent training signal than trying to define one canonical "correct" answer for subjective quality dimensions like helpfulness or tone.

Q21.What is the relationship between PEFT adapters and serving multiple fine-tuned "variants" of a model in production?(show answer)

Since LoRA adapters are small and separate from the frozen base model, multiple task-specific adapters can be trained independently and swapped in and out, or even served simultaneously via multi-adapter serving, against the same base model — avoiding the cost of hosting a full separate fine-tuned model copy per use case.

Q22.Describe a scenario illustrating why fine-tuning for knowledge injection is a common but costly mistake.(show answer)

For example, fine-tuning a model on a company's product documentation to "teach it the facts," then needing to retrain from scratch every time the documentation changes — an expensive, slow cycle compared to RAG, where updating the documentation just means re-indexing it, with no retraining needed at all.

Q23.What's the difference between "adapting behavior" and "adapting knowledge," and why does that distinction guide the prompting/RAG/fine-tuning decision?(show answer)

Behavior — format, tone, consistent structured output, task-specific style — is what fine-tuning is well suited to shift, since it's a persistent pattern in how the model responds. Knowledge, specific facts, is better handled by RAG since it can be updated without retraining. Conflating the two leads to reaching for the wrong tool, such as fine-tuning to add facts that then go stale.

Q24.How would you set up an experiment to determine whether a LoRA fine-tune actually improved the target task without introducing regressions elsewhere?(show answer)

Run both the fine-tuned model and the base model on a held-out target-task evaluation set, checking for improvement, and on a separate general-capability benchmark or set of prior task types the model handled, checking for no meaningful regression. Comparing both dimensions, rather than only the target metric, catches forgetting that a single-metric evaluation would miss.

Q25.Why might catastrophic forgetting be harder to detect than it sounds, in practice?(show answer)

It may not show up as an obvious, uniform capability loss — it can appear as subtle degradation on specific unrelated tasks or edge cases not covered by whatever quick sanity checks were run after fine-tuning. Teams that only spot-check the target task's improvement can ship a model that's quietly worse at things users still relied on.