Most AI tools have a few knobs you can tweak: temperature, top-p, max tokens, frequency penalty, presence penalty. They sound intimidating but they boil down to "how creative do you want the AI to be?". This tutorial demystifies each one in plain English.
If you only ever use ChatGPT in a browser, you may not see these controls. But every time you use an AI API, a custom app, or a playground, you will. Knowing what they do means you can dial the AI's behaviour exactly where you need it.
Temperature ranges from 0 to about 2. At 0, the AI always picks the single most likely next token — answers become consistent, factual, sometimes a bit dry. At 1, it picks from a wider mix — answers become more varied and creative. Above 1.2 you often get strange, surprising, or unreliable output.
Instead of looking at every possible next token, top-p tells the AI: "only consider the smallest group of tokens whose combined probability adds up to P". A top-p of 0.9 means the AI ignores the long tail of unlikely tokens. Lower top-p = more focused. Higher = more variety.
Most of the time you set either temperature or top-p — not both. Pick one knob and leave the other at default.
This caps how long the AI's answer can be. If you set max tokens too low, the reply gets cut off mid-sentence. Set it high enough for the format you asked for. (Roughly 100 tokens ≈ 75 words.)
Both nudge the AI away from repeating itself.
Values are usually between 0 and 2. Start at 0 and increase gradually if you see repetition.
You can specify a string (or several) that causes the AI to stop generating as soon as it produces them. Useful when you want output in a precise format (e.g. stop after the first "---" line).
Not really a "parameter", but worth listing here. The system prompt is a hidden instruction the AI receives before the conversation begins. It sets the role, the tone, and the rules. (Full deep-dive in Topic 11.)
| Task | Temperature | Top-P | Notes |
|---|---|---|---|
| Code generation | 0 – 0.2 | 0.9 (default) | You want consistency, not creativity. |
| Factual Q&A / summaries | 0.1 – 0.4 | 0.9 | Low randomness to reduce hallucinations. |
| Structured data extraction | 0 | 0.9 | Pure determinism is best. |
| General writing / emails | 0.5 – 0.8 | 0.9 | Balanced; sounds natural. |
| Creative brainstorming | 0.9 – 1.2 | 0.95 | Wider variety; expect some wild ideas. |
| Poetry / fiction / wordplay | 1.0 – 1.4 | 0.95 | Maximum surprise; review carefully. |
Wrong settings for the job
Extract every product name and price from the invoice text below.
Return JSON only: [{"product":"","price":""}]
Invoice text:
[paste invoice here]
(Settings: temperature 1.2 — too high for extraction)
At high temperature, prices are often slightly altered or rounded. The output looks plausible but is not reliable.
Settings matched to the task
Extract every product name and price from the invoice text below.
Return JSON only: [{"product":"","price":""}]
Invoice text:
[paste invoice here]
(Settings: temperature 0 — best for factual extraction)
At temperature 0, the model returns the same structured output every run, and prices match the source.
Run the same creative-writing prompt at temperature 0, 0.7, and 1.3 (use an API playground or an app that exposes the slider). Compare how the answers change.
Run a structured data extraction (e.g. "extract email, phone, and city from the text below in JSON") at temperature 0 versus 1.0. Notice the reliability difference.
If you only use ChatGPT in the browser, mimic temperature in your prompt: ask twice — once "give the safest, most standard answer" and once "give a creative unusual angle". This gives a similar effect without a slider.
Sign in to join the discussion and post comments.
Sign inAdvanced Prompt Engineering Techniques
Master the powerful techniques AI experts use every day. Chain-of-thought, RAG, agents, function calling, prompt evaluation, and much more — 20 deep-dive tutorials.
Prompt Engineering for Data Science & Analytics
Supercharge your data workflows with AI. 15 practical tutorials on using prompt engineering for data cleaning, EDA, machine learning, SQL, visualisation, and more.
Prompt Engineering for Business & Productivity
Use AI to work smarter — automate tasks, make better decisions, and communicate professionally. 12 practical business prompt tutorials for professionals.
Prompt Engineering for Education & Learning
Use AI as your personal tutor. Learn how to study faster, create lesson plans, generate practice questions, master languages, and prepare for competitive exams with smart prompts.
Prompt Engineering for Developers
Use AI as your coding co-pilot. 18 tutorials on writing prompts to generate clean code, debug faster, write tests, build APIs, and ship better software.
Prompt Engineering for Content & Copywriting
Write blogs, ads, emails, and social media content ten times faster with AI. 13 practical tutorials on prompt engineering for content creators and copywriters.