# Temperature, top-p and other sampling parameters explained

[Skip to content](#lm-inhoud)Network/[NL](/en/sampling-parameters)EN[Hubhub.llmnet.nlCompare models on task, language, cost and license.](https://hub.llmnet.nl/en/)[Communitycommunity.llmnet.nlPrompt techniques, patterns and system prompts.](https://community.llmnet.nl/en/)[APIapi.llmnet.nlLLMs in production: rate limits, routing, structured output.](https://api.llmnet.nl/en/)[Consultancyconsultancy.llmnet.nlRolling out AI in an organization, pilot to production.](https://consultancy.llmnet.nl/en/)[Newsnieuws.llmnet.nlAI developments, explained for the Netherlands.](https://nieuws.llmnet.nl/en/)[Benchmarkbenchmark.llmnet.nlMeasure AI quality yourself, on your own tasks.](https://benchmark.llmnet.nl/en/)[Careersvacatures.llmnet.nlAI roles, salaries and career paths in the Netherlands.](https://vacatures.llmnet.nl/en/)[Learnleren.llmnet.nlAI concepts in plain language, beginner to builder.](https://leren.llmnet.nl/en/)[Guidegids.llmnet.nlRun AI privately on your own Mac, PC, NAS or home server.](https://gids.llmnet.nl/en/)[Directorydirectory.llmnet.nlMapping the AI ecosystem: tools, models, companies.](https://directory.llmnet.nl/en/)[Radarradar.llmnet.nlSignals from X, research and communities for indie developers.](https://radar.llmnet.nl/en/)[Appsapps.llmnet.nlReviews of AI apps and open-source repos, with tips for builders.](https://apps.llmnet.nl/en/)[llmnet.nl — main site](https://llmnet.nl/en/)[](https://x.com/intent/post?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters&text=Temperature%2C%20top-p%20and%20other%20sampling%20parameters%20explained)[](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters)[](https://www.reddit.com/submit?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters&title=Temperature%2C%20top-p%20and%20other%20sampling%20parameters%20explained)[](#)[](https://x.com/intent/post?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters&text=Temperature%2C%20top-p%20and%20other%20sampling%20parameters%20explained)[](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters)[](https://www.reddit.com/submit?url=https%3A%2F%2Fleren.llmnet.nl%2Fen%2Fsampling-parameters&title=Temperature%2C%20top-p%20and%20other%20sampling%20parameters%20explained)[](#)By Ivo Donker — created with AI assistance (Claude & Gemini) · Last updated: July 27, 2026

leren.llmnet.nl > Models & API

# Temperature, top-p and other sampling parameters explained

When communicating with a Large Language Model via an API or interface, you use sampling parameters to determine how the model chooses from possible next words. In this module, you will learn about the most important settings and their impact on creativity and reliability.

## How LLMs choose words

A language model does not predict entire sentences directly, but calculates the probability of each possible next word (token) in the vocabulary step by step. Without guidance, the model simply always chooses the most likely word. Sampling parameters intervene in this probability distribution process.

## The Most Important Parameters

### 1. Temperature

What it does: Temperature scales the probabilities of tokens before they are converted into likelihoods.

- Low temperature (e.g., 0.0 - 0.2): Makes the probability distribution steeper. The most likely word receives almost all the preference, leading to predictable, deterministic, and factual answers.

- High temperature (e.g., 0.8 - 1.2): Flattens the distribution. Less likely words suddenly stand a better chance, resulting in more creative, surprising output.

### 2. Top-p (Nucleus Sampling)

What it does: Top-p limits the choice of words to a cumulative probability threshold. With a setting of 0.9, the model only considers the set of words that together make up 90% of the cumulative probability. Words with a very low probability are immediately discarded, regardless of the temperature.

### 3. Frequency & Presence Penalty

What it does: These parameters discourage repetition.

- Frequency Penalty: Lowers the probability of a word based on how often that word has already appeared in the generated text.

- Presence Penalty: Encourages the model to talk about new topics by immediately penalizing already used words, regardless of their exact frequency.

## When to use which value?

Use Case | 
Temperature | 
Top-p | 

Code generation / Data extraction | 
0.0 - 0.1 | 
1.0 | 

Business emails / Customer service | 
0.3 - 0.5 | 
0.9 | 

Creative writing / Brainstorming | 
0.8 - 1.0 | 
0.95 | 

### Practical Exercise

You are building an application that analyzes legal contracts and creates bulleted summaries. Which settings do you choose for the API call to prevent the model from making up facts (hallucinating)?

Answer: Choose a low temperature (e.g., 0.1) to ensure maximum predictability and factual accuracy.

© 2026 llmnet.nl — Also visit our [community](https://community.llmnet.nl/en/) for questions and discussions.
