Introduction to Prompt Engineering: How to Create Effective AI Prompts (Part1)

Do you sometimes feel that ChatGPT isn’t as helpful as you’d like? Or that its answers miss the mark? Just like having a meaningful conversation with your partner takes a little finesse, so does interacting with ChatGPT. In this article, I’ll introduce some fundamental techniques to help you communicate effectively with Large Language Models (like ChatGPT) and get the most out of your experience.

Introduction

Prompt Engineering is a discipline that involves creating prompts in a way that GenAI can better understand, leading to more effective results. Writing an effective prompt offers several benefits:

  • Increase the relevance of the output
  • Control the output (length, difficulty, format)
  • Customization

Basics of Prompting

Prompting Role
  • System
    • The System role is used to provide setup information or context that informs the behavior of the model, such as domain-specific information, example, or instructions.
    • For example: The assistant should always maintain a professional tone and avoid discussing personal opinions on politics.
  • User
    • The User role represents the questions/prompts from the user
    • For example: Can you explain how to integrate OpenAI’s API with my existing Python application?
  • Assistant
    • This is the role of the model itself, responding to user inputs based on the context set by the system.
    • For example (response): Sure, to integrate OpenAI’s API with your Python application, you’ll start by installing the OpenAI Python package using pip…
Prompting Elements
  • Instruction: A specific task you want the model to complete
  • Context: Additional information that can help the model understand the questions
  • Input: It can be images, tabular data, or simply questions written in texts
  • Output: The form/type of the output

To provide more clarity, let’s use my thesis topic as an example. The task is to ask the model to create a conceptual model from a set of user stories in the field of music. Instruction: “Create a conceptual model in the domain of music.” Context: Details such as the context, purpose, and constraints on data and the model. Input: User stories. Output: Conceptual diagram.

Tips for Designing Prompts

  • Start simple (i.e. short, or even less tasks at one time). Keep in mind that the process of designing prompt is iterative because you might need to change your words and structure of the prompts based on the response from the model.
  • Specify what you want to achieve with precise words (e.g. Write, Classify, Summarize, Translate, etc.)
  • Avoid ambiguous words. (Two prompts are provided below)
    • Explain the concept prompt engineering. Keep the explanation short and don’t be too descriptive.
    • Use 2-3 sentences to explain the concept of prompt engineering to a high school student.
  • Use Persona Pattern: As a … (role), this can make the model provide the information related to that role. Thus, making the output more accurate and relevant.
  • Make sure that all the provided information is relevant and contribute to the task.

Keep in mind that: Clear + Specific => Better Output!!

This concludes the first note on prompt engineering. I hope it helps you or provides some insights. If you have any questions, feel free to leave them in the comments. See you soon!

Reference

Leave a Comment

Your email address will not be published. Required fields are marked *