Become a Prompt Engineer: A Career Designing and Crafting Prompts for Advanced Language Models

Feb 28, 2023

Become a Prompt Engineer: A Career Designing and Crafting Prompts for Advanced Language Models


As the world of artificial intelligence continues to evolve, so do the roles of those who work with it. One such role is that of a prompt engineer, who is responsible for designing and crafting prompts that guide advanced language models like GPT-3, DALL-E, Midjourney, and ChatGPT.


The Role of a Prompt Engineer


As a prompt engineer, your ultimate goal is to design creative and logical prompts that encourage the language model to generate interesting and varied completions (outputs). You will also need to continuously monitor and improve the prompts and collaborate with your team to achieve the best possible prompt for a particular task. In order to excel in this role, you should arguably have a good understanding of machine learning, natural language processing, and related technologies, as well as programming skills. A logical way of thinking and a practical mindset can also help you excel in this profession - excluding the need for technical knowledge.


Expectations for a Prompt Engineer


The prompt engineer is responsible for designing and crafting prompts for large language models. The role of a prompt engineer includes the following expectations:


Understanding of the Task: You should have a good understanding of the task or application that the model will be used for and design prompts that are relevant and appropriate for that task, that also provide satisfactory completions (outputs).


Knowledge of the Model: You should have a good understanding of the model's capabilities and limitations and design prompts that are within the model's capabilities.


Creativity: You should be able to design creative and varied prompts that encourage the model to generate interesting and varied outputs.


Clear and Concise: You should design prompts that are clear and concise, making it easy for the model to understand the task and stay on track.


Ability to Test and Evaluate: You should test and evaluate the model's output and use that information to improve the prompts and the model's performance.


Continual Improvement: You should continuously monitor and improve the prompts' performance and adjust them as necessary.


Familiarity with Data Bias: You should be aware of the potential biases in the training data and design prompts that minimize them.


Collaboration: You should work collaboratively with other members of the team, such as data scientists, engineers, and product managers.


Technical Skills: You should have a good understanding of machine learning, natural language processing, and related technologies, as well as programming skills. That being said, the recent advertisement for Prompt Engineers on Anthropic’s site stated that programming and machine learning skills were not required.


Stay Current with the Field: You should keep up with the latest developments in the field and be able to apply that knowledge to your work.


Prerequisites



LLM architecture knowledge is a prerequisite for prompt engineers because it provides a foundational understanding of the underlying structure and function of the language model, which is crucial for creating effective prompts. Making ambiguous problems clear and identifying core principles that can translate across scenarios is also important because it allows the engineer to define the task at hand clearly and develop prompts that can be easily adapted to different contexts.


Well-crafted prompts are the final piece of the puzzle, as they are the tool that the engineer uses to communicate the task to the language model and guide its output. Together, these skills and knowledge allow the prompt engineer to create effective and efficient prompts that can be used to train and improve the performance of the language model.


What kind of salary would you expect as a prompt engineer?


Well. We’re early doors, but Anthropic just advertised a role offering to pay an impressive impressive $250k-$335k per annum. Quite a bump right?


Do Prompting Techniques Differ between GPT-3, ChatGPT, DALL-E, and Midjourney?


Prompting techniques can vary between different large language models such as GPT-3, DALL-E/Midjourney, and ChatGPT. For example, GPT-3 uses a combination of unsupervised and supervised learning, where it's trained on a large corpus of text data and fine-tuned on specific tasks. GPT-3 has the ability to generate human-like text, answer questions, and perform other language tasks Each model has its own unique architecture and training data, which can affect how the model responds to prompts.


For example, DALL-E and Midjourney are image-generating models that require different kinds of prompts than text-generating models like GPT-3 and ChatGPT. With DALL-E and Midjourney, the prompts may involve specifying the object to be generated, its properties, and its surroundings. In contrast, prompts for GPT-3 and ChatGPT may involve providing a topic or task to be performed, along with some initial input.


Another factor that can affect prompting techniques is the task or application for which the language model is being used. For example, if the model is being used for natural language generation in a customer service chatbot, the prompts may need to be designed to elicit specific responses that address customer inquiries or issues. This could be achieved by feeding the LLM with data in order for it to learn from previous prompts. In contrast, if the model is being used for creative writing, the prompts may be designed to encourage more open-ended and imaginative responses.


Overall, while there may be some differences in prompting techniques between different large language models, the fundamental principles of designing effective prompts remain the same. A prompt engineer must have a good understanding of the model's capabilities and limitations, the task or application for which it is being used, and be creative and flexible in designing prompts that elicit the desired output.


Do you want to become a better prompt engineer right now? Well, look no further. Here’s a quick walkthrough to help you on your way.



Prompt engineering is a critical component of training AI models. The prompt format determines the quality of output generated by the AI model. This article explains the different prompt formats that work reliably well and offers some rules of thumb to help you generate the best prompt format for your task.


How to improve your prompts right now?


Firstly, don't be an idiot - use the latest Model


