Temperature

الحرارة

Beginnerai-ml1 min read
LLM temperaturesampling temperaturemodel temperature

Definition

A setting (0–1) that controls how random or creative an LLM's responses are — lower is more predictable, higher is more creative.

إعداد (0–1) يتحكم في مدى عشوائية أو إبداعية استجابات النموذج اللغوي الكبير — الأقل أكثر قابلية للتنبؤ والأعلى أكثر إبداعاً.

Why It Matters

Setting the wrong temperature causes real problems. Temperature 0.9 on a data extraction task will produce inconsistent JSON structures. Temperature 0 on a creative writing task will produce repetitive, formulaic content. Every AI API call should have an intentional temperature setting.

يُسبّب ضبط الحرارة الخاطئة مشاكل حقيقية. الحرارة 0.9 في مهمة استخراج البيانات ستُنتج بنيات JSON غير متسقة. الحرارة 0 في مهمة الكتابة الإبداعية ستُنتج محتوى متكرراً ونمطياً. يجب أن يكون لكل استدعاء AI API إعداد حرارة مقصود.

Full Definition

Temperature is a parameter you pass to an LLM API call that controls how much randomness is introduced when the model selects the next token. At temperature 0, the model always picks the most likely next token — responses are deterministic and consistent but may be repetitive. At temperature 1, the model samples from a distribution — responses are more creative and varied but less consistent. For factual Q&A or data extraction, use temperature 0–0.2. For creative writing or brainstorming, use temperature 0.7–1.0.
الحرارة هي معامل تُمرّره لاستدعاء API الخاص بالنموذج اللغوي الكبير يتحكم في مقدار العشوائية المُدخَلة عندما يختار النموذج الرمز التالي. عند الحرارة 0، يختار النموذج دائماً الرمز الأكثر احتمالاً — الاستجابات محددة ومتسقة لكنها قد تكون متكررة. عند الحرارة 1، يأخذ النموذج عينات من توزيع — الاستجابات أكثر إبداعاً وتنوعاً لكنها أقل اتساقاً. للأسئلة والأجوبة الواقعية أو استخراج البيانات، استخدم حرارة 0–0.2. للكتابة الإبداعية أو العصف الذهني، استخدم حرارة 0.7–1.0.

Example Usage

Classification task: `temperature: 0` — you need 'positive' or 'negative', not 'somewhat positive with hints of frustration'. Story generation: `temperature: 0.8` — you want creative, varied output, not the same story every time. Code generation: `temperature: 0.2` — you want correct, predictable code, not creative interpretations of syntax.

مهمة تصنيف: `temperature: 0` — تريد 'إيجابي' أو 'سلبي'، ليس 'إيجابي نوعاً ما مع لمسات من الإحباط'. توليد قصة: `temperature: 0.8` — تريد مخرجات إبداعية ومتنوعة، ليس نفس القصة في كل مرة. توليد كود: `temperature: 0.2` — تريد كوداً صحيحاً وقابلاً للتنبؤ، ليس تفسيرات إبداعية للصياغة.

Knowledge Graph

Avoid these mistakes when using Temperature:

1

Leaving temperature at the API default — always set temperature explicitly; never rely on the default

2

Using high temperature for JSON output — even temperature 0.3 can cause occasional malformed JSON; use structured output modes when available

3

Assuming temperature 0 means perfect accuracy — the model can still be wrong at temperature 0; it just makes the same mistake consistently

Sign in to unlock guided AI explanations from AI Teacher.

Generate a Prompt

Copy this prompt and use it directly with any AI model — no setup needed.

Ready-to-Use Prompt
Help me build a project using Temperature.

Explain:
1. What is Temperature and why it matters
2. The core architecture and required tools
3. Step-by-step implementation plan
4. Common mistakes to avoid: Leaving temperature at the API default — always set temperature explicitly; never rely on the default, Using high temperature for JSON output — even temperature 0.3 can cause occasional malformed JSON; use structured output modes when available, Assuming temperature 0 means perfect accuracy — the model can still be wrong at temperature 0; it just makes the same mistake consistently
5. Best practices and production tips

Official Resources