Top-P

BytapaScript

BeginnerLLM Concepts
In a nutshell

A sampling knob that keeps only the most likely next tokens.

What it means

A sampling setting that limits next-token choices to likely candidates whose combined probability reaches a specified threshold.

💡 Asking a restaurant to choose from the most popular dishes rather than the entire menu.

Code example

const res = await openai.chat.completions.create({
  model: "gpt-4o",
  top_p: 0.9, // only sample the most likely tokens
  messages: [{ role: "user", content: "Write a tagline" }],
});

Why it matters

It provides another way to control response generation and output diversity.

Related terms

Learn Full Stack

with tapaScript

By clicking Sign Up you re confirming that you agree with our Terms and Conditions.

newsletter

Don't forget to connect with us on