Question presented to candidate: "Explain to me, as if I were a new engineer on the team, what a large language model actually is. When I send it a prompt, what happens step by step until text comes back?"
What a strong answer should cover:
- An LLM is a neural network (almost always a decoder-only transformer) trained to predict the next token given all previous tokens; its knowledge lives in billions of learned weights, not in a database
- Generation is autoregressive: tokenize the prompt, run a forward pass, get logits over the whole vocabulary, turn them into probabilities with softmax, pick one token, append it, repeat until a stop token or a length limit
- The picking step is the decoding strategy: greedy, or sampling shaped by temperature and top-p; this is why the same prompt can give different answers
- Training stages: pretraining on a huge text corpus with a next-token (cross-entropy) loss, then post-training (instruction tuning, preference tuning) that turns a text continuer into an assistant
- Practical consequences: output tokens are produced one at a time (latency grows with output length), the model only sees what fits in its context window, and fluent output is not the same as correct output (hallucination)
Code / implementation expected: Optional โ a toy next-token model and a generation loop are a strong way to show the mechanism; no real model call is needed.