Using the latest, most capable models are recommended for the best results. As of February 2023, “ChatGPT” is recommended for text generation, and the "code-davinci-002" model is recommended for code generation.


  1. Put Instructions at the beginning of the Prompt


To separate the instruction and context, use ### or """. This makes it easier to generate better output. For example:


Inferior ❌:

Summarize the text below as a bullet point list of the most important points.


{text input here}


Improved ✅:

Summarize the text below as a bullet point list of the most important points.

Text: """

{text input here}

"""


  1. Be Specific About the Desired Context, Outcome, Length, Format, Style, Etc.


For example:


Inferior ❌:

Write a poem about Promptstacks:


Improved ✅:

Write a short inspiring poem about OpenAI, focusing on the recent DALL-E product launch (DALL-E is a text to image ML model) in the style of a {famous poet}


  1. Articulate the Desired Output Format Through Examples


Show and tell by providing examples. This makes it easier to programmatically parse out multiple outputs reliably. For example:


Inferior ❌::

Extract the entities mentioned in the text below. Extract the following 4 entity types: company names, people names, specific topics, and themes.

Text: {text}


Improved ✅:

Extract the important entities mentioned in the text below. First extract all company names, then extract all people names, then extract specific topics which fit the content and finally extract general overarching themes.


Desired Format:


Company names: <comma_separated_list_of_company_names>

People names: -|Bob|-

Specific topics: -|TopicA|-

General themes: -|Theme 1|-

Text: {text}


  1. Start with Zero-shot, Then Few-shot, Neither of Them Worked, Then Fine-tune


Zero-shot is the first stage in AI model training. If it fails, move to few-shot and then fine-tune the model. For example:


✅ Zero-shot


Extract keywords from the below text.

Text: {text}

Keywords:


✅ Few-shot - Provide a couple of examples.


Extract keywords from the corresponding texts below.


Text 1: Shopify provides APIs that web developers can use to integrate payment processing into their websites and mobile applications.


Keywords 1: Shopify, payment processing, APIs, web developers, websites, mobile applications


Text 2: OpenAI has trained cutting-edge language models that are very good at understanding and generating text. Our API provides access to these models and can be used to solve virtually any task that involves processing language.


Keywords 2: OpenAI, language models, text processing, API.


Text 3: {text}


Keywords 3:


✅Fine-tune: See fine-tune best practices here.


Reduce "Fluffy" and Imprecise Descriptions


Avoid using fluffy and imprecise descriptions. Instead, use a 3- to 5-sentence paragraph to describe the product.


Inferior ❌:


The description for this product should be fairly short, a few sentences only, and not too much more. Make sure to use some keywords.


Improved ✅:


Using a 3 to 5 sentence paragraph. Describe this product.


  1. Instead of Just Saying What Not to Do, Say What to Do Instead


It's more effective to suggest what to do instead of just saying what not to do. For example:


Inferior ❌:


The following is a conversation between an Agent and a Customer. DO NOT ASK USERNAME OR PASSWORD. DO NOT REPEAT.


Customer: I can't log in to my account.


Agent:


Improved ✅:


The following is a convo between a salesperson and a Customer. The salesperson will attempt to diagnose the problem and suggest a solution, whilst refraining from asking any questions related to PII. Instead of asking for PII, such as username or password, refer the user to the help article www.samplewebsite.com/help/faq


Customer: I can’t log in to my account.


Agent:


  1. Be Code Specific - Use “suggestive words” to nudge the model toward a particular pattern


Inferior ❌:


Please write a basic Python function that performs the following tasks:

Prompts the user to enter a distance in miles.

Converts the entered distance from miles to kilometers.


Improved ✅:


# Write a python function that

# 1. Asks me for a number in mile

# 2. Converts miles to kilometers


import


By including the "import" keyword in the code example, the model is provided with a cue to begin generating Python language code. Similarly, the keyword "SELECT" serves as a helpful cue for the model to recognize the start of a SQL statement.


Finally - When working with language models, two common parameters can be adjusted to modify the output. The model and the temperature.


The model refers to the type of language model being used. Generally, higher performance models tend to be more expensive and have a higher latency.


Temperature is a measure of how frequently the model produces less likely tokens. Higher temperatures tend to result in more creative and random output. However, it is important to note that higher temperatures do not necessarily result in more truthful output. For factual use cases such as data extraction and truthful Q&A, a temperature of 0 is usually best.


Another parameter that can be adjusted is the maximum length of the generated text. This is controlled by the max_tokens parameter, which sets a hard cutoff limit for token generation. However, the model may stop generating text earlier if it believes it has completed its task or if it reaches a predefined stop sequence.


The stop parameter defines a set of characters or tokens that, when generated, will cause the language generation process to stop.


Well, that’s just about it. Hopefully after reading this article you know how to craft a better prompt, what a prompt engineer is, and whether this could be a good role for you to pursue. Also, check us out at Promptstacks. We might be able to help…