a Transformer, and how does self-atte ...
What is Prompt Engineering, Really? Prompt engineering is the art of designing inputs in a way that helps an AI model get what you actually want-not in literal words but in intent, tone, format, and level of reasoning. Think of a prompt as giving an instruction to a super smart, but super literal inRead more
What is Prompt Engineering, Really?
Prompt engineering is the art of designing inputs in a way that helps an AI model get what you actually want-not in literal words but in intent, tone, format, and level of reasoning. Think of a prompt as giving an instruction to a super smart, but super literal intern. The clearer, the more structured, and the more contextual your instruction is, the better the outcome.
1. Begin with clear intention.
Before you even type, ask yourself:
- What am I trying to obtain from the model?
- What should the response look like?
- Who is the audience?
If you can’t define what “good” looks like, the model won’t know either. For example:
- “Write about climate change.” → Too vague.
- Write a 200-word persuasive essay targeted at high school students on why reductions in carbon emissions matter.
- Adding specificity gives models guidance and a frame of reference, such as rather than asking a chef to cook, asking him to prepare vegetarian pasta in 20 minutes.
2. Use Structure and Formatting
Models always tend to do better when they have some structure. You might use lists, steps, roles, or formatting cues to shape the response.
Example: You are a professional career coach. Explain how preparation for a job interview can be done in three steps:
- 1. Pre-interview research
- 2. Common questions
- 3. Follow-up after the interview
This approach signals the model that:
- The role it should play expert coach.
- it must be in three parts.
- Tone and depth expected.
Structure removes ambiguity and increases quality.
3. Context or Example
Models respond best when they can see how you want something done. This is what’s called few-shot prompting, giving examples of desired inputs and outputs. Example: Translate the following sentences into plain English:
- The fiscal forecast shows a contractionary trend.
- The economy is likely to slow down.
- Input: “The patient had tachycardia.
Example: You are a security guard patrolling around the International Students Centre at UBC. → The model continues in the same tone and structure, as it has learned your desired pattern.
4. Set the Role or Persona
Giving the model a role focuses its “voice” and reasoning style.
Examples:
-
“You are a kind but strict English teacher.”
-
“Act as a cybersecurity analyst reviewing this report.”
-
“Pretend you’re a stand-up comedian summarizing this news story.”
This trick helps control tone, vocabulary, and depth of analysis — it’s like switching the lens through which the model sees the world.
5. Encourage Step-by-Step Thinking
For complex reasoning, the model may skip logic steps if you don’t tell it to “show its work.”
Encourage it to reason step-by-step.
Example:
or
This is known as chain-of-thought prompting. It leads to better accuracy, especially in math, logic, or problem-solving tasks.
6. Control Style, Tone, and Depth
You can directly shape how the answer feels by specifying tone and style.
Examples:
-
“Explain like I’m 10.” → Simplified, child-friendly
-
“Write in a formal tone suitable for an academic paper.” → Structured and precise
-
“Use a conversational tone, with a bit of humor.” → More human-like flow
The more descriptive your tone instruction, the more tailored the model’s language becomes.
7. Use Constraints to Improve Focus
Adding boundaries often leads to better, tighter outputs.
Examples:
-
“Answer in 3 bullet points.”
-
“Limit to 100 words.”
-
“Don’t mention any brand names.”
-
“Include at least one real-world example.”
Constraints help the model prioritize what matters most — and reduce fluff.
8. Iterate and Refine
Prompt engineering isn’t one-and-done. It’s an iterative process.
If a prompt doesn’t work perfectly, tweak one thing at a time:
-
Add context
-
Reorder instructions
-
Clarify constraints
-
Specify tone
Example of iteration:
- “Summarize this text.” → Too generic.
- “Summarize this text in 3 bullet points focusing on key financial risks.” → More precise.
- “Summarize this text in 3 bullet points focusing on key financial risks, avoiding technical jargon.” → Polished.
Each refinement teaches you what the model responds to best.
9. Use Meta-Prompting (Prompting About the Prompt)
You can even ask the model to help you write a better prompt.
Example:
This self-referential technique often yields creative improvements you wouldn’t think of yourself.
10. Combine Techniques for Powerful Results
A strong prompt usually mixes several of these strategies.
Here’s an example combining role, structure, constraints, and tone.You are a data science instructor. Explain the concept of overfitting to a beginner in 4 short paragraphs:
-
Start with a simple analogy.
-
Then describe what happens in a machine learning model.
-
Provide one real-world example.
-
End with advice on how to avoid it.
-
Keep your tone friendly and avoid jargon.”
This kind of prompt typically yields a crisp, structured, human-friendly answer that feels written by an expert teacher.
Bonus Tip: Think Like a Director, Not a Programmer
- The best prompt engineers treat prompting less like coding and more like directing a performance.
- You’re setting the scene, tone, roles, and goals — and then letting the model “act” within that frame.
When you give the AI enough direction and context, it becomes your collaborator, not just a tool.
Final Thought
- Prompt engineering is about communication clarity.
- Every time you refine a prompt, you’re training yourself to think more precisely about what you actually need — which, in turn, teaches the AI to serve you better.
- The key takeaway: be explicit, structured, and contextual.
- A good prompt tells the model what to say, how to say it, and why it matters.
1. The Big Idea Behind the Transformer Instead of reading a sentence word-by-word as in an RNN, the Transformer reads the whole sentence in parallel. This alone dramatically speeds up training. But then the natural question would be: How does the model know which words relate to each other if it isRead more
1. The Big Idea Behind the Transformer
Instead of reading a sentence word-by-word as in an RNN, the Transformer reads the whole sentence in parallel. This alone dramatically speeds up training.
But then the natural question would be:
“The cat which you saw yesterday was sleeping.”
When predicting something about “cat”, the model can learn to pay stronger attention to “was sleeping” than to “yesterday”, because the relationship is more semantically relevant.
Transformers do this kind of reasoning for each word at each layer.
2. How Self-Attention Actually Works (Human Explanation)
Self-attention sounds complex but the intuition is surprisingly simple:
Everybody gets an opportunity to “look around the room” to decide:
Self-attention calculates these “listening strengths” mathematically.
3. The Q, K, V Mechanism (Explained in Human Language)
Each token creates three different vectors:
Analogical is as follows:
Finally, it creates a weighted combination of the Values, and that becomes the token’s updated representation.
4. Why This Is So Powerful
Self-attention gives each token a global view of the sequence—not a limited window like RNNs.
This enables the model to:
And because multiple attention heads run in parallel (multi-head attention), the model learns different kinds of relationships at once for example:
Each head learns, through which to interpret the input in a different lens.
5. Why Transformers Replaced RNNs and LSTMs
Flexibility Transformers are not limited to text anymore, they also power:
GPT-4o, Gemini 2.0, Claude 3.x-like multimodal systems
agents, code models, scientific models
Transformers are now the universal backbone of modern AI.
6. A Quick Example to Tie It All Together
Consider the sentence:
Self-attention allows the model to learn this by assigning a high attention weight between “it” and “bottle,” and a low weight between “it” and “water.”
This dynamic relational understanding is exactly why Transformers can perform reasoning, translation, summarization, and even coding.
Summary-Final (Interview-Friendly Version)
A Transformer is a neural network architecture built entirely around the idea of self-attention, which allows each token in a sequence to weigh the importance of every other token. It processes sequences in parallel, making it faster, more scalable, and more accurate than previous models like RNNs and LSTMs.
Self-attention works by generating Query, Key, and Value vectors for each token, computing relevance scores between every pair of tokens, and producing context-rich representations. This ability to model global relationships is the core reason why Transformers have become the foundation of modern AI, powering everything from language models to multimodal systems.
See less