Skip to content
RED SAGSkills
easyAI Engineer (LLM & Generative AI) interview question

What do temperature and top-p control, and how would you set them for different tasks?

What the interviewer wants to hear

  • Both control randomness of token sampling
  • Temperature reshapes the probability distribution
  • Top-p samples from the smallest set covering probability p
  • Low for extraction and code; higher for creative writing

Model answer

Both settings control how random the output is. At each step the model gives a probability for every possible next token. Temperature rescales these probabilities: low temperature makes the top token much more likely, so output is focused and repeatable; high temperature flattens the distribution, so rarer tokens get picked and output is more varied. Top-p, or nucleus sampling, only samples from the smallest set of tokens whose probabilities add up to p, cutting off the unlikely tail. I usually change one, not both. For extraction, classification, SQL or code, I use low temperature for consistency. For brainstorming, marketing copy or story writing, I use a higher value for variety. Even at zero temperature, outputs may not be perfectly identical, so I still design evals and validation instead of relying on determinism.

Can you answer it under time pressure?

Take a timed easy round and get scored on every answer.

Start mock interview

More easy AI Engineer (LLM & Generative AI) questions