Transformer architectures and training
Compare encoder, decoder and sequence-to-sequence architectures.
Match the model's attention pattern and training objective to the downstream task.
Interview questions
Choose a question to reveal its answer.
01EasyCoreWhy is an encoder-only transformer useful for text classification?
Answer
Why is an encoder-only transformer useful for text classification?
Bidirectional contextual representations can use the full input, making them suitable for classification or token labeling.
Encode a complete support ticket before predicting its category.
02EasyCoreWhy are decoder-only models suitable for autoregressive text generation?
Answer
Why are decoder-only models suitable for autoregressive text generation?
Causal self-attention conditions predictions on a prefix, allowing generation by repeated next-token prediction.
Generate an answer one token at a time.
03MediumCoreWhen would you use an encoder-decoder transformer?
Answer
When would you use an encoder-decoder transformer?
An encoder represents source input and a decoder generates target output using cross-attention to those representations.
Translate a source sentence to another language.
04MediumCoreHow does masked language modeling train an encoder?
Answer
How does masked language modeling train an encoder?
Selected input tokens are hidden or altered and the model learns to recover the original tokens from context.
Learn bidirectional representations from incomplete sentences.
05MediumHigh priorityWhat is the training objective of a causal language model?
Answer
What is the training objective of a causal language model?
Predict subsequent tokens from preceding tokens, commonly minimizing next-token cross-entropy.
Train a decoder using a shifted target sequence.
06MediumHigh priorityWhat is teacher forcing in sequence generation training?
Answer
What is teacher forcing in sequence generation training?
Training provides ground-truth previous output tokens rather than the model's own sampled outputs.
Predict the next translation token given the reference prefix.
07HardHigh priorityWhat is exposure bias in autoregressive generation?
Answer
What is exposure bias in autoregressive generation?
Training on reference prefixes differs from inference on model-generated prefixes, potentially allowing errors to compound.
A wrong generated token changes subsequent generation context.
08HardWhat is the difference between pre-norm and post-norm transformer blocks?
Answer
What is the difference between pre-norm and post-norm transformer blocks?
Pre-norm normalizes inputs before a sublayer, while post-norm normalizes after adding the residual; optimization behavior differs.
Compare residual paths in deep transformer stacks.
09MediumHow does model width relate to head dimension in standard multi-head attention?
Answer
How does model width relate to head dimension in standard multi-head attention?
With equal-sized heads and a standard partition, each head has dimension model width divided by head count.
A 768-wide model with 12 heads uses 64 dimensions per head.
width, heads = 768, 12
assert width % heads == 0
print('Head size:', width // heads)This assumes the common equal-width head partition.
10HardWhy use grouped-query attention during LLM inference?
Answer
Why use grouped-query attention during LLM inference?
Several query heads share key and value heads, reducing KV cache memory relative to full multi-head attention.
Serve long sequences with a smaller cache footprint.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.