Have you ever asked ChatGPT a question, received an answer that wasn't quite what you wanted, and thought:
"That's not what I meant!"
So you try again.
You change a few words, add another sentence, or explain your question differently.
Sometimes the answer improves. Other times, it gets even more confusing.
If you've experienced this, you're not alone.
I spend my days testing open-source AI models on real documents, including research papers, resumes, and contracts.
And here's something I've learned: sometimes the model doesn't give us the result we expect, not because it can't do the task, but because we haven't explained the task clearly enough.
Of course, unclear instructions aren't the only reason AI fails. Sometimes the model simply doesn't have the necessary information or ability.
But learning how to give better instructions can make a real difference.
That's where prompt engineering comes in.
Don't let the word engineering scare you.
You don't need to know programming, mathematics, or anything about how computers work to get started.
You just need curiosity and a willingness to experiment.
In this first part of our six-part series, we'll explore what prompt engineering means, how AI generates answers, and why concepts like tokens, context windows, temperature, and hallucinations matter.
Let's start with something simple.
Who Is This Series For?
This series is for:
- Complete beginners who want to understand AI.
- Everyday AI users who use ChatGPT, Claude, Gemini, or similar tools but sometimes get frustrating results.
- Students and professionals who want AI to help with learning, writing, or everyday tasks.
- Developers who want to understand how to communicate better with AI models.
- Anyone curious about how AI works behind the scenes.
Prerequisites: None. Just curiosity and access to an AI chat interface.
1. The Mindset Shift: From Asking AI to Guiding AI
Imagine walking into a coffee shop and saying:
Give me something to drink.
The person behind the counter has many options.
Coffee? Tea? Juice? Something hot? Something cold?
They might give you a perfectly good drink, but it might not be what you wanted.
Now imagine saying:
I'd like a medium-sized hot coffee with milk and no sugar, please.
Much better, right?
You've explained what you want instead of leaving the other person to guess.
The same principle applies when communicating with AI.
Example: Asking AI a question
Let's say you ask:
Explain climate change.
The AI might give you a long explanation filled with scientific terms.
The information could be correct, but it might not be useful to you.
Now try:
Explain climate change to a 12-year-old student. Use simple English, give two everyday examples, and keep the explanation under 150 words.
See the difference?
In the second request, you've provided:
- Task: Explain climate change.
- Audience: A 12-year-old student.
- Style: Simple English.
- Examples: Two everyday examples.
- Length: Under 150 words.
You've made your expectations clear.
This is the basic idea behind prompt engineering.
Prompt engineering is the process of designing and improving instructions so AI can produce more useful, relevant, and consistent responses.
A prompt is simply the question, instruction, or information you give an AI model.
Prompt engineering isn't about discovering magical words that make AI smarter.
It's about communicating what you need as clearly as possible.
The mindset shift
| Before Learning Prompt Engineering | After Learning Prompt Engineering |
|---|---|
| "Let me ask the AI..." | "Let me design a clear prompt..." |
| "Why is this answer bad?" | "What information or instruction might be missing?" |
| "I'll try different words." | "I'll change one thing and test whether it helps." |
| "Prompting is magic." | "Prompting is something I can learn and improve." |
| One-time conversations | Reusable instructions that can be tested and improved |
There's a simple principle behind this:
Move uncertainty from the AI's guesswork into your written instructions.
In other words, don't leave important details for the AI to figure out on its own.
Tell it what you expect.
And when you receive an answer, check whether it actually meets those expectations.
But why does this work?
To understand that, we need to look at how language models generate answers.
2. How Do Large Language Models Actually Work?
Before we go further, let's understand two terms.
Artificial Intelligence (AI) is a broad name for technology that can perform tasks we usually associate with human intelligence.
Large Language Model (LLM) is a type of AI trained to work with language. It can answer questions, summarize information, write stories, translate text, and solve different kinds of problems.
ChatGPT, Claude, and Gemini are examples of AI assistants powered by language models.
Now here's an interesting question:
When you ask an AI a question, how does it know what to say next?
The autocomplete analogy
Think about typing a message on your phone.
You write:
I'll see you...
Your keyboard might suggest:
- tomorrow
- later
- soon
It suggests these words because it has learned patterns in how people write.
A language model uses a related idea, but on a much larger and more advanced scale.
During training, language models learn patterns and relationships from enormous amounts of information.
When you provide a prompt, the model uses its training and the information available in the conversation to generate an answer.
One important part of this process is next-token prediction.
Don't worry about the word token yet. We'll explain it in the next section.
For now, think of it as predicting what piece of text should come next.
Phone autocomplete vs. language models
| Phone Autocomplete | Large Language Model |
|---|---|
| Suggests words while you type | Can generate complete explanations, conversations, and documents |
| Uses relatively simple language patterns | Learns complex relationships from large amounts of data |
| Usually considers a small amount of text | Can work with much longer conversations and documents |
| Primarily helps complete text | Can also compare, summarize, analyze, and solve problems |
The autocomplete comparison helps us understand how text generation works.
But modern language models are far more capable than ordinary keyboard suggestions.
They can perform meaningful reasoning, and some models can spend additional steps working through complex problems before producing an answer.
A simple prediction example
Imagine you type:
The sun rises in the...
The model might consider possible continuations such as:
"east"
"morning"
"sky"
These possibilities don't all have the same likelihood.
Based on the sentence and the patterns it has learned, the model may find "east" to be a suitable continuation.
So the output could be:
The sun rises in the east.
This is a simplified illustration of text prediction.
Underneath, language models work with smaller pieces of text called tokens, not always complete words.
And that leads us to our next concept.
3. Tokens: The Building Blocks of AI Language
Have you ever wondered whether AI reads text the same way humans do?
Not exactly.
Before a language model processes text, it is divided into smaller pieces called tokens.
Think of tokens like building blocks.
Just as we use individual blocks to build something bigger, language models process smaller pieces of information to work with text.
A token can be:
- A complete word
- Part of a word
- A punctuation mark
- A combination of spaces and letters
Let's look at an example
Suppose we have this sentence:
Hello world!
A tokenizer might divide it into:
"Hello" " world" "!"
Notice that the second piece contains a space before the word.
That can happen because spaces affect how text is divided.
But here's where things get slightly more technical.
What are token IDs?
Each token is represented by a number called a token ID.
Think of it like assigning an identification number to each building block.
For example, an illustrative representation might look like this:
Text: "Hello world!"
Tokenization:
"Hello" → [101]
" world" → [205]
"!" → [9]
Total: 3 tokens
The model receives token IDs:
[101, 205, 9]
Important: These numbers are examples, not actual IDs from a specific model. Real token IDs depend on the tokenizer being used.
The exact way a sentence is divided can also vary between models.
Why are tokens important?
Because AI models have limits on how much information they can process at once.
And those limits are usually measured in tokens.
For English text, a commonly used rough estimate is:
1 token ≈ 0.75 words
100 tokens ≈ 75 words
4,000 tokens ≈ 3,000 words
These aren't exact conversions.
Different languages, unusual words, numbers, and symbols can require different numbers of tokens.
A real-world example
Imagine you upload a long document and ask AI to summarize it.
The model needs to process the document's tokens, your instructions, and potentially its own generated response.
If there's too much information, it may exceed the amount the model can handle in one request.
That limit is related to something called the context window.
Before we explore that, let's understand how tokens become an answer.
4. Every Answer Is Generated Step by Step
Remember the next-token prediction idea?
Let's explore it a little further.
Imagine asking AI:
Write a short poem about coffee.
The model doesn't necessarily begin by writing the entire poem at once.
During text generation, it produces tokens step by step.
At each step, the model estimates how likely different possible next tokens are, based on the text and information available so far.
A simplified example
Imagine the model is deciding how to begin.
It might assign probabilities like:
Possible next word:
"Morning" → 40%
"Warm" → 30%
"Coffee" → 20%
"Steam" → 10%
These are made-up numbers to illustrate the concept, not actual measurements from a model.
Probability simply means how likely something is to happen.
For example, a 40% probability means that an option is assigned a likelihood of 40 out of 100 in this simplified situation.
Depending on how the model is configured, it might choose the most likely option or sample from several possibilities.
Let's say it starts with:
Morning
It then considers what should come next.
It continues this process until it produces something like:
Morning coffee glows
Warmth rises into the air
A new day begins
The model generates the response piece by piece, using the previous text to help determine the next piece.
Does this mean AI cannot reason?
No.
This is an important distinction.
Next-token prediction describes an important part of how language models generate text.
It doesn't mean models are limited to repeating memorized sentences.
They can learn relationships, apply patterns, compare ideas, perform calculations, and reason through problems.
Some advanced models also use additional reasoning steps before presenting their final answer.
However, the fact that an answer sounds reasonable doesn't automatically mean it's correct.
That's why prompt engineering involves not only giving clear instructions but also checking the results.
5. Context Window: The AI's Working Space
Imagine you're preparing for an exam.
Your desk contains:
- A textbook
- Your notes
- Practice questions
- Previous lessons
- A notebook
But your desk has limited space.
You can't spread every book and paper across it at once.
You have to choose which information to keep in front of you.
A language model has a similar limitation.
It's called the context window.
A context window is the amount of information an AI model can consider during a request.
You can think of it as the model's working space.
What goes inside the context window?
Depending on the application, it may contain:
| Information | Meaning |
|---|---|
| System instructions | Rules or guidance provided to the AI |
| Examples | Sample questions and answers that demonstrate what you want |
| Your prompt | Your actual question or instruction |
| Documents | Information you provide for the model to use |
| Previous messages | Earlier parts of the conversation |
| Generated response | The answer the model is producing |
All of these can use space within the available limit.
How big is a context window?
Different models have different context-window sizes.
For example, model configurations have been offered with limits such as:
16,000 tokens
128,000 tokens
200,000 tokens
1,000,000 tokens
These are illustrative sizes found across different model families, not a list of current limits for specific products.
A larger context window generally allows a model to work with more information at once.
However, a larger context window doesn't guarantee that the model will use every detail correctly.
A practical example
Suppose you provide a 100-page document and ask:
Summarize the important findings in five points.
If the document fits within the model's available context, the AI can use it while generating an answer.
But if it is too large, you may need to divide it into smaller sections.
Even if the document fits, the model might overlook an important paragraph.
That's why it helps to give specific instructions such as:
Summarize the five most important findings from this document. Include the page number for each finding. If any information is unclear, mention that instead of guessing.
Notice how this prompt makes the output easier to verify.
Is the context window the same as memory?
Not exactly.
A context window refers to the information available during a particular request.
Some AI applications offer separate memory features that can save or retrieve information across conversations.
These are not the same thing.
The main takeaway: Give AI relevant information, organize long documents clearly, and don't assume that everything in a large conversation will always be used perfectly.
6. Temperature: Creativity vs. Consistency
Have you noticed that AI sometimes gives different answers to the same question?
For example, you might ask:
Write a birthday message for my best friend.
One response could be emotional and heartfelt.
Another could be funny and playful.
Why does that happen?
One factor that can influence variation is a setting called temperature.
The name sounds complicated, but the idea is simple.
Think of temperature as a setting that influences how predictable or varied the model's word choices are.
Imagine a creativity dial
At lower temperatures, the model generally chooses more predictable responses.
At higher temperatures, it allows more variation.
| Temperature example | General behavior | Possible use |
|---|---|---|
| 0.0 | More predictable and focused | Finding information in a document |
| 0.7 | Allows more variety | General writing and brainstorming |
| 1.5 | Can produce much more varied responses | Experimental creative writing |
These numbers are examples, not universal recommendations.
The supported temperature range and its effect depend on the particular model.
Also, a temperature of 0 doesn't guarantee identical answers every time.
Does higher temperature mean smarter AI?
No.
Temperature does not measure intelligence.
It also doesn't measure how truthful an answer is.
A higher temperature may produce more surprising writing, but it can also make responses less consistent.
Can you change the temperature?
That depends on the AI tool.
Some platforms and programming interfaces allow users to set temperature directly.
Others manage it automatically or don't provide the setting.
For everyday chatbot users, the important lesson is that you can still guide the style of an answer through your prompt.
For example:
For a straightforward answer:
Explain this topic in five simple points.
Use clear language and avoid unnecessary details.
For a creative answer:
Give me five unusual and creative ideas
for a birthday surprise.
You don't need access to temperature controls to start writing better prompts.
7. Hallucinations: When AI Confidently Gets Things Wrong
Now let's discuss one of the most important limitations of AI.
Imagine you're planning to travel tomorrow.
You ask:
What time does the last bus leave?
The AI answers:
The last bus leaves at 7:30 PM.
That sounds helpful.
But what if the bus schedule changed recently?
What if the AI doesn't have access to the updated timetable?
Or what if it generated a reasonable-sounding answer without reliable information?
You might end up missing your bus.
This is related to a problem called AI hallucination.
An AI hallucination occurs when a model generates information that is incorrect, invented, or unsupported, even though the answer may sound convincing.
What can AI hallucinate?
It might generate:
- A book that doesn't exist
- A research paper that was never published
- A website link that doesn't work
- A quotation someone never said
- An incorrect date or number
- A made-up explanation that sounds reasonable
Why does this happen?
Language models generate responses using learned patterns and the information available to them.
But generating a plausible answer isn't the same as checking whether the answer is true.
Even advanced AI models can make mistakes.
This is a known limitation of language-model systems.
How can we reduce hallucinations?
We can't guarantee that AI will never hallucinate, but we can reduce unnecessary guessing.
For example, instead of asking:
What is the payment deadline?
You could provide the relevant contract and ask:
Read the attached contract.
Find the deadline for the first payment.
Give me:
1. The payment deadline.
2. The sentence where the deadline is mentioned.
If the deadline is not clearly stated,
say "Not found."
This gives the model a specific source and clear instructions.
It also makes the answer easier to check.
However, the model can still make mistakes, so you should verify important results against the document.
A useful habit: Ask AI to clearly say when it doesn't have enough information instead of making a guess.
And remember, telling AI "don't hallucinate" is not a guarantee that it won't.
8. Knowledge Cutoff: Why AI Might Not Know the Latest Information
There's another concept closely related to hallucinations.
It's called the knowledge cutoff.
Language models are trained using information collected during particular periods.
Their built-in knowledge may therefore not include everything that happened afterward.
The point up to which a model's training knowledge extends is commonly called its knowledge cutoff.
Imagine studying from an old textbook
Suppose you studied geography using a textbook published five years ago.
You might know plenty about the subject.
But if a country changed its official rules or introduced a new policy last month, your textbook wouldn't contain that information.
Something similar can happen with AI.
Does that mean AI cannot access current information?
Not necessarily.
Some AI tools can search the web, retrieve documents, connect to other services, or access updated information.
So it's important to distinguish between:
- Training knowledge: Information learned during model training.
- Retrieved information: Information the AI accesses from external sources while completing a task.
If your question depends on the latest information, make sure the AI has access to a reliable and current source.
And even then, verify important facts.
Key takeaway: AI can be knowledgeable without necessarily being up to date.
9. Did the AI Calculate or Predict?
Let's explore an interesting question.
Suppose you ask:
247 × 83 = ?
The correct answer is:
20,501
But how did the AI arrive at that answer?
Did it remember a similar calculation?
Did it recognize a mathematical pattern?
Did it work through the arithmetic?
The answer depends on the model and how it performs the task.
Language models can learn mathematical relationships and perform reasoning.
Some advanced systems can also use calculators or computer tools to perform calculations more reliably.
Now consider a more difficult example:
12,347 × 9,823 = ?
This requires more complicated arithmetic.
Some models may solve it correctly, while others may produce an incorrect answer.
Why does this matter?
Because a confident answer isn't always a correct answer.
Even when AI provides a detailed explanation, the calculation can still contain mistakes.
One useful technique is to ask the model to explain the main steps of its solution.
That can make the result easier to review.
But the safest approach for important calculations is to verify them using a reliable calculator or calculation tool.
We'll explore ways to approach more complicated problems in Part 3 of this series.
For now, remember:
AI can reason and solve problems, but its answers still need checking when accuracy matters.
10. What Does This Mean for Prompt Engineering?
By now, we've learned a few important things.
AI models:
- Generate language using patterns learned during training.
- Process text using tokens.
- Work with a limited amount of information at once.
- Can produce different responses depending on their instructions and settings.
- Can reason through problems, but can also make mistakes.
- May not have the latest information unless they can access updated sources.
So where does prompt engineering fit into all this?
Let's return to the idea we started with.
When instructions are unclear, AI has to make more assumptions about what we want.
And those assumptions might not match our expectations.
Clear prompts can help reduce unnecessary guesswork.
A practical example
Imagine you want AI to summarize a research paper.
Your first prompt is:
Summarize this paper.
The AI might create a long summary, focus on the wrong sections, or include details you don't need.
Now try:
Read the attached research paper.
Explain the main findings to someone
who has no technical background.
Include:
1. What the researchers studied.
2. Why the research matters.
3. The three most important findings.
4. Any limitations mentioned by the researchers.
Use simple English.
Keep the summary under 300 words.
Do not add findings that are not supported
by the paper.
This prompt is more specific.
It provides the task, audience, expected structure, and limits.
It also explains what the model should avoid.
Does that guarantee a perfect summary?
No.
But it makes the result easier to evaluate and improve.
That's an important difference between simply asking AI a question and approaching prompting as a repeatable process.
You can improve a prompt, test the answer, identify what went wrong, and revise the instructions.
That's where prompting starts becoming engineering.
11. Your 5-Minute Exercise
Let's put everything into practice.
You don't need programming experience or special tools.
Just open ChatGPT, Claude, Gemini, or another AI assistant.
Step 1: Start with a basic prompt
Ask:
Explain how a smartphone works in one paragraph.
Read the response.
Ask yourself:
- Was it easy to understand?
- Were there unfamiliar words?
- Did it explain what you actually wanted to know?
Save the response.
Step 2: Make the prompt clearer
Start a new conversation and ask:
Explain how a smartphone works to someone
who has no technical background.
Use simple everyday language.
Explain it in five short points.
Include one real-life example.
Avoid complicated technical words.
Compare the two responses.
Which one is easier to understand?
Did the additional instructions help?
Step 3: Experiment with the audience
Now try:
Explain how a smartphone works
to a 10-year-old child.
Use a fun everyday analogy.
Notice how the explanation changes.
The topic is the same, but the instructions are different.
Step 4: Explore tokens
Visit the OpenAI Tokenizer.
Paste this sentence:
Explain how a smartphone works.
Explore how the text is divided into smaller pieces.
Try changing the sentence and see whether the token count changes.
Remember, token counts can differ between models and tokenizers.
Step 5: Think like a prompt engineer
Ask yourself:
What did I change, and how did that change affect the answer?
You've now taken your first step toward testing and improving prompts instead of randomly trying different questions.
12. Quick Recap: What Have We Learned?
Let's bring everything together.
| Concept | Simple explanation |
|---|---|
| Prompt Engineering | Writing and improving instructions to get more useful AI responses |
| Large Language Model (LLM) | An AI model trained to understand and generate language |
| Next-Token Prediction | Generating text by predicting the next piece of the response |
| Tokens | Small pieces of text processed by a model |
| Token IDs | Numbers used to represent tokens |
| Context Window | The amount of information a model can consider at once |
| Temperature | A setting that influences variation in generated responses |
| Hallucination | When AI generates incorrect or unsupported information |
| Knowledge Cutoff | The point beyond which a model's built-in training knowledge may not extend |
| Verification | Checking whether an AI-generated answer is accurate |
You don't need to memorize every technical term today.
The goal is to understand the basic ideas.
As you continue practicing, these concepts will become more familiar.
What's Coming in Part 2?
Now that we understand how AI generates answers and why clear instructions matter, it's time to learn how to build better prompts.
In Part 2: The Anatomy of a Good Prompt, we'll explore six useful components:
- Role: Who should the AI act as?
- Context: What background information does it need?
- Examples: Can we show it what a useful answer looks like?
- Task: What exactly should it do?
- Constraints: What rules or limitations should it follow?
- Output Format: How should the final answer be organized?
We'll compare a basic prompt with a more carefully designed version.
And we'll use the smartphone example from today's exercise to put everything together.
Final Thoughts
When I started working more closely with AI models, I realized something important.
Getting better results isn't always about using a more powerful model.
Sometimes, it's about understanding what the model needs from us.
A clear instruction.
The right background information.
A useful example.
And a way to verify the answer.
That's the mindset I want to share throughout this series.
Prompt engineering isn't about learning secret commands. It's about learning to communicate with AI more clearly, thoughtfully, and effectively.
And you don't need a technical background to start.
One Question Before You Go
Have you ever asked an AI something and received an answer that was completely unexpected or incorrect?
What did you ask, and what happened?
I'd love to hear about your experience in the comments.
This is Part 1 of 6 in my "Prompt Engineering from Scratch" series. I work with and test open-source AI models on real documents, and I'm sharing what I learn along the way.
Follow the series if you'd like to learn prompt engineering, one practical concept at a time.
Top comments (1)
The change one thing advice is the part to practice first. Keep a copy of your first prompt, then change only the audience or only the length in the next version, so you can see which change actually improved the answer instead of guessing across several edits at once.