AI

Prompt engineering for beginners: a guide with examples

What prompt engineering is, the key ideas and simple techniques: how to write requests to AI tools to get accurate and useful answers. With prompt examples.

Introduction

Prompt engineering is a fairly new but fast-growing field. It is about writing effective requests (prompts) that bring out the full potential of large language models (LLMs). These models can understand what a user wants, follow instructions and produce the results asked for. You can define prompt engineering as the art and science of designing and improving prompts. Good prompts guide AI models, especially LLMs, towards the answers you need. With carefully written prompts, the user gives the model context, instructions and examples. These help it understand the intent and give a meaningful answer. In AI, a prompt is the input you give a model to get a specific answer. It can be a simple question or a keyword. It can also be a complex instruction, a piece of code or even a sample of creative writing.

Key ideas in prompt engineering

Understanding the key ideas is the foundation of good prompt engineering. One of the basic units AI models use to process text is the token. A token is the smallest unit of text that the model analyses to produce answers. Depending on the language and the model’s tokenisation method, a token can be a single character, part of a word or a whole word. Knowing how tokens work helps you write prompts that are both short and informative, so the model reads your request correctly.

Another important idea is fine-tuning. This means training an already trained AI model further on a specialised dataset, so it performs better in particular tasks or fields. Fine-tuning helps the model understand and produce relevant answers based on highly specialised data.

Priming means giving the AI extra context or instructions before the main request. This background information sets the model in the right direction and helps it produce answers that match the result you want. Priming is especially important for high-quality results in complex or subtle tasks.

The prompt itself is the input text you give an AI language model to get a specific answer. The quality of the AI’s output depends heavily on how well the prompt is written. A clearly written prompt leads to more accurate and relevant answers.

Context means giving relevant background information that shapes the AI’s answer. It makes sure the output is based on the right scenario or situation, so the answer is more coherent and useful. Including context is essential for accurate and meaningful answers.

Prompt engineering is often a process you repeat: you review the results and refine the prompts based on them.

There are also several more advanced prompting techniques. Zero-shot prompting means giving the model a direct request without any examples. One-shot prompting means giving one example of the result you want along with the request. Few-shot prompting takes this further and gives the model several examples of the format or style you want. In chain-of-thought prompting, you ask the model to reason step by step. A complex question is broken into smaller, logical parts, like a human train of thought. This helps the model solve problems in stages instead of answering directly, and it improves its reasoning.

An effective prompt usually has an instruction (what exactly to do) and context (extra information about the situation). It also has input data (the specific information to process) and an output indicator (the format or type of answer you want).

Simple prompt engineering techniques

Beginners can use a few simple but effective techniques to improve their prompts.

Making your instructions specific is one of the key techniques. The more specific and detailed the request, the better the AI can understand and complete the task. Vague instructions can lead to general or incomplete answers. For example, “Write a short story about a robot who wants to become an artist” works better than simply “Write a short story”. Saying what output format you want also matters. For example, you can ask the AI to answer as a list, a table or a paragraph.

Giving context helps the AI understand the task better and give a more relevant answer. Context can include any background information, point of view or role that may affect the AI’s answer. For example, if you ask for investment advice, it helps to describe the current economic situation. When you work with a text, giving the passage your question is about makes the answer much more accurate.

Using keywords is another simple but effective technique. Relevant keywords in the prompt help the AI focus on a particular topic or aspect of the request.

Role prompting is another useful technique: you ask the model to act as a particular character or expert. This can give you more specialised answers that fit the context better. For example, you can ask the AI to act as a marketer or a historian.

Finally, delimiters can make a prompt much clearer to the AI, especially if it has several parts. Delimiters such as triple quotes, brackets or special characters help the AI tell apart the instructions, the context and the input data.

Original promptImproved promptExpected resultHow the technique helps
Write a short story.Write a short story about a robot who wants to become an artist.(A more specific story about a robot artist)A specific topic is added.
Tell me about dogs.Write a descriptive paragraph about the behaviour and traits of golden retrievers, highlighting their friendly nature, intelligence and suitability as family pets.(A detailed description of golden retrievers)Details about the breed and what to describe are added.
Generate product ideas.Generate 5 ideas for innovative eco-friendly products. Present each idea in this JSON format: { "productName": "Product name", "briefDescription": "One-sentence description", "targetMarket": "Main target users" }.(A list of 5 eco-friendly product ideas in JSON format)The number, the topic and the format are given.

Examples of basic prompts and their effect

Even simple examples show how the wording of a prompt affects the result.

Example 1: Completing a sentence

  • Original prompt: The sky is…

  • Result: blue.

  • Improved prompt: Complete the sentence: The sky is…

  • Result: blue during the day and dark at night.

In this example, adding the instruction “Complete the sentence” guides the model to a fuller and more meaningful answer.

Example 2: A question

  • Prompt: What is the capital?

  • Result: (May be ambiguous)

  • Improved prompt: What is the capital of France?

  • Result: Paris.

Giving context (“of France”) makes the request unambiguous and leads to an accurate answer.

Example 3: Naming the audience

  • Prompt: Explain quantum computing.

  • Result: (Probably a technical explanation)

  • Improved prompt: Explain the idea of quantum computing in simple words, suitable for a non-technical audience.

  • Result: (A simplified explanation that non-specialists can follow)

