Prompt Engineering: Things You Must Know to Gain Maximum Value From Gen AI Tools

11 min read
Prompt Engineering: Things You Must Know
Prompt Engineering: Things You Must Know

When ChatGPT was introduced to the public, everyone got instantly hooked. But soon it became obvious that the tool itself isn’t of great help if you don’t know how to use it. The same applies to any Gen AI tool, whether it’s an image generator or a code-writing tool. Using GitHub Copilot to write code in seconds sounds impressive but without good prompts, it is only a pipe dream.  

That’s when prompt engineering steps in. At Flyaps, we have hands-on experience building generative AI solutions for our clients. We also experiment with different use cases in our company, creating various prompts and seeing how they improve our work processes. In this article, we’ll share what we learned after experimenting with different LLMs and how to write prompts that AI perfectly understands.

But before diving into the topic, let’s first settle on what exactly prompt engineering is.

Is prompt engineering a skill or a profession of its own?

Prompt engineering is an umbrella term that refers to training processes behind language models. Developers create an input (prompt) that goes into a large language model (LLM) or a gen AI tool (ChatGPT, Gemini, Microsoft Copilot). The prompt is later fine-tuned to improve the output accuracy.

Is prompt engineering a skill that developers dealing with language models must have or a new profession?

When a new technology emerges, it often creates new professions. This once happened with the rise of crypto and NFTs, where we saw the emergence of roles such as blockchain developers, crypto analysts, NFT artists, and so on. Similarly, with the wave of AI, we're witnessing new roles focused on machine learning, data science, AI ethics, and, of course, prompt engineering. But will these new jobs stand the test of time?

prompt engineer on Google Trends
On Google Trends, the term "prompt engineer" — which was practically non-existent at the start of 2023 — has risen rapidly, hitting peak popularity in April 2023. Image source

Job platforms such as Indeed and LinkedIn reflect this growing demand, with thousands of prompt engineer job listings in the US alone. Salaries for these roles span from $50,000 to upwards of $150,000 per year.

 Prompt Engineer
If you search Prompt Engineer on Indeed, you’ll see multiple job offers. 

The skills listed in these postings usually include technical proficiency in Python and data structures, experience in machine learning, natural language processing and large-scale model training.

Gen AI and LLMs are definitely going to stay and companies are in a rush to find experts that could train them according to their needs. But whether it’s going to be a profession of its own in a year or two is an open question. From our perspective, it’ll most likely become one of the must-have skills for developers working with AI tools.

“Does an AI developer require a prompt engineering skill? Yes and no: it depends on their tasks. If they work with LLMs, then definitely yes. Without this skill, they won’t get the results they want.”

– Alexander Arhipenko, CTO at Flyaps

Working with LLMs comes with a number of challenges and prompt engineering is a must-have skill to overcome them. Here are some of the challenges that a developer working with AI tools needs to be aware of:

Variability of model outputs

  • One of the primary challenges in working with language models is their inherent variability. A single prompt can yield a range of different outputs, so developers must train the model to always stick to one specific answer without trying to generate a brand-new output every time.

Specifics of different LLMs and clouds

  • Every LLM functions differently and to use them efficiently developers must familiarize themselves with various language models, cloud platforms, and strategies.

Ensuring precision and compliance

  • Accuracy and precision are paramount, especially when it comes to compliance with regulations like GDPR. A slight deviation or mistake in the output can have significant implications, so a prompt engineer needs to ensure that the model doesn’t invent any information and produces only highly accurate responses compliant with relevant laws and standards.

Continuous updating and verification

  • Language models constantly evolve as the amount of company data they rely on keeps increasing. Prompt engineering is needed to train the models to get accurate and relevant outputs because local data grows and previous information becomes no longer relevant. 

To sum up, as LLMs continue to grow data-wise and more businesses are looking to integrate AI into their apps, prompt engineering will soon become a must-have skill for any AI/ML engineer. But what exactly does a good prompt mean and, vice versa, what makes a bad prompt?

Good prompt vs a bad prompt

To put it simply, a good prompt is a clear roadmap for the model that specifies the desired output while also eliminating the chance of irrelevant outputs. It sets clear expectations and boundaries for the language model, ensuring that its answer aligns with the intended purpose.

