Written by Martin Ågren - March 17, 2025
Prompt engineering is the art of writing good instructions or questions (writing good prompts) in order to get good answers (qualitative output) from AI.
One of the best pieces of advice I could give is: Try learning by doing! The more you practice prompting AI chatbots, the better you get at it. And be curious and experiment. Try different prompts and compare the results. Draw conclusions. That's a great way of getting better at prompt engineering. But of course, I also suggest you take a look at the prompting strategies I have listed below.
To some extent prompt engineering techniques have been built in new models (like CoT-based reasoning models) but prompt engineering is still very relevant.
Since prompt engineering is about obtaining the best possible output quality from AI, it's important to understand AI hallucinations. Therefore, first read the page about AI hallucinations before proceeding to the strategies for prompt engineering listed below.
The AI reasons step by step. Avoid for reasoning models, since such models aleady reason step by step.
Difference from CoT: Uses fewer words per step (saving time and tokens). Almost as good output as CoT but much more efficient.
The AI reasons step by step. Avoid for reasoning models, since CoT is already built-in.
Difference from CoD: Lengthier outputs but sometimes a bit better output quality.
Write clear instructions - Avoid misunderstandings – The AI should not have to guess.
Have a conversation with the chatbot: Ask follow-up questions or demand better answers.
Delete part of a chat: You can make the lower part of a chat disappear.
Good for making conversations short (AI gets less confused).
Hover over input field + Click pencil icon + Rewrite prompt + Click Send.
Use triple quotes to define starting point and ending of your reference text.
Prompt example:
Here is a reference text:
"""
Prompt engineering is...
"""
Swedish usually works well – English is the safest/best (especially for complex tasks) since most training data is in English.
Provide examples for good output.
Zero-shot prompt = 0 examples - Saves time, but does not optimize output, might not be necessary for simple tasks/questions.
One-shot prompt = 1 example
Few-shot prompt = 2+ examples - Recommended for complex tasks.
Activate internet search when prompting.
Sometimes it's best with Internet search activated, and sometimes it's best not to force AI to search online before answering.
Advantage of long prompt: Easier to reuse (saves time in the long run).
Disadvantage of long prompt: Takes more energy and time to create the first prompt.
To see examples of prompt format: See heading "Delimiters".
Example: “Act as a prompt engineering expert.”
Personal preference: I often define themes instead.
Ask AI to check its own output:
“Check your previous output. Is it correct? Could your output be improved?”
Even with short inputs and outputs, the conversation as a whole can become unnecessarily long. This can be a problem, since the AI chatbot can become confused trying to keep track of all previous information in the conversation. Strategies:
Start a new conversation instead of letting the current conversation get unnecessary long.
Delete part of the conversation (if the AI tool allows it).
Avoid unnecessary long inputs/outputs, to prevent the AI being distracted by excess information.
Short inputs: Create short and concise inputs (but with enough info)
Short outputs: Instruct AI to keep outputs short: “Always short answers, please!”
Break down tasks into multiple steps.
Especially useful for complex tasks. Example: Creating several code snippets instead of long and complex segments of code.
Define the type of style or tone you want from the AI chatbot.
Example: “Casual but still professional tone.”
Define who the target audience and recipients of the text are.
Define a theme for the conversation (or define AI's role).
Example: "Topic for this conversation: Prompt engineering".
Upload file(s) when prompting, for example a PDF file with accurate information that is relevant for the topic.
Explain who you are and what is important for you related to the given task.