Naming the target audience helps the model match its answer to the user’s level of knowledge.

Prompt without contextPrompt with contextExpected resultHow the technique helps
What is the capital?What is the capital of France?ParisGeographical context is added.
Summarise the article.Summarise the following news article: “[article text]”(A summary of the article provided)A specific text to process is given.
Give me some advice.Given the economic downturn, give me investment advice.(Investment advice that takes the downturn into account)Economic context is added.
Prompt without a rolePrompt with a roleExpected resultHow the technique helps
Explain quantum computing.Explain quantum computing in simple words, suitable for a non-technical audience.(A simplified explanation)A target audience is named, which implies the role of a “teacher”.
Write marketing instructions.Give me detailed instructions on how to measure and improve the performance of an online ad campaign, as if you were a marketing controller.(Detailed expert-level instructions)The role of a “marketing controller” is given.
Assess this diet plan.As a nutritionist, assess the following diet plan: [diet plan].(An assessment from a nutrition point of view)The role of a “nutritionist” is given.

How the wording of a prompt affects the quality and relevance of answers

The wording of a prompt has a big effect on the accuracy, relevance and overall quality of the AI’s answer. Even small changes in word choice, sentence structure and tone can steer the AI towards a certain type of answer.

For example, compare two requests to a model about a McKinsey report:

  1. “Summarise McKinsey’s 2023 ‘Women in the Workplace’ report and give three specific recommendations for improving the situation.”

  2. “Why does flexible working support diversity? Give 4 statistics from McKinsey’s 2023 ‘Women in the Workplace’ report.”

The first request gives a general summary with recommendations. The second focuses on one aspect of the report and asks for facts. This shows how specific requests help models understand exactly what you need.

Another example shows the difference between a weak and a strong prompt when you ask about dogs:

  • Weak prompt: “Tell me about dogs.”

  • Strong prompt: “Write a paragraph describing the behaviour and traits of golden retrievers, highlighting their friendly nature, intelligence and suitability as family pets.”

The more detailed prompt leads to a much more accurate and useful answer.

It is also important to use positive instructions instead of negative ones. AI responds better to clear directions about what to do than to limits on what to avoid. For example, instead of “Don’t make it too long”, it is better to say “Answer in 3–4 sentences”. Positive instructions guide the AI towards useful results and reduce ambiguity.

Original promptAlternative promptComparing the results
Write a summary of the report.Summarise the key findings of the attached research paper as a bulleted list.The second prompt states the format you want, which leads to a more structured and focused result.
Explain the topic.Explain prompt engineering in simple words for beginners.The second prompt makes the target audience and the level of difficulty clear.
Generate marketing ideas.Brainstorm 5 innovative marketing strategies for a new line of organic skincare products aimed at young people who care about sustainability.The second prompt gives specific context about the product, the target audience and the kind of ideas you want.

Using prompt engineering in different fields

Prompt engineering is widely used in many fields.

In writing, you can use prompt engineering to create articles, social media posts, product descriptions, scripts, poems and much more. Good prompts let the AI write content in a given style and tone, for a given purpose. For example, you can ask the AI for an article in the style of an investigative report. You can also ask for an Instagram post that highlights the benefits of a product.

For answering questions, prompt engineering helps you get accurate information from the model’s broad knowledge or from the context you provide. Clear questions with the right context help the AI give the most relevant and accurate answers. For example, you can ask about the capital of France. You can also ask the AI to explain the main causes of deforestation based on a text you provide.

For generating ideas, prompt engineering is a powerful brainstorming tool. Well-written prompts can spark the AI’s creativity and help you find fresh ideas for marketing campaigns, business strategies or content. You can ask the AI for ideas for new products, ad slogans or blog topics.

Tips for beginners: how to write effective prompts

Here are a few key tips that will help beginners write better prompts.

Start with simple, clear prompts and make them more complex as you gain experience. Try different techniques and wordings to see what works best for your tasks. Improve your prompts step by step: look at the results and adjust.

Be specific in your instructions and give enough context for the AI to understand your task. Use positive wording: say clearly what you want, not what to avoid.

Consider giving the AI a role to steer its answer in the right direction. Where needed, use delimiters to structure your prompt and make it easier for the AI to follow.

State clearly the format and length of the answer you want, so the AI can give a result that meets your needs. Use keywords to focus the AI’s attention on the most important parts of your request.

If a task seems complex, try breaking it into smaller subtasks so the AI can work through it step by step. Don’t be afraid to ask the AI to ask you clarifying questions if you feel it hasn’t fully understood your request.

Remember the limits of AI and don’t expect the impossible from it. Always check and double-check the information it produces, especially if you use it for important decisions.

Conclusion

Prompt engineering is a valuable skill in the age of large language models. Understand the key ideas, use simple techniques and try different wordings. This will help you work well with AI and get the results you want in many fields. Start with simple steps, don’t be afraid to try new things, and you will get the most out of prompt engineering.

Photo of Tata, the author of the blog
Author

Tata @mnogobukof

Marketer and social media specialist. I have been bringing AI tools into business processes since 2023.

Ask a question