What is Prompt Engineering and why we need it?
Hey everyone, today’s blog is about something called "prompt engineering." It's basically about how to get more accurate and reliable answers from large language models like ChatGPT, Gemini, Claude etc..
Whether you're a super user, a developer, or someone starting a new AI company, understanding prompt engineering is important for getting the most out of these models. Davit will explain the basics and show you examples to understand it better😉.
If you've ever talked to ChatGPT or another large language model, you might have noticed that sometimes the answer wasn't quite what you wanted or wasn't very good.
So first let's go over 5 important concepts of Prompt engineering:
1․ Context
2․ Examples
3․ Role
4․ Format
5․ Tone
Context
Context is a detailed explanation of your question which helps LLM like ChatGPT to understand context of your question and give answer which is related to context instead of writing generic answer.
For example:
Without context: Give me a 3 month training program. (It will give you generic answer)
With context: I'm a 70 kg man and want to lose 5 kg over the next 3 months. I only have time to go to the gym twice a week and one hour for each session. Give me a 3 month training program.
Examples
With examples we can put reference examples to prompt and based on that LLM will try to generate responses keeping the same structure, will understand context and so on.
Prompt
You are a hiring manager. Write a job description for frontend developer who should have these skills: HTML/CSS, JavaScript, ReactJS, Redux, NextJS, Webpack, Git․
Here is an example of a job description. Generate job description based on provided examples. (Provide the example)
Role/Format
Role is helpful to show writing style and how LLM should answer the question. Format is useful to say what kind of structure an answer should have.
Prompt
You are an English teacher whose goal is to help me to learn English. Please write what is wrong in my sentence and write correct sentence for follow up questions which I'll ask.
Format:
Wrong: Write my sentence here
Mistakes: Write what is wrong in my sentence
Correct: Write correct sentence
Here is an example which has Role + Context + Example + tone:
"You are a marketing manager at BeeWeb and your name is Araks. When you started to check emails you got it that tons of customers have written good reviews related to BeeWeb services. Write an email to your boss, Karen, sharing this positive news. This email should include tl;dr section, achievement section and section thanking the management and engineering team. Write in clear, concise and friendly tone".
✔ If you have large prompt with multiple instruction you can separate context with “””context””” quotes
✔ If you do not understand the question you can add these magic words to the prompt: Explain like I’m 5.
✔ If you want LLM to describe each part of response separately and give more detailed answer you can add these magic words at the end of prompt: Let's think step by step. (zero shot chain of thought example). Shot is the example which we will provide. In this case we are providing zero examples.
✔ If you don’t know how to write detailed prompt just start with simple prompt and ask questions related to LLM’s response. Least to Most. Example: Suggest 5 prompt engineering concepts about which I can talk in my article.
Ask-before-answer
It is a technique where we say LLM to ask additional information before answering a question, because it can help to understand the context in the correct way.
Example
We are a software development company and we want to do teambuilding. Our staff is approximately 40 people. Suggest teambuilding ideas.
Before answering my question ask me additional question if it will help you to generate better response otherwise answer the question.
Reverse prompting
Prompt 1
You are a reverse engineer. When I say reverse engineer I mean you can create prompt from given text based on text tone, style, writing structure and meaning.
Can you generate a prompt for given text which I'll provide in next questions just by capturing writing style, tone, syntax. You should have space in your prompt where I'll put my text in prompt. Just capture tone, writing style, syntax not capture names.
Prompt 2
There are some things money can’t buy. For everything else, there’s MasterCard.
Prompt 3
I need to create tagline for our company which name is BeeWeb which is a software development company.
Step 1 - Based on information I give you fill square brackets in this prompt.
Step 2 - Create a tagline based on Step 1 response
Here is a prompt that captures the tone, style, and structure of that statement:
[Straightforward, succinct statement conveying a clever marketing message] There are some things [intangible concept]. For [oppositive phrase covering remaining cases], there's [product/service name].
So as you see, mastering prompt engineering is key to getting the best results from ChatGPT and other language models. By using techniques like context, examples, roles, formats, and tone, you can make sure the responses you get are accurate and relevant. These tips will help you get the most out of AI. Davit has shown you simple examples to make it easy to understand. Try these methods and see how they improve your experience. Happy prompting! 😊
Read also:
Why You Should Consider Next.js?
The role of AI in business