LLM generation and adaptation
Understand decoding, fine-tuning and inference tradeoffs.
Choose decoding parameters and evaluate generated outputs on representative prompts.
Interview questions
Choose a question to reveal its answer.
01EasyCoreHow does autoregressive text generation work?
Answer
How does autoregressive text generation work?
Predicts the next token conditioned on preceding tokens, then repeats.
Generate a continuation one token at a time.
02EasyCoreWhat is an LLM context window?
Answer
What is an LLM context window?
Maximum token sequence supported by a model configuration, including relevant input and output budgeting.
Trim or retrieve input passages to fit a model request.
03EasyCoreVisualHow does temperature change token sampling?
Answer
How does temperature change token sampling?
Rescales logits before sampling; lower positive values sharpen the distribution.
Sampling typically applies softmax(logits/T) for T > 0. Lower temperature concentrates probability on higher logits; higher temperature spreads probability. It changes sampling behavior rather than supplying new facts or improving retrieval.
Make stochastic generation less varied.
import torch
logits = torch.tensor([1., 2., 3.])
for t in [0.5, 1., 2.]:
print((logits/t).softmax(0))Higher temperature flattens the distribution.
04MediumHigh priorityHow does top-k sampling constrain generation?
Answer
How does top-k sampling constrain generation?
Restricts sampling to the k highest-probability tokens.
Avoid drawing from very low-ranked candidate tokens.
05MediumHigh priorityHow is top-p sampling different from top-k?
Answer
How is top-p sampling different from top-k?
Restricts sampling to a smallest high-probability set meeting a cumulative mass threshold.
Adapt candidate count to uncertainty at each step.
06MediumWhy does a KV cache accelerate inference?
Answer
Why does a KV cache accelerate inference?
Stores attention keys and values from previous positions to avoid recomputation during decoding.
During generation, a decoder stores prior keys and values instead of recomputing them for each new position. Memory scales with sequence length, number of layers, KV head count and head dimension. Grouped-query attention can reduce the cache footprint.
Speed incremental generation at the cost of memory.
07MediumWhat is instruction tuning?
Answer
What is instruction tuning?
Fine-tunes a model on instruction-response examples.
Improve a pretrained model's ability to follow task instructions.
08MediumHow does LoRA reduce trainable parameters?
Answer
How does LoRA reduce trainable parameters?
Trains low-rank updates to selected model weights while freezing base weights.
Adapt a large model using fewer trainable parameters.
09HardWhat are the tradeoffs of model quantization?
Answer
What are the tradeoffs of model quantization?
Represents model weights or activations with lower precision.
Reduce inference memory usage while checking quality impact.
10HardWhat does perplexity measure and when is comparison valid?
Answer
What does perplexity measure and when is comparison valid?
Exponentiated mean negative log likelihood on a token sequence under a specified tokenizer and model.
Compare language-model predictive likelihood on the same evaluation setup.
Priority and difficulty are editorial study recommendations.
Technical reference: Documentation / paper ↗
Try a few practice questions
Explore the questions before creating a free account.
1. Which sampling method keeps the smallest ranked set with cumulative probability at least p?
2. What is cached during autoregressive decoding to avoid recomputation?
3. What is a typical consequence of lower-bit weight quantization?
LLM fine-tuning and alignment
Continue to the next set of interview questions.