Interview Q&A / AI & Generative AI
AI & Generative AI interview questions
LLMs, tokens, embeddings, RAG and prompt engineering, the questions every AI role now asks.
Prefer rapid revision? Practise AI & Generative AI short interview answers →
- What do temperature and top-p control in an LLM?
Both control how the next token is picked from the model's probabilities. Temperature sharpens or flattens the probabilities (low means predictable, high means varied), and top-p limits sampling to the smallest set of tokens whose probabilities add up to p.
IntermediateIn-depth3 min read - What happens when you set temperature to 0?
The model effectively always picks the most likely next token, so output becomes close to deterministic and repeatable. It suits extraction and classification, but it is not a guarantee of a correct or perfectly identical answer.
BeginnerQuick answer1 min read - What is greedy decoding, and what is its weakness?
Greedy decoding always picks the single most probable next token. It is deterministic and fast, but it can produce repetitive or dull text and can miss better full sentences, because a locally best word may lead to a worse overall answer.
BeginnerQuick answer1 min read - Which sampling settings would you use for JSON extraction versus brainstorming taglines?
For JSON extraction use low temperature, near zero, so output is stable and format errors are rare. For brainstorming use a higher temperature, with perhaps a moderate top-p, so the model offers varied options. Always validate structured output.
BeginnerQuick answer1 min read - Why can an LLM give different answers to the same question?
Most chat settings sample the next token from a probability distribution instead of always taking the top one, so small random choices early on lead to different wording or even different conclusions. Lowering temperature reduces this variation.
BeginnerQuick answer1 min read - What do repetition, frequency and presence penalties do during generation?
They lower the chance of tokens that have already appeared. A frequency penalty grows with each repeat, a presence penalty applies once a token has appeared at all. They reduce loops and repeated phrases but can hurt text that needs repetition.
IntermediateQuick answer1 min read - What is top-k sampling, and how does it differ from top-p?
Top-k keeps only the k most likely tokens and samples among them. Top-p keeps the smallest set of tokens whose probabilities add up to p. Top-k uses a fixed count, while top-p adapts the candidate list to how confident the model is.
IntermediateQuick answer1 min read