Prompting Basics
After understanding GPT and how it generates text, the next most important skill is prompting.
A powerful model without a good prompt often produces weak or confusing results. Prompting is the art of communicating clearly with AI models.
In this lesson, you will learn what prompting is, why it matters, how prompts influence output, and how to write effective prompts for real-world use.
What Is a Prompt?
A prompt is the input text you provide to a language model to guide its response.
It can be:
- A question
- An instruction
- A partial sentence
- A role description
The model uses the prompt as context to generate the next tokens.
Why Prompting Is Important
GPT models do not truly “understand” intent. They rely completely on the prompt.
A vague prompt produces vague output. A clear prompt produces clear output.
Good prompting helps:
- Reduce hallucinations
- Improve accuracy
- Control tone and format
- Save time and retries
Simple Prompt Example
Prompt:
Explain machine learning.
This prompt is short and general, so the output will also be general.
Now compare with a better prompt.
Improved Prompt:
Explain machine learning in simple terms for a beginner, using real-life examples.
The second prompt gives clarity on:
- Audience
- Depth
- Style
Types of Prompts
There are different styles of prompts depending on the task.
1. Question-Based Prompts
Used when you want explanations or facts.
Example:
What is tokenization in NLP?
2. Instruction-Based Prompts
Used when you want the model to perform a task.
Example:
Summarize this paragraph in 3 bullet points.
3. Role-Based Prompts
You assign a role to the model to guide behavior.
Example:
Act as an NLP instructor and explain TF-IDF.
4. Completion Prompts
You give a partial sentence and let the model continue.
Example:
Artificial intelligence is transforming the world by
Prompt Structure (Best Practice)
A well-structured prompt often includes:
- Context: background information
- Task: what you want done
- Constraints: length, style, format
Example:
You are an NLP expert. Explain tokenization to a beginner in under 150 words using simple examples.
How Prompt Changes Output (Key Insight)
The same model can give very different outputs for small changes in the prompt.
Prompt A:
Write about NLP.
Prompt B:
Write a beginner-friendly explanation of NLP with one real-world example.
Prompt B produces:
- More focused response
- Better readability
- Higher usefulness
Where to Practice Prompting
You can practice prompting using:
- OpenAI Playground
- Chat-based AI tools
- Hugging Face text generation demos
Try changing one line in a prompt and observe output changes.
Common Prompting Mistakes
Beginners often make these mistakes:
- Using vague instructions
- Asking multiple tasks in one prompt
- Not specifying output format
- Expecting perfect answers without guidance
Prompting is an iterative skill.
Practice Questions
Q1. What is a prompt?
Q2. Why is prompting important?
Quick Quiz
Q1. Which prompt type assigns behavior to the model?
Q2. Does a longer prompt always mean better output?
Homework / Assignment
Theory:
- Write two prompts for the same task: one vague, one clear
- Compare the outputs
Practical:
- Open an AI text generator
- Try role-based prompting
- Change constraints (length, tone) and observe results
Quick Recap
- A prompt guides model behavior
- Clear prompts produce better outputs
- Prompting is a skill, not magic
- Small changes can lead to big differences
Next lesson: Zero-Shot and Few-Shot Learning