If you’re even slightly interested in artificial intelligence, you’ve surely heard of prompt engineering at least once.
It’s a true science of formulating instructions that can guide linguistic models to produce precise and relevant results. It’s therefore not just used for asking questions, but also for structuring a real conversation so that AI can understand the context and the final objective.
Let’s look at the fundamental techniques for use, some unwritten rules, examples, and concrete templates to use.
What is prompt engineering
Prompt engineering is a process that involves designing and optimizing queries to be provided to artificial intelligence chatbots.
Essentially, it serves to guide language models so they can generate answers as close as possible to what you’re looking for. A sort of language to translate, to communicate effectively with AI.
Over the years, studies and research fields focused precisely on this field have emerged, with the aim of refining techniques and providing concrete advice on how to guide models towards optimized answers.
What are the fundamental prompt engineering techniques
First, let’s look at the fundamental techniques to use in prompt engineering to formulate a correct query.
Let’s start with Zero-Shot Prompting, which involves directly requesting a task without providing concrete examples. For example, writing “Recommend me a restaurant for dinner tonight”.
A second option is Few-Shot Prompting, which involves inserting a few examples into the prompt to provide the AI with the style or format you’re looking for. For example, “Recommend a restaurant for dinner tonight similar to the one we had last time, a Japanese place like [restaurant name] but cheaper.”
The third option is Chain-of-Thought, which involves asking the AI to think step by step before providing the final answer. This option is especially useful for logical or mathematical tasks. So, you could write, for example, “Explain the logical reasoning behind this physics problem, proceeding step by step.”
Finally, Role Prompting, where you assign a specific identity to the AI to influence its tone and expertise. For example, “Act as if you were an expert journalist and provide me with a review of this movie that just came out in theaters.”
How to Structure an Effective Prompt
The ultimate goal of prompt engineering is clearly to help the user formulate an effective query, which can guide the AI toward a response aligned with your needs.
To achieve an optimized prompt, there are 4 key elements to keep in mind. Starting with the Persona, who should the AI be? Specify it by impersonating an expert, a mathematician, a critic, and so on.
Then there’s the Task, where you explain what it needs to do specifically. For example, write a letter, translate a text, solve a task. For the Context, provide background information that can help. For example, “This is for a task management software intended for freelancers.”
Finally, there’s the Format, where you explain how you want the output to appear. E.g., “must be at least 200 words, must not contain bullet points, I want hyperlinks, etc..”
Some Practical Prompt Engineering Tips
For a good command prompt to provide to AI, in addition to the basic techniques, there are some practical tips to always keep in mind.
First, it’s essential to be specific. Try to separate instructions from the input text, using tags like
Avoid generic instructions; the more details you provide, the more relevant the final result will be. And remember, if the initial response isn’t what you were looking for, you can ask the AI to refine it or correct some specific points.
Finally, Negative Prompting can be useful: you must explicitly tell the AI what it shouldn’t do. For example, avoid using technical jargon, don’t use familiar terms, and so on.
Remember that, for each AI model, prompt engineering specifications may change. That’s why official guides provided by sources like OpenAI or Google can be useful.
Useful examples of prompt engineering
Let’s now look at some practical examples of prompt engineering to understand how the result can change based on the instructions you provide. to AI.
The first example involves changing perspective. If you don’t apply engineering techniques, ask, for example, “How can I improve this project?”. With the engineering prompt, it becomes “Analyze this project from a lawyer’s perspective and identify any possible logical flaws, financial risks, and structural weaknesses”.
Another example is the case of logical decomposition. Without engineering, you might ask “How much does it cost to produce 500 pieces if....” However, with engineering, it becomes: “Calculate the production cost. Before giving me the total, list the costs of materials, labor, and fixed expenses individually, explaining the calculation for each item”.
We then move on to stylizing the output, where you focus more on how the person answers rather than on the content. In this case, without engineering, the prompt is “Summarize this text.” With engineering, it becomes “Summarize this text in a comparison table that lists the pros, cons, and required resources. Use language appropriate for a boardroom.”
Finally, there are the classic examples used for extraction and transformation. Some examples? Without engineering, a query might be “What do customers say in these reviews?.” With engineering, it becomes “Read these 50 reviews. Extract 3 main reasons for dissatisfaction and present them as priority action items for development teams”.
Ready-made prompt engineering templates
At this point, we provide you with a selection of ready-to-use templates, structured according to the Persona-Task-Context-Format framework.
You can copy them and use them immediately, or modify them according to your needs.
Content Creation
For content creation for blogs or social networks, here is an effective template:
- Persona: Act as an expert on [topic] and a professional copywriter;
- Task: Write a [type of content] on [topic]
- Context: The target audience is people who [description]. The goal is [to generate curiosity].
- Constraints: Use a [type of tone]. Include a call to final action.
- Format: Divide the text into short paragraphs and use relevant emojis. Maximum [word count].
Problem solving
Now let’s look at a ready-made template for problem solving and strategic analysis:
- Persona: You are a senior strategy consultant specializing in [Industry];
- Task: Analyze the following situation: [Describe the problem];
- Procedure: First identify 3 root causes, then propose 3 practical short-term solutions and a long-term vision;
- Format: Present the solutions in a table with the columns: Solution, Estimated Cost, and Expected Impact.
Rapid learning
Do you need AI help with rapid learning? Here’s a template:
- Person: You are an academic tutor capable of simplifying complex concepts;
- Task: Explain [Difficult Concept] to me;
- Context: I have no technical background on the topic;
- Format: Explain as if I were 10 years old (use an analogy).
Text Review
Finally, we provide you with a ready-made template for text review:
- Person: Act as a senior editor with a ruthless eye for detail;
- Task: Review the following text [Paste your text];
- Objective: Make the text more (e.g., Persuasive/Concise/Professional);
- Instructions: Proofread, suggest more elegant synonyms, and rewrite sentences that are too passive or long;
- Format: Provide the corrected version first, followed by a brief list of the main changes made.
Original article published on Money.it Italy. Original title: Cos’è il prompt engineering? Tecniche, esempi e template pronti-