“A prompt is similar to a programming language. In programming, a developer has a few options for writing a command, but with generative AI, the range of possible prompts is endless.”

– Alexander Arhipenko, CTO at Flyaps

This is why specifying constraints is crucial when writing a prompt. For instance, if you want the model to generate text with the given list of words in the right order, you need to specify that the model should not add new words. Otherwise, a system such as GPT-3.5 will invent new words and produce irrelevant gibberish.

Crafting a well-defined prompt takes more than just knowing what you need to get as a result. You need to convey the task in a way that the model would understand which means including precise instructions and examples to illustrate the desired outcome. And vice versa, if you forget to mention that the model can’t invent elements to complete the task, it surely will do it because it was trained to generate as much content as possible.

To illustrate a good prompt, let's consider a recent e-commerce project our team has worked on. Our goal was to categorize a large number of products by titles and specific parameters such as color and volume. To streamline this process, we integrated the product database with ChatGPT-3.5 and wrote a prompt that the model could understand.

We described the task in detail and inserted an example of the desired output:

Here’s the result the model offered:

Thanks to the detailed task description and the example provided, the model correctly understood the task and classified the extensive database, standardizing parameters like volume and colors.

To sum up, here’s what differentiates a good prompt from a poorly written one:

Good prompt

Bad prompt

  • Clearly states the desired output without unnecessary politeness.

  • Vague and ambiguous, lacks clear instructions on what is expected.

  • Specifies constraints to guide the model's behavior.

  • Allows the model to make irrelevant assumptions.

  • Includes examples to illustrate the desired outcome.

  • Makes it challenging for the model to understand what you want.

  • Provides context or leading questions.

  • Fails to guide the model towards the correct output.

In essence, writing a good prompt is about clearly specifying the desired outcome while also mentioning what the model shouldn’t do. Here’s how we find this sweet spot at Flyaps.

Best practices for writing good prompts

Writing effective prompts is both an art and a science. Here are some tips to help you craft prompts that bring accurate, relevant, and valuable outputs.

1. Write clear instructions

The instructions in your prompt should be clear and direct, leaving no room for ambiguity. Avoid using phrases like "please" or "could you": the model isn’t human, so dry instructions are the best way to communicate with it. Be explicit about what you want the model to do. For example, instead of writing "Could you please provide some information on prompt engineering?" input "Provide an overview of best practices for writing good prompts."

2. Provide enough context

Context is key to guiding the model towards the desired output. This might include examples, constraints, or background information. The more context you provide, the more accurate and relevant responses the model will generate. Here's an example of a prompt for writing unit tests:

“You are a software developer tasked with writing unit tests for a new login authentication module in a web application. The login module handles user authentication using email and password credentials. Your goal is to ensure that the login functionality works correctly, handles edge cases, and maintains security standards.”

3. Make the model operate within the provided context

Ensure that the model operates strictly within the context you’ve provided. Generative AI tools like GPT-3.5 are incredibly versatile and generate content on their own, leading to irrelevant outputs or sometimes hallucinations. Set clear boundaries to ensure that the model stays focused on the task at hand. For instance, if you need to retrieve information from an internal knowledge base, add “Don’t make any suggestions or assumptions” to ensure the model provides only existing information on the topic.

4. Feed the model with specific data

When building your own gen AI solution, feed the model with specific data to improve the output accuracy. This might include product names, numbers, or information related to your business. This way, the model will have enough information about your business to generate more precise outputs without any room for errors.

5. Adopt a gradual approach

Instead of applying a single-shot prompt approach when the model is expected to get the best answer on the first try, we recommend starting with a general prompt and engaging in a conversation with the solution, adding details and more context on the way. This gradual approach allows you to refine the prompt based on the model’s responses, leading to better and more accurate outputs over time.

6. Clear conversation history

If you find that the model is hallucinating or producing irrelevant outputs, consider clearing the conversation history and starting over. Some APIs like OpenAI GPT-3 API offer the ability to clear history, allowing the model to start fresh. This can be especially useful when the model gets lost in the answers and needs a reset.

