Lesson 32 / 33

Common Interview and Exam Questions

Answer the questions most often asked about Transformers and the Hugging Face stack, with reasons.

By · 15 years in web development

Questions you should be able to answer

What is the difference between BERT and GPT? BERT is an encoder trained with masked-token prediction and sees context in both directions; GPT-style models are decoders trained to predict the next token with a causal mask, so they generate text. Why subword tokenization? It keeps the vocabulary manageable and handles unseen words by splitting them into known pieces. What is the attention mask for? It tells the model to ignore padding positions. Logits versus probabilities? Logits are raw scores; softmax turns them into probabilities. How does LoRA reduce memory? It freezes the base model and trains small low-rank matrices, so gradients and optimiser state exist only for a tiny fraction of parameters. What does temperature do? It rescales logits before softmax; lower is more deterministic, higher more diverse. Why is trust_remote_code risky? It executes Python from the repo on your machine. How do you make results reproducible? Pin model revisions, fix seeds, save the tokenizer with the model and record library versions.

Structure your answer

A good interview answer has three parts: a one-line definition, the mechanism (how it works), and a trade-off or example from your own project. "LoRA trains small low-rank adapters; it freezes the base weights so memory drops; in my project a rank-16 adapter fit on a 16 GB GPU" beats a memorised paragraph.

Design-style questions

Expect at least one open question such as "How would you build a support-ticket classifier?" A strong answer walks the whole lifecycle. Clarify labels and volume. Start with a baseline, perhaps zero-shot classification or a simple model, to learn what is hard. Collect and clean labelled data, split it with a fixed seed and deduplicate across splits. Fine-tune a small encoder with Trainer, choose metrics such as macro F1 that respect class imbalance, and inspect errors per class. Serve with the model loaded once behind an API, batch requests, and monitor latency, input drift and the share of low-confidence predictions. Plan for retraining as new labels appear. For generation questions, mention chat templates, decoding settings, evaluation on a fixed prompt set and guarding against prompt injection. Mention costs and hardware limits explicitly: they separate a realistic design from a wish list.

A viva, not a quiz show

An interview on this topic is like a project viva: the examiner keeps asking "why?" until you reach the edge of your understanding. Prepare by explaining each concept aloud to a friend, who keeps asking "but why?" after every answer.

Quick check: An interviewer asks why your fine-tuning results changed when you reran the same script a month later, with identical code and data, loading the base model by name only. What is the best answer?

  • The tokenizer cache expired
  • Trainer randomises weights on every run
  • The model id pointed to a branch that moved; pinning a commit revision would have kept the old weights
  • GPUs produce different results every day
Answer

The model id pointed to a branch that moved; pinning a commit revision would have kept the old weights — Loading by name tracks the main branch. Pinning a commit hash keeps the exact files and makes runs reproducible.