Control the Output – Temperature, Tokens, and System Messages (Practical)
Overview
In this lesson, you will learn:
- How to control AI outputs using temperature, maximum tokens, and system messages.
- Where and how to test these parameters in real-world tools.
- Beginner-friendly, hands-on strategies to fine-tune AI responses.
By the end, you will be able to experiment with AI parameters in practical environments to achieve desired outputs.
Key Concepts
- Temperature: Adjusts randomness and creativity (low → predictable, high → creative).
- Maximum Tokens: Controls the length of AI outputs.
- System Messages: Sets AI role, tone, and behavior.
- Output Control: Helps you make responses consistent, relevant, and in your desired style.
Practical Approach
1. Where to Test These Parameters
- ChatGPT (OpenAI Playground / ChatGPT Plus):
- Temperature slider: 0–1
- Max tokens field: limit response length
- System messages: Use the “Custom Instructions” or GPT system role
- Google Bard / Gemini:
- Options for creative vs. factual responses
- Input boxes can handle step-by-step instructions and role prompts
- Notion AI / Dify / Copy.ai:
- Set tone and output length
- Use templates to test different temperatures or creativity levels
- Coding Environment (Python + OpenAI API):
from openai import OpenAI
client = OpenAI()
response = client.chat.completions.create(
model="gpt-4",
messages=[{"role":"system","content":"You are a friendly teacher."},
{"role":"user","content":"Explain photosynthesis."}],
temperature=0.7,
max_tokens=150
)
print(response.choices[0].message.content)
2. How to Test Parameters Practically
Step 1: Pick a Task
- Examples: Explain AI, write a poem, summarize text, or solve a math problem.
Step 2: Adjust Temperature
- Low temperature (0–0.3) → precise, factual, deterministic output.
- High temperature (0.7–1.0) → creative, varied, playful output.
Step 3: Limit Output Length
- Use max tokens to control concise summaries or long-form responses.
Step 4: Use System Messages
- Define AI’s role for tone and style (teacher, assistant, coach, creative writer).
Step 5: Experiment Iteratively
- Run multiple versions with different settings.
- Compare outputs and observe the effect of each parameter.
Practical Examples
Example 1: Controlling Creativity (Temperature)
- Tool: ChatGPT Playground
- Prompt: “Write a one-line description of AI.”
- Temperature 0.2 → “AI is the simulation of human intelligence by machines.”
- Temperature 0.8 → “AI is like teaching machines to dream, reason, and imagine!”
Example 2: Controlling Length (Max Tokens)
- Tool: ChatGPT Playground
- Prompt: “Summarize photosynthesis.”
- Max tokens 50 → Short summary
- Max tokens 150 → Detailed explanation
Example 3: System Message / Role
- Tool: OpenAI API or Playground
- System Message: “You are a friendly teacher for 10-year-olds.”
- Prompt: “Explain the water cycle.”
- Output: Simple, engaging, age-appropriate explanation
Hands-On Beginner Activity
- Open ChatGPT Playground or your preferred AI tool.
- Select a topic (e.g., “AI in daily life”).
- Set temperature = 0.2, run prompt → observe output.
- Change temperature = 0.8, run prompt → observe differences in creativity.
- Limit max tokens = 50, then 150, compare outputs.
- Add a system message (role = teacher/coach) → note changes in tone/style.
- Record results in a small table:
| Parameter | Value | Output Example | Observations |
Exercises
- Summarize a paragraph in 50 tokens and then in 150 tokens. Compare.
- Write a short poem about AI at temperature 0.2 and 0.8.
- Ask AI to explain a concept using a system message as a teacher.
- Experiment with all three parameters together: temperature, max tokens, system role.
Summary & Key Takeaways
- Temperature controls randomness and creativity.
- Max tokens controls output length.
- System messages define role, tone, and behavior.
- Use real tools (ChatGPT Playground, APIs, Notion AI) to experiment practically.
- Iterative testing builds intuition on how parameters affect outputs, preparing learners for advanced prompt optimization and automation.


