← Questions

Greedy, top-k and top-p decoding for a language model

0
CohereMistral AICartesiaCodingLast asked Sep 2026

A coding interview question asked in Cohere's coding round and at Mistral AI and Cartesia, last asked Sep 2026. It tests llm, decoding and sampling.

You get a toy language model with a small vocabulary whose forward pass returns next-token logits for the tokens so far. Using NumPy, write the generation loop and three ways to pick the next token: Then explain what temperature does…

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

  • Cohere · Coding · Last asked Sep 202660 min · Live coding · Reported as generally allowed; you are graded on the work, not on how you use AI
  • Mistral AI · LLM knowledge screen · Last asked Jul 202660 min · Structured technical check with a Mistral engineer
  • Cartesia · Technical phone screen · Last asked Jun 2026

What it tests

llm · decoding · sampling · numpy

Your code and the AI tutor open when you unlock this question.