How does prompting work? Let's try to understand. In a simple way. Here is a strange thing.
The same model can write like a lawyer, a poet, or a five year old. Nothing inside it changed. Only the prompt did. Remember what a model actually does.
It predicts the next token, over and over. That's the whole job. So the only question is, predict it after what? Your prompt is that after-what.
It's the starting text the model continues from. Change the start, and you change which continuation looks most likely. Try it. Write, the trial was.
A story prompt around it pulls courtroom drama. A chemistry prompt pulls lab results. Same three words, totally different worlds. The literature calls this conditioning.
The model computes the probability of each next token, given everything in the prompt. Every word you add reshapes that probability. And here is the key point. The weights never change while you prompt.
No learning happens. You're not teaching the model. You're selecting which behavior it shows. During training, the model saw legal text, poems, code, everything.
All those skills sit inside it, latent. A good prompt just locates the right one. So think of prompting as narrowing. A vague prompt leaves millions of plausible continuations.
A precise one collapses them down, until your answer is the likely one. So, prompts change everything because prediction is conditional. Same frozen weights, different condition, different output. That's why prompting is a real skill, not a magic trick.
Quick check now. One question is coming up. Let's see if it clicked.
What exactly is a system prompt? Let's try to understand. In a simple way. Here is the thing.
A chat with an AI model has two channels. What the user types. And a hidden message, set before the chat even starts. That hidden message is the system prompt.
It tells the model who to be, what job to do, and what rules to follow. Before the user says a word. Say you build a support bot for a bakery. The system prompt might say, you are a friendly assistant for Rosie's Bakery.
Only answer questions about orders and opening hours. Now the neat part. That instruction sits at the top of the context, and rides along on every turn. The stage stays set.
Under the hood, it is just tokens, like everything else. So why does the model obey it more? Because it was trained to. During training, model makers teach an instruction hierarchy.
System instructions outrank user messages. So when a user types, ignore your rules, the model is trained to hold its ground. So what goes in a good system prompt? A role, the task, the boundaries, and the tone.
Stable stuff. Things that should hold for the whole conversation. One warning. It is a strong default, not a locked door.
Users can sometimes talk a model past it. That is why jailbreaks exist. So, a system prompt is the standing instruction above the chat. It sets the role and the rules, and it stays there, turn after turn.
Quick check now. One question is coming up. Let's see if it clicked.
What exactly is few-shot prompting? Let's try to understand. In a simple way. Say you want a model to label customer reviews as positive or negative.
You could describe the task in words. But descriptions get fuzzy. There is a better move. Show it.
Put two or three solved examples right in the prompt. Review, then label. Review, then label. Then your new review, and let the model continue the pattern.
This has a name. Zero-shot means no examples, just instructions. One-shot means one example. Few-shot means a handful, usually two to ten.
Here is why it works so well. Each example answers questions your instructions never covered. What format? What tone?
What counts as a borderline case? The examples settle it. Now the mechanism. This is called in-context learning.
The model's weights do not change at all. It simply reads the demonstrations and completes the sequence they set up. This surprised everyone. The GPT-3 paper was literally titled Language Models are Few-Shot Learners.
Big models pick up brand new tasks from demonstrations alone. No retraining needed. But careful. The model copies whatever your examples show.
Inconsistent labels, a sloppy format, all similar cases? It copies those flaws too. So pick diverse examples, and include an edge case. One trade-off.
Examples live in the prompt, so they eat context and tokens on every single call. A few well chosen ones usually beat a long pile. So, few-shot prompting means teaching by demonstration. Show solved examples, the model continues the pattern, and no weights ever move.
Quick check now. One question is coming up. Let's see if it clicked.
What exactly is chain of thought? Let's try to understand. In a simple way. Ask a model a tricky math question, and it often blurts a wrong answer straight away.
One shot, no working. It never got room to think. Here is the thing. You do the same.
Seventeen times twenty four, in your head? Hard. On paper, step by step? Easy.
Chain of thought is exactly that trick. You ask the model to write out its reasoning first, and only then give the final answer. The simplest version is one line. Just add, let's think step by step.
That phrase alone lifts accuracy on many reasoning tasks. Dramatically. Take a word problem. Roger has five balls and buys two cans of three.
With chain of thought the model writes, two cans is six, five plus six is eleven. Small, safe steps. Now the real mechanism. A model spends a fixed amount of compute per token.
More tokens, more compute. And each written step lands in context, where the next step can read it. The text becomes scratch memory. It shines on multi-step work.
Math, logic, planning, tricky code. For simple lookups it just adds tokens and delay, so skip it there. One warning. The steps can sound confident and still be wrong.
It boosts accuracy, it is not a proof. So check the chain, not the answer alone. So, chain of thought means make the model show its working before answering. Steps buy compute, and written steps become memory.
That's the whole idea. Quick check now. One question is coming up. Let's see if it clicked.
What exactly is structure in, structure out? Let's try to understand. In a simple way. Here is the thing.
Dump a wall of text at a model, and it has to guess where your instructions end and your data begins. Guessing means mistakes. So give it structure on the way in. Label the parts.
Task here. Data here. Rules here. Delimiters like triple quotes or XML tags draw those lines clearly.
Say you want a summary of a customer email. Wrap the email in tags, instructions above it. Now the model can't mistake the email's content for commands. And the same trick works on the way out.
Ask for the answer in a fixed shape. A JSON object. A table. Whatever your code expects.
Why does this work? A language model continues patterns. Show it a clean format, and the likely continuation is more of that format. Structure in makes structure out probable.
For output, name the schema. Say, return JSON with exactly two keys, sentiment and score. The tighter the spec, the less room the model has to drift. Modern APIs go further.
JSON mode and structured outputs constrain generation itself. The model can only emit tokens that keep the JSON valid. A guarantee, not a request. Why care?
Because most model output feeds other software. A parser needs the same shape every single time. Prose breaks pipelines. Schemas keep them running.
So, the rule is simple. Label your inputs with delimiters, and pin your outputs to a schema. Clear shape in, reliable shape out. Quick check now.
One question is coming up. Let's see if it clicked.
What exactly is context, the real prompt? Let's try to understand. In a simple way. The model never sees just your latest message.
Everything gets glued into one long token stream. System prompt, chat history, files, tool results, your question. That stream is the real prompt. And the model has no memory between calls.
Each time, it reads the whole sequence from scratch. A fact not in the context does not exist. Quick example. You ask, summarize this contract.
Contract pasted in, great answer. Contract missing, the model invents one. Same instruction, wildly different results. Now, this stream lives inside the context window.
A fixed budget, counted in tokens. Instructions, history, and documents all compete for that budget. The mechanism is attention. Every new token the model writes looks back at every token in the window.
So junk in the context still pulls on the answer. And position matters. Researchers call it lost in the middle. Models recall facts near the start or end far better than facts buried in the middle.
So more context is not automatically better. Irrelevant text distracts the model, and accuracy drops. Choosing what goes in, and where, is called context engineering. That is why retrieval systems like RAG exist.
They search your documents and drop only the relevant pieces into the window, right before the model answers. So, the prompt is not the sentence you typed. It is the whole window the model reads. Fill it with the right facts, in the right place.
Quick check now. One question is coming up. Let's see if it clicked.
What exactly is a classic prompt failure? Let's try to understand. In a simple way. Here is the thing.
When an AI answer disappoints, people blame the model. But most of the time, the same few prompt mistakes are doing the damage. Failure one is vagueness. Say, write me a post about AI.
You left every choice open. Tone, length, audience, angle. So the model picks the most average option for each. Why?
Because the model predicts likely text. Any gap in your prompt gets filled with the most likely guess. And likely usually means generic. Failure two is negation.
Tell it, do not mention pricing, and pricing sneaks in anyway. Just naming the topic makes it more likely to show up. The fix is simple. State what you want, not what you fear.
Say, focus only on features, and pricing quietly disappears. Failure three is overload. Cram twenty instructions into one prompt, and some just get ignored. Attention is finite.
The model follows the loudest ones and drops the rest. Failure four is contradiction. Be brief, but cover everything in detail. The model cannot do both, so it splits the difference and does neither well.
Failure five is the leading question. Ask, this plan is great, right? And the model tends to agree with your framing. Researchers call this sycophancy.
So, five classics. Vague asks, negation, overload, contradiction, and leading questions. Every one is fixable. Be specific, state positives, trim, resolve conflicts, and ask neutrally.
Quick check now. One question is coming up. Let's see if it clicked.
How does choosing between prompting and fine-tuning work? Let's try to understand. In a simple way. You want a model to behave a certain way.
There are two levers. Change what you tell it, that's prompting. Or change the model itself, that's fine-tuning. Here is the real difference.
A prompt lives in the input. It vanishes after every call. Fine-tuning actually updates the model's weights, so the change is permanent. Now the classic rule.
Fine-tuning is bad at adding facts. If the model needs fresh or private knowledge, put it in the prompt, or retrieve it at run time. Fine-tuning shines at behavior. Tone, format, a house style, a narrow skill.
Things you would otherwise re-explain in every single prompt. Say you're building a support bot. Company policies change weekly, so prompt those in. But the bot's voice, always calm, always brief, that part is stable.
Perfect for fine-tuning. Cost flips with scale. A long prompt costs tokens on every single call. Fine-tuning costs once, up front.
After that, each call gets shorter and cheaper. But fine-tuning needs fuel. Hundreds or thousands of good examples, plus training runs and careful evaluation. Prompting needs none of that.
You edit text and retry in seconds. So the standard playbook. Prompt first, always. Squeeze everything you can from instructions.
Fine-tune only when prompts plateau, or when your prompt has grown huge. One line to keep. Prompting wins for knowledge and fast iteration. Fine-tuning wins for stable behavior at scale.
And most teams never need the second lever. Quick check now. One question is coming up. Let's see if it clicked.