7. Use the GitHub repository for experimentation

The GitHub repository of prompts can be of great help to try out different prompts and track their performance. GitHub repositories are designed for specific models such as ChatGPT, or consist of general guides for prompt engineering. Feel free to test them and see what prompts bring the best results to your project.

8. Try adding personas

Add personas to your prompts to tailor the model’s responses to a specific audience. For example, you could ask the model to explain something as if it were talking to a child for a simpler answer or specify that the model is an expert in a specific domain to get more detailed and technical responses. You can also specify the style, job position, age, or any other necessary context to tune the model’s output.

9. Ask LLM to generate prompts

Open two separate chat windows or AI platforms, for instance, OpenAI's ChatGPT for one chat and another general AI platform for the second chat.

In the first chat window with GPT-4 or another LLM, ask it to generate a series of prompts. These prompts should be varied in nature to elicit different types of responses. For example, "Create a prompt outlining the different types of functions in programming" or "Write a prompt that breaks down the various categories of functions in programming".

Take the prompts generated from the first chat and insert them one by one into the second chat window of the same or another AI solution. Then analyze the responses to see how AI interprets and expands upon the prompts generated by the LLM. Look for patterns, creativity, coherence, and any unexpected or interesting outcomes.

These practices can help you craft prompts and get the maximum value of AI to improve productivity in numerous ways. Here’s a specific example of how prompt engineering can help you at work.

Prompt engineering in action: AI that classifies the company’s knowledge base

Software development companies often grapple with extensive knowledge bases of stored video and audio files, making it challenging for newcomers to understand the project specifics and developers to quickly access the necessary information. Flyaps is no exception here, so we decided to bring the power of AI to solve this pain.

To address this challenge, we implemented an AI-powered chatbot that allows us to find the needed information in the entire database in seconds. With this chatbot, developers can ask any project or company-related questions and get responses complete with links to the original documents and timestamps to video files. The chatbot operates exclusively within our internal knowledge base, ensuring employees have direct access to data.

As with any generative AI solutions, we had to make sure that our chatbot operates only within the internal dataset and doesn’t make things up. This is when prompt engineering steps in to refine the process. Unlike simple input queries, we write specific questions to guide the model towards the desired output. For instance, asking the chatbot to "summarize what happened in Vancouver" might yield a general response. So we have to specify what exact type of information is needed (specific location, witnesses, time, and such) and add constraints so that the model only provides the relevant information.

To further optimize the chatbot's performance, we developed our own search models tailored to our specific documents and datasets. These custom search models enable the chatbot to work more efficiently with our documents, improving the accuracy and relevance of the responses.

AI capabilities combined with prompt engineering is a revolution in productivity. Whether it’s about streamlining the onboarding process or customer engagement, AI increases efficiency in a way that we could never achieve through manual processes and human-only intervention.

Now, can AI models do prompt engineering for you?

As we briefly mentioned, you can experiment with AI to make it perform its own prompt engineering. After all, if AI can generate responses, why can't it come up with prompts as well? However, things are not that simple.

While AI models are incredibly powerful, they lack the critical thinking capabilities that humans have. A machine's understanding begins and ends with the prompt it receives, it doesn’t think or try to understand the underlying context in the same way humans do.

“Writing a prompt is like aiming at a target. Humans can see the target and adjust their aim based on factors like wind speed, distance, and so on. Machines, on the other hand, can’t "see" the target, they shoot based on inserted parameters that describe the location of the target. Those parameters must be set by humans and the result depends entirely on the accuracy of the prompt.”

— Oleksii, developer at Flyaps

While there are AI models like Leonardo AI that can generate prompts themselves based on several keywords, it doesn't work in more complex scenarios. AI models can certainly assist in generating prompts but their relevance won’t be as good without human oversight.

That’s why if you're looking to empower your business operations with AI, it's crucial to trust the job to experts who understand the intricacies involved. While AI can assist in generating prompts, prompt engineering is a process that should be done by humans.

If you're ready to take your business operations to the next level with AI-powered solutions tailored to your needs, trust the prompt engineering experts at Flyaps. Contact us today to learn more about how we can help empower your business with AI.